[R] adjust scale of x-axis to unequal intervals

Jim Lemon jim at bitwrit.com.au
Wed Sep 25 03:22:59 CEST 2013


On 09/25/2013 01:56 AM, Sagan Friant wrote:
> Thank you!  This worked beautifully.  Can you help me adapt the code to
> do the same thing for a plot of means? The application is not a simple
> as I hoped...
>
> plotMeans(rich.small$ALL, rich.small$sample, error.bars="se")
>...

Hi Sagan,
Let's see, plotMeans is in the Rcmdr package. After installing it, I 
couldn't get it to plot, but upon exiting the Rcmdr window I worked out 
that the second argument (factor1) must obviously be a factor. After 
correcting this:

rich.small<-data.frame(ALL=rnorm(240,5),
  sample=factor(c(rep(0,60),rep(2,50),rep(4,40),
  rep(7,30),rep(10,30),rep(18,30))))

I get a plot, but I can see no way of adjusting the positions of the 
means displayed. I suggest:

plot(c(0,10,13,16,19,94),
  by(rich.small$ALL,rich.small$sample,FUN=mean),
  xaxt="n",ylim=c(4.7,5.4))
library(plotrix)
dispersion(c(0,10,13,16,19,94),
  by(rich.small$ALL,rich.small$sample,FUN=mean),
  by(rich.small$ALL,rich.small$sample,FUN=std.error))
staxlab(1,at=c(0,10,13,16,19,94),labels=c(0,2,4,7,10,18))

Jim



More information about the R-help mailing list