[R] Stumped with subsetting

From: Peter Wilkinson <pwilkinson_at_videotron.ca>
Date: Fri 30 Jul 2004 - 05:22:20 EST

This seems like such a trivial thing to do:

given a data.frame DF and variables w,v, x,y,z I can do

DF["x"] or DF[c("x","y")]

if I create a vector, mylist = c("x",y")

then I do DF[mylist]

I am not getting x and y, I get something else.

what is the correct way to subset a data.frame by columns using a vector, as if I were doing DF["x","y"]?

Peter



R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Fri Jul 30 05:28:06 2004

This archive was generated by hypermail 2.1.8 : Fri 18 Mar 2005 - 02:41:20 EST