Skip to content
Prev 155842 / 398502 Next

Creating data frame from existing data frame

well, first you could have a look at

?"[.data.frame"
?subset

and then check the following:

dat <- data.frame(year = sample(seq(2000, 2008, 2), 100, TRUE), y =
rnorm(100))

subset(dat, year == 2002)
dat[dat$year == 2002, ]

# or

subset(dat, year > 2002)
dat[dat$year > 2002, ]


I hope it helps.

Best,
Dimitris