An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20090531/56d5efc3/attachment-0001.pl>
using chron vector with boxplot
2 messages · Kenneth Takagi, Gabor Grothendieck
Try this: boxplot(as.matrix(data) ~ as.Date(date), cex.axis = 0.5, las = 2) or if all the dates are in the same year and month as they are here then you might want to just display the day of the month: boxplot(as.matrix(data) ~ month.day.year(date)$day)
On Sun, May 31, 2009 at 1:45 PM, Kenneth Takagi <kat215 at psu.edu> wrote:
Hi,
I'm having trouble using dates (created using library(chron)) as
groupings for a boxplot. ?I have 10 repeat measurements of a variable
within an individual day. ?The measurements were done over 10 days. ?I
would like to plot the measurements as a box and wisker plot (using
boxplot or something similar) where the days (as chron object) would be
the grouping and the repeated measurements of the variable make up the
box and wisker plot. ?I would like the spacing of the individual
boxplots to reflect the time between measurements:
Example using random numbers:
### Create date vector of measurement dates
library(chron)
time=c(39083, 39085, 39095, 39096, 39103, 39104, 39105, 39110, 39113,
39120);
orig =chron("01/01/1900")
date = orig + time-2;
### ?Data for B and W plot
data = data.frame();
mean=rnorm(10, mean=0, sd=1);
for(i in 1:10){data[1:10,i] =rnorm(10, mean=mean[i], sd=1)};
### Plot
boxplot(data, range=0); ?# works, but doesn't reflect the different time
intervals between measurements dates!
boxplot(data~date, range=0) # tried using formula, gives error:
? ? ? ? ? ?Error in model.frame.default(formula = data ~ date) :
? ? ? ? ? ? invalid type (list) for variable 'data'
Not sure what to try next. ?Any suggestions?
Thanks,
ken
kat215 at psu.edu
? ? ? ?[[alternative HTML version deleted]]
______________________________________________ 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.