Let's say that I have a string and I want to know if a single word is present in the string. I've written the following function to see if the word "Geico" is mentioned in the string "Cheap Geico car insurance". However, it doesn't work, and I assume it has something to do with the any() function. Do I need to use regular expressions? (I hope not)
main <- function(keyword){ for( i in keyword ){ n = strsplit(as.character(keyword), " ") print( n ) if( any( n=="Geico" )){ print( "Yes" ) } } } main("Cheap Geico car insurance") I'm running R 2.13 on Ubuntu 10.10 Thanks, Abraham [[alternative HTML version deleted]] ______________________________________________ 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.