Re: [R] RES: another aov results interpretation question

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Tue 21 Jun 2005 - 01:43:13 EST

On 6/20/05, Paulo Brando <pmbrando@ipam.org.br> wrote:
>
> Dear All,
>
> I created a script to calculate averages - two groups: "parcel" and
> "date" - and, based on these averages, make a graph. The problem is that
> 'R' does not recognize the first column even if I try to insert one.
>
> A brief example
>
> Raw data:
>
> Data <- sample(1:100, 30, replace = FALSE, prob = NULL)
> Date <- rep(c("02/30/2004","03/15/2004", "04/16/2004", "06/14/2004",
> "07/08/2004"), 6)
> Parcel <- rep(c("DRY", "CONTROL"),15)
>
> Df <- data.frame(Parcel, Date, Data)
>
> Res <- tapply(Df$Data, list(Date = Df$Date, Parcel = Df$Parcel), mean)
>
>
> > Res
> Parcel
> Date CONTROL DRY
> 02/30/2004 53.00000 52.33333
> 03/15/2004 54.00000 67.66667
> 04/16/2004 54.66667 30.00000
> 06/14/2004 27.66667 20.00000
> 07/08/2004 59.00000 38.00000
>
> > colnames(Res)
> [1] "CONTROL" "DRY"
>
> > matplot(Res[,1], Res[,-1], type = "l")
>
> ### It does not recognize the colunm "Date". Why?

Date is a not a column in the matrix -- it is the name of the row dimension (and Parcel is the name of the column dimension). Res is a 5 by 2 matrix whose colnames are CONTROL and DRY. Try this:

   dimnames(Res)
   dim(Res) # 5 by 2

Also note that the first date (Feb 30th) is illegal and matplot does not work with dates in any case. Fix up the erroneous date and convert the row names to an object, xx, of chron or Date class, using plot for the axes and matlines for the lines:

   xx <- format(rownames(Res), "%m/%d/%Y") # Date class    plot(range(xx), range(Res), type = "n") # axes    matlines(xx, Res)

More on dates is in R News 4/1.



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Tue Jun 21 01:56:22 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:32:54 EST