Use tapply
and format
.
eg.
> tst<-data.frame(date=as.POSIXct(runif(1000)*31557600,origin="2010/8/9"),value=runif(1000))
> tapply(tst$value,format(tst$date,"%a"),summary)
$Fri
Min. 1st Qu. Median Mean 3rd Qu. Max.
0.001545 0.238900 0.499600 0.484700 0.697000 0.996400
$Mon
Min. 1st Qu. Median Mean 3rd Qu. Max.
0.02029 0.25100 0.49100 0.49910 0.75530 0.99120
$Sat
Min. 1st Qu. Median Mean 3rd Qu. Max.
0.003557 0.245600 0.493600 0.499200 0.754600 0.996200
$Sun
Min. 1st Qu. Median Mean 3rd Qu. Max.
0.01867 0.22340 0.52750 0.51260 0.80500 0.97760
$Thu
Min. 1st Qu. Median Mean 3rd Qu. Max.
0.003691 0.281200 0.600600 0.546800 0.790800 0.973000
$Tue
Min. 1st Qu. Median Mean 3rd Qu. Max.
0.009304 0.253400 0.488900 0.510300 0.772200 0.997100
$Wed
Min. 1st Qu. Median Mean 3rd Qu. Max.
0.002854 0.236200 0.400600 0.473500 0.742900 0.988600
You can replace the %a
in format
with other codes to suit, see ?strptime
. Month is %b
and weeknumber is %U
.