Skip to content
Prev 165982 / 398502 Next

How to extract range of colums in a data frame

Or this:

new.DF <- subset(dat, select = V3:V9)
'data.frame':	16 obs. of  7 variables:
 $ V3: num  9 18 15 15 21 21 12 15 21 19.5 ...
 $ V4: int  18 8 8 6 21 21 21 9 21 18 ...
 $ V5: num  12 12 12 18 21 ...
 $ V6: num  18 18 12 6 21 21 21 18 21 19.5 ...
 $ V7: num  15 15 18 18 21 21 21 15 21 16.5 ...
 $ V8: num  12 12 12 15 21 21 21 15 21 19.5 ...
 $ V9: num  6 18 12 9 21 21 21 6 21 18 ...


See ?subset for the above and ?"[.data.frame" for additional information
on subsetting data frames, which is also covered in An Introduction to R.

HTH,

Marc Schwartz
on 01/04/2009 08:42 PM Jorge Ivan Velez wrote: