Skip to content
Prev 132155 / 398503 Next

Using boxplot in a daily time series

On Saturday 15 December 2007 07:13:34 am pedrosmarques at portugalmail.pt wrote:
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