[R] plot separate groups with plotmeans()

Jon Zadra jrz9f at virginia.edu
Wed Nov 9 01:19:54 CET 2011


Hi,

I often use plotmeans() from the gplots package to quickly visualize a 
pattern of change.  I would like to be able to plot separate lines for 
different groups, but the function gives an error when a grouping 
variable is included in the formula argument.

For instance,
 > require(gplots)
 > x <- data.frame(Score=rnorm(100), Time=rep(1:10, 10), 
Group=factor(rep(c("A","B"),50)))
 > plotmeans(Score ~ Time, x) #works fine
 > plotmeans(Score ~ Time * Group, x)
Error in .subset2(x, i, exact = exact) :
   attempt to select more than one element
 > plotmeans(Score ~ Time | Group, x)
Error in ns - 1 : non-numeric argument to binary operator
In addition: Warning message:
In Ops.factor(Time, Group) : | not meaningful for factors

The help for plotmeans() states that it accepts a formula object 
including a grouping variable.  There is no other grouping argument 
listed.  Any help is appreciated, including pointing to a more robust 
function for plotting means.

Thanks,

Jon
-- 
Jon Zadra
Department of Psychology
University of Virginia
P.O. Box 400400
Charlottesville VA 22904
(434) 982-4744
email: zadra at virginia.edu
<http://www.google.com/calendar/embed?src=jzadra%40gmail.com>


More information about the R-help mailing list