1
運行下面的代碼:誤差if語句使用grep
if(grep("sales", resume$jobs$title, ignore.case = TRUE, perl = FALSE, value = FALSE,
fixed = FALSE, useBytes = FALSE, invert = FALSE)) {p2_feature = 1}
else if(grep("\\$[0-9]+",resume$jobs$text,ignore.case = TRUE, perl = FALSE, value = FALSE,
fixed = FALSE, useBytes = FALSE, invert = FALSE)){p2_feature = 1}
else {p2_feature = 0}
得到一個錯誤:
Error in if (grep("sales", resume$jobs$title, ignore.case = TRUE, perl = FALSE, : argument is of length zero
[如何使一個偉大的R可重現的例子?](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – zx8754