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@psu.edu

 


	[[alternative HTML version deleted]]


