在正则表达式中,神秘错误:断言';树->;num_tags==num_tags';无法执行regexp:file';tre compile.c';,第634行
假设900多个公司名称粘贴在一起,使用管道分隔符--“firm.pat”形成一个正则表达式模式在正则表达式中,神秘错误:断言';树->;num_tags==num_tags';无法执行regexp:file';tre compile.c';,第634行,regex,r,runtime-error,gsub,stringr,Regex,R,Runtime Error,Gsub,Stringr,假设900多个公司名称粘贴在一起,使用管道分隔符--“firm.pat”形成一个正则表达式模式 traceback()没有启发我 > traceback() 4: gsub("aaronson rappaport|adams reese|adelson testan|adler pollock|ahlers cooney|ahmuty demers|akerman|akin gump|allen kopet|allen matkins|alston bird|alston hunt|alv
traceback()
没有启发我
> traceback()
4: gsub("aaronson rappaport|adams reese|adelson testan|adler pollock|ahlers cooney|ahmuty demers|akerman|akin gump|allen kopet|allen matkins|alston bird|alston hunt|alvarado smith|anderson kill|andrews kurth|archer
# hundreds of lines of company names omitted here
lties in all 50 states and washington, dc. results are compiled through a peer-review survey in which thousands of lawyers in the u.s. confidentially evaluate their professional peers."
), fixed = FALSE, ignore.case = FALSE, perl = FALSE)
3: do.call(f, compact(args))
2: re_call("gsub", string, pattern, replacement)
1: str_replace_all(bio$comment, firm.pat, "")
其他三篇文章也提到了这个神秘的错误,但没有讨论
我知道这个问题缺乏可复制的代码,但即使如此,我如何找出错误的原因?更好的是,如何避免抛出错误?这种错误似乎不会发生在数量较少的公司身上,但我无法检测到模式或阈值。我正在运行Windows 8、RStudio和每个软件包的更新版本
多谢各位 我也遇到了同样的问题,就是由数百个制造商的名字组成的模式。正如我可以建议的那样,这个模式太长了,所以我把它分成两个或多个模式,效果很好
ml<-length(firms$firm)
xyz<-gsub(sprintf("(*UCP)\\b(%s)\\b", paste(head(firms$firm,n=ml/2), collapse = "|")), "", bio$comment, perl=TRUE)
xyz<-gsub(sprintf("(*UCP)\\b(%s)\\b", paste(tail(firms$firm,n=ml/2), collapse = "|")), "", xyz, perl=TRUE)
ml您可以在qdap包中使用mgsub,它是gsub的扩展,用于处理模式和替换的向量
请参阅此我也有类似的问题。你能访问它吗?
> traceback()
4: gsub("aaronson rappaport|adams reese|adelson testan|adler pollock|ahlers cooney|ahmuty demers|akerman|akin gump|allen kopet|allen matkins|alston bird|alston hunt|alvarado smith|anderson kill|andrews kurth|archer
# hundreds of lines of company names omitted here
lties in all 50 states and washington, dc. results are compiled through a peer-review survey in which thousands of lawyers in the u.s. confidentially evaluate their professional peers."
), fixed = FALSE, ignore.case = FALSE, perl = FALSE)
3: do.call(f, compact(args))
2: re_call("gsub", string, pattern, replacement)
1: str_replace_all(bio$comment, firm.pat, "")
ml<-length(firms$firm)
xyz<-gsub(sprintf("(*UCP)\\b(%s)\\b", paste(head(firms$firm,n=ml/2), collapse = "|")), "", bio$comment, perl=TRUE)
xyz<-gsub(sprintf("(*UCP)\\b(%s)\\b", paste(tail(firms$firm,n=ml/2), collapse = "|")), "", xyz, perl=TRUE)