[R] Using boxplot in a daily time series
Dylan Beaudette
dylan.beaudette at gmail.com
Sat Dec 15 23:02:02 CET 2007
On Saturday 15 December 2007 07:13:34 am pedrosmarques at portugalmail.pt wrote:
> Hi all,
>
> I'm trying to plot my daily time series, with 3650 observations( 10 years),
> with boxplot but I want 12 boxes, one for each month, can anyone help me
> doing that.
>
> Best regards
>
Sure,
there are several approaches to this, but in general thinking about your data
in terms of 'grouping' factors can be helpful
example:
# 1 year's worth of dates:
d <- strptime(1:365, format="%j")
# some simulated data
x <- rlnorm(365)
# combine them into a DF
dx <- data.frame(date=d, value=x)
# plot the data, note that x-axis is in dates:
plot(dx)
# now generate a grouping factor. how about months:
dx$month <- format(dx$date, format="%B")
# box and whisker plot for data *grouped* by month
boxplot(value ~ month, data=dx, las=3)
cheers,
Dylan
More information about the R-help
mailing list