如何在组中而不是在变量上单独运行summarytools :: freq()?

问题描述 投票:1回答:1

我编写此代码可同时运行多个频率:

freq(staff[ ,c("hispanic","race","county","disabled",
              "ethnicity","frail","funding","funding1","funding2","gender",
              "language","marital","office","outcome","problem")])

它只运行了其中的4个,告诉我它忽略了变量:

Variable(s) ignored: county, funding, funding1, problem

因此,我一次没有问题地单独运行它们。关于为什么不能将它们包含在较大的组中的任何想法? "county"是字符,但是"funding""funding1""problem"都是因素。 AND,它将在组中运行"funding2"(也是一个因子)。

因此,我尝试独自运行这四个麻烦制造者:

freq(staff[ ,c("county", "funding", "funding1", "problem")])

并且得到了:

Error in x[[1]] : subscript out of bounds

一切都存储在"tbl_df"中会有所帮助。

r frequency
1个回答
0
投票

此问题现在应该已经解决,但是如果其他问题遇到类似的问题,请检查freq.ignore.threshold选项(使用st_options()设置),该选项确定不同值的数量,高于该数量的数字变量将被忽略。 (字符变量和因素不受此影响,因此这不是引起OP引起问题的原因)。

要包括所有变量,只需将这个选项设置为一个非常高的数字,如果这确实是您想要的:

library(summarytools)
st_options(freq.ignore.threshold = 999999)

在即将发布的版本(0.9.7)中,也将允许使用Inf。由于某些原因,尽管文档说明相反,checkmate::test_int似乎也不接受Inf,所以将需要一点技巧。

library(summarytools)
st_options(freq.ignore.threshold = Inf)
© www.soinside.com 2019 - 2024. All rights reserved.