[R] Odp: Selecting data based on date-Data manupulation

Petr PIKAL petr.pikal at precheza.cz
Mon Sep 21 11:01:51 CEST 2009


Hi

see ?format

output of format can be transferred to numeric and you can use logical 
operators to select only desired data.

x[as.numeric(format(x, "%Y")) > 2008,]

another option is to compare it to some date like

x > as.Date("2008-1-1")
this assumes that x has class "Date". If not you can change it by as.Date 
function.

Regards
Petr

r-help-bounces at r-project.org napsal dne 21.09.2009 07:55:57:

> 
> I have 70 columns and more than 400k rows .In the data date column will 
have
> values from 1900(01/01/1900) .How do i select only the data of recent 
two
> years?Help me in this regard
> -- 
> View this message in context: 
http://www.nabble.com/Selecting-data-based-on-
> date-Data-manupulation-tp25530189p25530189.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> 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