Skip to content
Prev 276776 / 398506 Next

plot separate groups with plotmeans()

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