Try this:
subset(dat, format(date, "%Y-%m") == "1999-11")
On Tue, May 6, 2008 at 12:25 PM, <partofy@inoutbox.com> wrote:
> 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@inoutbox.com
>
> --
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O
[[alternative HTML version deleted]]