这段代码给了我一个错误: Error in if (is.na(s)) { : the condition has length > 1

Var*_*air 3 if-statement r stargazer

请帮助解决我执行以下命令时遇到的错误:

stargazer(as.data.frame(st_sect.hh.earnings[st_sect.hh.earnings$sector.f=="Rural",c(1,3,4)]), 
      type="html", 
      title="Mean and Standard Deviation of Monthly Household Income by State for Rural India (Unweighted)", 
      summary=F, covariate.labels=c("S.No.", "State", "Mean", "Std.Dev."), 
      digits=0,
      notes=c("Source: Periodic Labour Force Survey, 2017-18"), 
      out=c("tb2.state-rural.hh.earnings.html"))
Run Code Online (Sandbox Code Playgroud)

Poz*_*oza 7

我有类似的问题。对我来说,它有助于定义观星器功能之外的数据框。所以它会是

df <- as.data.frame(st_sect.hh.earnings[st_sect.hh.earnings$sector.f=="Rural",c(1,3,4)])
stargazer(df, 
      type="html", 
      title="Mean and Standard Deviation of Monthly Household Income by State for Rural India (Unweighted)", 
      summary=F, covariate.labels=c("S.No.", "State", "Mean", "Std.Dev."), 
      digits=0,
      notes=c("Source: Periodic Labour Force Survey, 2017-18"), 
      out=c("tb2.state-rural.hh.earnings.html"))
Run Code Online (Sandbox Code Playgroud)

编辑(在评论中讨论之后):这样做的原因是参数输入长度不应该太长。检查下面的评论。