s-news
[Top] [All Lists]

Re: Graphic problem

To: Tristan Lorino <tristan.lorino@lcpc.fr>, s-news@lists.biostat.wustl.edu
Subject: Re: Graphic problem
From: "Richard M. Heiberger" <rmh@temple.edu>
Date: Thu, 9 Mar 2006 08:34:35 -0500
You need a few more lines

## your lines
x <- data.frame(c(0,0,1,2,3),
                c("a","a","a","b","a"),
                c(.3,.5,.6,.1,.2))
y <- tapply(x[,3], x[,c(2,1)], mean)

## additional lines
ty <- data.frame(t(y),
                 x=as.numeric(dimnames(y)[[2]])
                )
plot(a ~ x, data=ty)


There are two issues to keep in mind.
1. your original statement
   plot(y[1,])
plotted a vector, not a matrix, hence the implied x-axis is
generated as 1:length(y[1,])

2. plot works on columns, hence the transpose is needed after the tapply.


Rich

<Prev in Thread] Current Thread [Next in Thread>