我使用调查包定义了一个调查对象(一切正常),并按如下方式添加了两列:
anes_svy <- update( #the update fn adds columns to a survey object
anes_svy, #object to add variables to
one = 1,
undoc_kids =
factor( V161195x , levels = 1:6 , labels =
c( 'should sent back - favor a great deal' ,
'should sent back - favor a moderate amount' ,
'should sent back - favor a little' ,
'should allow to stay - favor a little' ,
'should allow to stay - favor a moderate amount' ,
'should allow to stay - favor a great deal' )
)
)
现在我跑
svyby( formula = ~one , by = ~undoc_kids , design = anes_svy , FUN = unwtd.count )
我收到错误
Error in sum(sapply(covmats, ncol)) : invalid 'type' (list) of argument
文档要求'公式'的向量,'by'的因子列表,'design'的svydesign对象,以及FUN的函数(unwtd.count是内置的)。我做错了什么?