I want to superimpose barchart with stripplot, and use panel paremeter in the xyplot, but it doesn't work. It plots nothing and give out many warnings, such as:
1: In order(as.numeric(x)) : NAs introduced by coercion
2: In diff(as.numeric(x[ord])) : NAs introduced by coercion
The code is here, however it works with the factorial Alternatice and Subject variables, although it plot the bar in a horizontal way:
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"
)
So does anyone could show me the correct code or to make it work on the right data? Thanks a lot!