[R] Creating data frame from existing data frame
d.rizopoulos at erasmusmc.nl
Fri Sep 12 09:43:28 CEST 2008
well, first you could have a look at
and then check the following:
dat <- data.frame(year = sample(seq(2000, 2008, 2), 100, TRUE), y =
subset(dat, year == 2002)
dat[dat$year == 2002, ]
subset(dat, year > 2002)
dat[dat$year > 2002, ]
I hope it helps.
> I'm new to R, using it for an engineering stats class, and the first
> is focused on creating data frames and plotting graphs. So far I have
> imported a set of data from a text file and saved it as a variable (using
> the read.table() function). One of the columns of the data consists of
> years, and I'm supposed to create a data frame that only consists the the
> date from one given year (ie. I need to scan the Year column, pick out the
> specific year, and include those rows). I'm pretty sure I have to use
> data.frame() to do this, but I don't know what arguments would pick out
> from a particular year (and keep the headers of the columns intact in the
> new data frame). Beyond this, I need to plot it and export it to an image
> file, which I can do myself.
> Can someone please tell me the arguments to data.frame() that would
> this (or better yet, point me to a good list of functions and arguments in
> addition to this).
> Thanks for your help,
> View this message in context:
> Sent from the R help mailing list archive at Nabble.com.
> R-help at r-project.org mailing list
> PLEASE do read the posting guide
> and provide commented, minimal, self-contained, reproducible code.
Department of Biostatistics
Erasmus University Medical Center
Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
More information about the R-help