【发布时间】:2020-03-06 17:47:33
【问题描述】:
我想用条形图叠加条形图,并在xyplot中使用面板参数,但它不起作用。它不绘制任何内容并发出许多警告,例如:
1: In order(as.numeric(x)) : NAs introduced by coercion
2: In diff(as.numeric(x[ord])) : NAs introduced by coercion
代码在这里,但它适用于阶乘交替和主题变量,尽管它以水平方式绘制条形:
t2 <- data.frame(Alternative = c("FA", "HF", "NO", "HF", "FA", "NO"),
AlloOthe = c(50, 80, 20, 80, 80, 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"
)
那么有没有人可以向我展示正确的代码或让它在正确的数据上工作?非常感谢!
【问题讨论】: