Re: [R] Using boxplot in a daily time series

From: Dylan Beaudette <dylan.beaudette_at_gmail.com>
Date: Sat, 15 Dec 2007 14:02:02 -0800

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



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Sat 15 Dec 2007 - 22:07:43 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 16 Dec 2007 - 00:30:19 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.