[R] Working with temporal data [Solved]

Sérgio Nunes snunes at gmail.com
Fri Feb 16 16:39:54 CET 2007


Just for the record, here are my steps for producing a date based histogram.
Data is stored in a file where each line only has a date - 2007/02/16

>d<-readLines("filename.dat")
>d<-as.Date(d, format="%Y/%m/%d")
>pdf(yearly.pdf)
>hist(d, "years")
>dev.off()

Instead of "years" you can also use "days", "weeks", "months", "secs",
"mins", "hours".

One final question, how could I easily filter my dataset if, for
instance, I only wanted to see results from 2006 ?

Thanks to all who helped,
Sérgio Nunes

On 2/15/07, Sérgio Nunes <snunes at gmail.com> wrote:
> Hi,
>
> I have several files with data in this format:
>
> 20070102
> 20070102
> 20070106
> 20070201
> ...
>
> The data is sorted and each line represents a date (YYYYMMDD). I would
> like to analyze this data using R. For instance, I would like to have
> a histogram by year, month or day.
>
> I've already made a simple Perl script that aggregates this data but I
> believe that R can be much more powerful and easy on this kind of
> work.
>
> Any suggestions on where to start?
>
> Thanks in advance,
> Sérgio Nunes
>



More information about the R-help mailing list