[R] graphs, need urgent help (deadline :( )

Jim Lemon drjimlemon at gmail.com
Thu Jun 11 11:06:33 CEST 2015


Rosa Oliveira wrote:

> Dear Jim,
>
> when I run your code (even the one you send me, not in my data), I get:
>
> Don't know how to automatically pick scale for object of type function. Defaulting to continuous
> Error in data.frame(x = c(0.1, 0.2, 0.1, 0.2, 0.1, 0.2, 0.1, 0.2, 0.1,  :
>  arguments imply differing number of rows: 24, 0

Well, let's agree on the data first. Using your original dataset:

my.data<-read.table(text="region sample factora factorb factorc
 0.1  10      0.895   0.903   0.378
 0.2  10      0.811   0.865   0.688
 0.1  20      0.735   0.966   0.611
 0.2  20      0.777   0.732   0.653
 0.1  30      0.600   0.778   0.694
 0.2  30      0.466   174.592 0.461
 0.1  40      0.446   0.432   0.693
 0.2  40      0.392   0.294   0.686",header=TRUE)
library(plotrix)
par(tcl=-0.1)
gap.plot(x=rep(seq(10,45,by=5),3),
 y=unlist(my.data[,c("factora","factorb","factorc")]),
 main="A plot of factorial mystery",
 gap=c(1.1,174),ylim=c(0,175),ylab="factor score",xlab="Group",
 xticlab=c(" \n0.1\n10"," \n0.2\n10"," \n0.1\n20"," \n0.2\n20",
  " \n0.1\n30"," \n0.2\n30"," \n0.1\n40"," \n0.2\n40"),
 ytics=c(0,0.5,1,174.59),pch=rep(1:3,each=8),col=rep(c(4,2,3),each=8))
mtext(c("Region","Sample"),side=1,at=6,line=c(0,1))
lines(seq(10,45,by=5),my.data$factora,col=4)
lines(seq(10,45,by=5),my.data$factorb[c(1:5,NA,7,8)],col=2)
lines(seq(10,45,by=5),my.data$factorc,col=3)
legend(18,1.8,c("factora","factorb","factorc"),pch=1:3,col=c(4,2,3))

This produces a plot, and I realize that it is not the one you
describe. As before, if you can let us know what is wrong with it,
maybe we can fix it.

Jim



More information about the R-help mailing list