[R] How To Extract Row from A Data Frame

Gundala Viswanath gundalav at gmail.com
Mon Oct 4 04:22:50 CEST 2010


I have a data frame that looks like this:


> print(df)
  V2     V3     V4     V5     V6     V7     V8     V9    V10    V11    V12
1 FN  8.637 28.890 31.430 31.052 29.878 33.215 32.728 32.187 29.305 31.462
2 FP 19.936 30.284 33.001 35.100 30.238 34.452 35.849 34.185 31.242 35.635
3 TN  0.000 17.190 16.460 21.100 17.960 15.120 17.200 17.190 15.270 15.310
4 TP 22.831 31.246 33.600 35.439 32.073 33.947 35.050 34.472 31.228 33.701


How can I extract rows as specified, e.g.
I tried this to extract the first line ("FN") starting from V3 to V12:

> fn <- df[1,df$V3:df$V12]

But it gives columns starting not from V3.

What's the right way to do it?

- G.V.



More information about the R-help mailing list