[R] Help with sub-setting data.frame

Stefan Grosse singularitaet at gmx.net
Wed Sep 2 09:04:20 CEST 2009


On Wed, 2 Sep 2009 17:12:18 +1200 Worik R <worikr at gmail.com> wrote:

WR> I have a data frame, df that I want to extract some rows from

What you need is subset, see
?subset

Example:
df<-data.frame(TTE=(0:10)/100,SOME=rnorm(11))
df
# subset with all columns
subset(df,TTE<0.02)
# the same as:
df[df$TTE<0.02,]

When you put the whole data.frame into the braces it does not make much
sense...

hth
Stefan




More information about the R-help mailing list