[R] Subset POSIXlt Field
Phil Spector
spector at stat.berkeley.edu
Tue Oct 5 22:58:10 CEST 2010
Jared -
The value "2010-08-17" is a character value, and your dates
are stored as POSIXlt values. So you'd need to use
Date == as.POSIXlt("2010-08-17")
in your subset statement.
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
spector at stat.berkeley.edu
On Tue, 5 Oct 2010, Jared Stabach wrote:
> Hello All
>
> I, for the life of me, can't figure out to subset my dataframe by my Date
> field. The field has been formatted as POSIXlt.
>
> str(wild)
> ......
> $ Date : POSIXlt, format: "2010-05-28" "2010-05-28" "2010-05-28" ...
>
> This doesn't work:
> test <-subset(wild,ID=="2830" & Date=="2010-08-17")
>
> which returns:
> <0 rows> (or 0-length row.names)
>
>
> I don't think this should be a difficult thing to do. I just can't sort out
> the syntax of what it requires and can't find any threads on it.
>
> Any help is be appreciated.
>
> Jared
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
>
More information about the R-help
mailing list