1

Running the following code:

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}

Getting an Error:

Error in if (grep("sales", resume$jobs$title, ignore.case = TRUE, perl = FALSE, : argument is of length zero

zx8754
  • 52,746
  • 12
  • 114
  • 209
RLearner
  • 11
  • 3
  • [How to make a great R reproducible example?](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – zx8754 May 06 '15 at 17:14

1 Answers1

1

You must be thinking of grepl, not grep. grepl returns a vector of logical values. grep just returns the indices of TRUE values (which is of length 0 if there are none). Just replace grep with grepl and you should be fine.

Max Candocia
  • 4,294
  • 35
  • 58