[R] grep or other complex string matching approach to capture necessary information...

Jason Rupert jasonkrupert at yahoo.com
Fri Sep 25 19:58:11 CEST 2009


Say I have the following data:


house_number<-floor(runif(100, 200, 600))
water_evaluation<-c("No water damage", "Water damage", "Water On", "Water off", "water pipes damaged", "leaking water")
water_evaluation_selection<-floor(runif(100, 1,6))
house_info<-data.frame(water_evaluation[water_evaluation_selection],
                       house_number) 

And, that I only want to pull out the ones with negative water evaluations, i.e. Water damage, water pipes damaged, and leaking water. 

Should/could I use grep in order to pull the house numbers out of house_info with those negative water evaluations?  

I guess I want to know the house numbers from house_info where the water evaluation is negative.  Is there a way to use grep or another R function in order to acquire that information? 

Thank you again in advance for any insights.




More information about the R-help mailing list