Message-ID: <200712151402.02416.dylan.beaudette@gmail.com>
Date: 2007-12-15T22:02:02Z
From: Dylan Beaudette
Subject: Using boxplot in a daily time series
In-Reply-To: <1197731614.4763ef1e5b2f3@gold3.portugalmail.pt>
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