library(vcd) Loading required package: MASS Loading required package: grid Loading required packag-6ren">
gpt4 book ai didi

r - "missing value where TRUE/FALSE needed"错误 vcd::mosaic

转载 作者:行者123 更新时间:2023-12-05 01:11:29 24 4
gpt4 key购买 nike

> 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

最佳答案

尝试这个:

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

moasic

关于r - "missing value where TRUE/FALSE needed"错误 vcd::mosaic,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14547162/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com