[R] symbolic column extraction ?

ryszard.czerminski@pharma.novartis.com ryszard.czerminski at pharma.novartis.com
Tue Nov 11 20:28:05 CET 2003


I have a data frame (df) with colums x, y and z.
e.g.  df <- data.frame(x = sample(4), y = sample(4), z = sample(4))
I can extract column z by: df$z or df[3]
I can also extract columns x,y by: df[1:2] or by df[-3].

Is it possible to extract x,y columns in a "symbolic" fashion i.e.
by equivalent of df[-z] (which is illegal) ???

Or alternativeley, is there an equivalent of "index" function,
which would return index of the column given name ?




More information about the R-help mailing list