簡體   English   中英

此代碼給我一個錯誤: Error in if (is.na(s)) {: the condition has length > 1

[英]This code gives me an error: Error in if (is.na(s)) { : the condition has length > 1

請幫助解決我在執行以下命令時遇到的錯誤:

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"))

我有一個類似的問題。 對我來說,它有助於在 stargazer function 之外定義數據框。所以它會是

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"))

但是,我不確定它是否也有助於解決您的問題。

不是答案,而是提示:以下代碼

library(functional)
library(stargazer)

tabify <- function(models){

sgCurried = Curry(stargazer)

do.call(sgCurried, models)
}


mydf <- data.frame(Y = rnorm(15), Z = ceiling(rnorm(15)))

regr <- lm(Y ~ Z, data=mydf)

models = list(regr)

tabify(models)

...曾經與 R 4.1.2 一起工作,而它在 R 4.2.2 上失敗(兩種情況下 stargazer 都是 5.2.3),產生 OP 報告的錯誤。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM