[R] Subset with selection variable from function argument. Is there another way?

From: Fredrik Karlsson <dargosch_at_gmail.com>
Date: Wed 11 May 2005 - 19:01:00 EST


Dear list,

I'm making my current code more generic and would like some advise. The basic problem is subset and the name of the column to be compared for selection.

What I've come up with is

> data(mammals)
> set <- bottompremolars"
> subset(mammals, eval(parse(file="",text=set)) > 2)

This seems a bit odd. Is there a nicer way?

/Fredrik



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Wed May 11 19:07:06 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:41 EST