[R] split and subset
partofy at inoutbox.com
partofy at inoutbox.com
Tue May 6 17:25:45 CEST 2008
Dear list:
I ask for your help in a simple problem in which I'm not figuring out
the solution
My data looks like:
dat<- data.frame(date=c("12/12/1980", "03/11/1994", "15/11/1999",
"31/10/2000", "20/03/2007", "05/01/2001"),
var1=c("A", "A", "B", "D", "C", "A"), var2=runif(6))
I was wondering if I could split the column "date" in 3 new columns in
he data frame corresponding to "day", "month" and "year".
If I decide not to split the date in 3 columns, I'd do:
dat$date<- as.Date(dat$date, "%d/%m/%Y")
Now, how can I subset parts of the dataframe, lets say for a given month
and year, something like
subset(dat, date=="1999-11-??")
The "??" is obviously wrong. How should I do this?
Many thanks
--
partofy at inoutbox.com
--
More information about the R-help
mailing list