6
> library(vcd)
Loading required package: MASS
Loading required package: grid
Loading required package: colorspace
> library(MASS)
> tbl = table(survey$W.Hnd,survey$Fold)
> print(tbl)

        L on R Neither R on L
  Left      10       1      7
  Right     88      17    113
> mosaic(tbl)
Error in if (split_vertical[i]) { : missing value where TRUE/FALSE needed
Calls: mosaic -> mosaic.default -> strucplot -> labeling
Execution halted

为什么会出现此错误,以及如何修复代码?


在这里轻松粘贴代码:

library(vcd)
library(MASS)
tbl = table(survey$W.Hnd,survey$Fold) # survey is a library data set in MASS
print(tbl)
mosaic(tbl) # produces the above error
4

2 回答 2

5

尝试这个:

> mosaic(survey$W.Hnd ~ survey$Fold)

马赛克

于 2013-01-27T12:24:00.990 回答
4

另一种选择是structablevcd包本身使用。

library(vcd)
library(MASS)
tbl <- structable(survey$W.Hnd ~ survey$Fold)
print(tbl)
mosaic(tbl)
于 2015-11-06T16:52:18.723 回答