“缺少需要 TRUE/FALSE 的值”错误 vcd::mosaic

yas*_*sar 5 r

> 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
Run Code Online (Sandbox Code Playgroud)

为什么我会收到此错误,以及如何修复代码?


简单粘贴代码在这里:

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
Run Code Online (Sandbox Code Playgroud)

Aru*_*run 5

尝试这个:

> mosaic(survey$W.Hnd ~ survey$Fold)
Run Code Online (Sandbox Code Playgroud)

马赛克