[R] request

Jason Turner jasont at indigoindustrial.co.nz
Mon Mar 31 23:28:09 CEST 2003

On Mon, Mar 31, 2003 at 01:40:23PM +0200, Ghosh Mini wrote:
> Dear all,
> Hope you are fine there. I want to know
> " Is it possible to treat Day,month and year seperately in a data frame in
> R"

It's easy, if your date column is a POSIX*t date/time class.
help(DateTimeClasses) should shed some light.

> Means, suppose I want to take mean of data first by day wise and then by
> month. Is it possible using R??

Use by() or tapply() with format(your.POSIX*t.object) for indicies,
and it's pretty easy.

Something like this, as a toy example...

myData <- data.frame(numbers=1:20)
myData$date <- as.POSIXct(paste(sep="-","2003",1:4,1:20))

#by day

#by month


Indigo Industrial Controls Ltd.
jasont at indigoindustrial.co.nz

More information about the R-help mailing list