提问人:Jessica Yu 提问时间:8/25/2023 更新时间:11/1/2023 访问量:46
(.format.s.statistics.list != “p25”) && (.format.s.statistics.list != : 'length = 7' 强制转换为 'logical(1)' 中的错误
Error in (.format.s.statistics.list != "p25") && (.format.s.statistics.list != : 'length = 7' in coercion to 'logical(1)'
问:
我正在根据一项调查结果进行回归分析,其中我将其中一些编码为
firstStepMutatedData <- mydata %>%
mutate(republican = ifelse((pid == 2), 1, 0),
conservative = ifelse((ideology >= 8), 1, 0),
votedTrump = ifelse((Q38 == 2),1,0),
white = ifelse((raceXethnic == "white & not hisp"),1,0),
asian = ifelse((raceXethnic == "asian & not hisp" | raceXethnic == "asian & hisp"),1,0),
otherRace = ifelse((raceXethnic != "white & not hisp" & raceXethnic != "asian & not hisp" & raceXethnic != "asian & hisp" ),1,0),
wantMove1year = ifelse((Q17 <= 2),1,0),
wantMove5year = ifelse((Q18 <= 2),1,0),
jobProsp = ifelse((Q8 == 1), 1, 0),
costProsp = ifelse((Q9 == 1), 1, 0),
qualityProsp = ifelse((Q10 == 1), 1, 0),
taxProsp = ifelse((Q11 == 2), 1, 0),
schoolGovtProsp = ifelse((Q12 == 1), 1, 0),
peopleProsp = ifelse((Q13 == 1), 1, 0),
politicalProsp = ifelse((Q14 == 1), 1, 0),
crimeProsp = ifelse((Q15 == 2), 1, 0),
childrenLifeProsp = ifelse((Q16 == 1), 1, 0),
buyHomeCA = ifelse((Q29 == 1),1,0),
buyHomeElsewhere = ifelse((Q29 ==2),1,0),
notBuyHome = ifelse((Q29==3),1,0))`
然后我运行了几个 lm 回归,举个例子:
demoVote1 <- lm(votedTrump ~ republican + conservative, firstStepMutatedData)
demoVote2 <- lm(votedTrump ~ republican + conservative + white, firstStepMutatedData)
stargazer(demoVote1, demoVote2, type = "text")
我看到了所有这些错误消息:
可能是什么问题?
答:
0赞
Pegasaurus
11/1/2023
#1
我刚刚遇到了这个错误。对我来说,我认为对你来说,问题是 R 中的重大更新,导致 stargazer 5.2.2 抛出错误。观星者维护者在 5.2.3 版本中修复了该问题。
如果你只是更新你的观星者包,那么你应该很高兴!install.packages('stargazer')
有关详细信息,请参阅 R 帮助服务器中的这篇文章。https://mailman.stat.ethz.ch/pipermail/r-help/2023-June/477522.html
评论