dear all, I tried to use grep to match IDs in two dataframes
grep(DF1$ID[i], DF2$ID) I wanted to use condition in a loop, but I have the problem to define what is in return if a match is not found. I used mode() and class() to compare between the attributes when a match is found and not found, but the mode and class are the same in both cases, numeric and integer, respectively. When a match is not found, grep returns "integer(0)". Is.numeric() and Is.integer() of the return gave TRUE but arithmetic calculation is not possible. For example, If a match is not found for i=12, grep(DF1$ID[12], DF2$ID) returns "integer(0)" and grep(DF1$ID[12], DF2$ID)+10 returns "numeric(0)" I will appreciate any suggestions. Thanks in advance. -- View this message in context: http://www.nabble.com/what-is-returned-if-a-match-is-not-found-using-grep-tp24914127p24914127.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.