0

次のコードは bwplot を生成しますが、y 軸の値は 10,11,12,13,14 ではなく 1,2,3,4,5 です。どうすればこれを修正できますか?

library(lattice)
test <- data.frame(c(rep(10,100),rep(11,100),rep(12,100),rep(13,100),rep(14,100))
               ,c(rep(rnorm(n=500,mean=2,sd=1:3))))
names(test) <- c("a","b")
bwplot(a ~ b, test)
4

2 に答える 2

2

bwplot (lattice) は ~ の左側にある因子を期待します。プロットする前に明示的に変換する

test$a = as.factor(test$a)

または(排他的または)使用

bwplot(as.factor(a) ~ b, test)
于 2013-11-27T13:09:44.807 に答える
0

列 a を文字要素に変換する必要があるように見えます

test$a=as.factor(as.character(test$a))
bwplot(a~b, data=test)
于 2013-11-27T13:10:41.897 に答える