绘图乱序

时间:2013-03-10 23:03:45

标签: r graph plot

当我绘制它们时,我无法弄清楚为什么我的值不正常。防爆。 x轴0表示0.2的值,x轴0.2表示0.6的值,x轴0.6表示1.2的值,x轴1.2表示0的值。

R版本2.15.2(2012-10-26) - 在Mac OS X 10.6.8上运行“捣蛋”

方法spike elisa kit鱼谱conc conc2

1   Mekebri CNTRL   AbraxisRBT abraxis rbt 450 0.0900000        0.09
2   Mekebri CNTRL   AbraxisRBT abraxis rbt 450 0.0700000        0.09
3   Mekebri CNTRL   AbraxisRBT abraxis rbt 450 0.0700000        0.08
4   Mekebri CNTRL    EnviroRBT enviro  rbt 450 0.0900000        0.09
5   Mekebri CNTRL    EnviroRBT enviro  rbt 450 0.0700000        0.09
6   Mekebri CNTRL    EnviroRBT enviro  rbt 450 0.0700000        0.08
7   Mekebri   0.2   AbraxisRBT abraxis rbt 450 0.1100000        0.12
8   Mekebri   0.2   AbraxisRBT abraxis rbt 450 0.3000000        0.32
9   Mekebri   0.2   AbraxisRBT abraxis rbt 450 0.1000000        0.10    
10  Mekebri   0.2    EnviroRBT enviro  rbt 450 0.1100000        0.12
11  Mekebri   0.2    EnviroRBT enviro  rbt 450 0.3000000        0.32
12  Mekebri   0.2    EnviroRBT enviro  rbt 450 0.1000000        0.10    
13  Mekebri   0.6   AbraxisRBT abraxis rbt 450 0.1600000        0.16
14  Mekebri   0.6   AbraxisRBT abraxis rbt 450 0.1800000        0.18
15  Mekebri   0.6   AbraxisRBT abraxis rbt 450 0.1700000        0.17
16  Mekebri   0.6    EnviroRBT enviro  rbt 450 0.1600000        0.16
17  Mekebri   0.6    EnviroRBT enviro  rbt 450 0.1800000        0.18
18  Mekebri   0.6    EnviroRBT enviro  rbt 450 0.1700000        0.17
19  Mekebri   1.2   AbraxisRBT abraxis rbt 450 0.9680557 0.963486175
20  Mekebri   1.2   AbraxisRBT abraxis rbt 450 0.6040148 0.622156567
21  Mekebri   1.2   AbraxisRBT abraxis rbt 450 0.5665602   0.5849501
22  Mekebri   1.2    EnviroRBT enviro  rbt 450 0.9680557 0.963486175
23  Mekebri   1.2    EnviroRBT enviro  rbt 450 0.6040148 0.622156567
24  Mekebri   1.2    EnviroRBT enviro  rbt 450 0.5665602   0.5849501

plot(c(0,0.2,0.6,1.2),
with(mc, tapply(conc2, list(kit,spike), mean,na.rm=T))[1,],
type="b",lwd=2,
ylim=c(0,1),
xlab=expression(paste("Spike, ",mu,"g / L")),
ylab=expression(paste(mu,"g / L")),
col="blue")
points(c(0,0.2,0.6,1.2),
with(mc, tapply(conc2, list(kit,spike), mean,na.rm=T))[2,],
type="b",lwd=2,
ylim=c(0,1),
col="red")
legend(0.2,0.8,lty=1,lwd=2,
col=c("blue","red"),legend=c("Abraxis","EnviroLogix"))

dput(head(mc))
structure(list(method = structure(c(3L, 3L, 3L, 3L, 3L, 3L), .Label = c("Geis", 
"Mag", "Mekebri"), class = "factor"), spike = structure(c(4L, 
4L, 4L, 4L, 4L, 4L), .Label = c("0.2", "0.6", "1.2", "CNTRL"), class = "factor"), 
elisa = structure(c(2L, 2L, 2L, 2L, 2L, 1L), .Label = c("AbraxisBlank", 
"AbraxisRBT", "EnviroBlank", "EnviroRBT"), class = "factor"), 
kit = structure(c(1L, 1L, 1L, 1L, 1L, 1L), .Label = c("Abraxis", 
"Enviro"), class = "factor"), fish = structure(c(2L, 2L, 
2L, 2L, 2L, 1L), .Label = c("blank", "rbt"), class = "factor"), 
spectral = structure(c(1L, 1L, 1L, 1L, 1L, 1L), .Label = c("450", 
"600", "scan"), class = "factor"), conc = structure(c(1L, 
1L, 1L, 8L, 1L, 2L), .Label = c("> DL", ">DL", "0", "0.01", 
"0.02", "0.03", "0.04", "0.05", "0.06", "0.07", "0.08", "0.09", 
"0.1", "0.11", "0.12", "0.13", "0.14", "0.15", "0.16", "0.17", 
"0.18", "0.19", "0.2", "0.21", "0.22", "0.23", "0.24", "0.25", 
"0.26", "0.27", "0.28", "0.29", "0.294871066", "0.3", "0.308253804", 
"0.31", "0.32", "0.33", "0.34", "0.344304772", "0.35", "0.350277282", 
"0.353189188", "0.359024076", "0.36", "0.360435916", "0.37", 
"0.370993533", "0.37858631", "0.378888547", "0.38", "0.384568909", 
"0.39", "0.4", "0.401289641", "0.41", "0.42", "0.43", "0.44", 
"0.45", "0.46", "0.47", "0.473548535", "0.48", "0.489942496", 
"0.49", "0.5", "0.51", "0.52", "0.53", "0.54", "0.55", "0.56", 
"0.566560247", "0.57", "0.58", "0.5849501", "0.6", "0.604014755", 
"0.61", "0.62", "0.622156567", "0.64", "0.65", "0.66", "0.67", 
"0.69", "0.7", "0.71", "0.73", "0.75", "0.77", "0.78", "0.79", 
"0.8", "0.81", "0.82", "0.83", "0.84", "0.85", "0.87", "0.88", 
"0.9", "0.91", "0.92", "0.963486175", "0.968055663", "0.97", 
"0.98", "1", "1.01", "1.02", "1.03", "1.04", "1.1", "1.11", 
"1.2"), class = "factor"), conc2 = c(0, 0, 0, 0.05, 0, 0)), .Names = c("method", 
"spike", "elisa", "kit", "fish", "spectral", "conc", "conc2"), row.names = c(NA, 
6L), class = "data.frame")

1 个答案:

答案 0 :(得分:3)

您希望CNTRL变量的spike级别对应于零,但这不是因子级别所在的顺序。尝试

mc <- transform(mc,spike=factor(spike,levels=c("CNTRL","0.2","0.6","1.2")))