我想将条形图与stripplot叠加,并在xyplot中使用面板参数表,但是它不起作用。它什么也没画,并发出许多警告,例如:
1: In order(as.numeric(x)) : NAs introduced by coercion
2: In diff(as.numeric(x[ord])) : NAs introduced by coercion
代码在这里,但是它可以使用阶乘Alternatice和Subject变量,尽管它以水平方式绘制条形图:
t2 <- data.frame(Alternative = c("FA","HF","NO","FA","NO"),AlloOthe = c(50,80,20,20),Subject = rep(c("2001","2002"),each = 3)
)
t2$Alternative <- as.character(t2$Alternative)
t2$Subject <- as.character(t2$Subject)
library(lattice)
xyplot(AlloOthe ~ Alternative | Subject,data = t2,panel = function(x,y) {
panel.barchart(x,y)
panel.stripplot(x,y,type = c("p","l"))
},ylab = "Allocation to Other"
)
那么,有谁能给我看正确的代码或使它适用于正确的数据?非常感谢!