I have a table with sample points from which I need to take subsets based on occurrence of these sample points in certain vegetation types. I have to repeat this many times for different combinations of vegetation types, so I have written a small script that gives me the conditions for sub-setting my table as a string, e.g.,

"VT==1 | VT==3"

But how to convert this string to be used in the subset function?

subset(data,VT==1 | VT==3)

Thanks to the invaluable R help archive I found that the following should work:

condition1 <- "VT==1 | VT==3" subset.table <- subset(PNVs, eval(parse(text=conditions1)))

This shows again one reason for the success of R, the incredible amount of information and help available online. And if you can’t find it, there is a good change that somebody can help you out on the R help mailing list.