我在 R Markdown 中编写下面的代码(我处理 ESS9 数据:https ://www.europeansocialsurvey.org/data/download.html?r=9 )
ess$social_trust<-rowSums(select(ess, ppltrst, pplfair, pplhlp), na.rm=TRUE)
tapply(ess$social_trust, ess$gndr, dfSummary)
tapply(ess$social_trust, ess$gndr, freq)`
该代码在手动运行时有效(也在单独的 R 文档中),但在编织后(pdf 和 HTML)我收到这样的错误:
tapply(ess$social_trust, ess$gndr, dfSummary)
## X[[i]] was converted to a data frame
## X[[i]] was converted to a data frame
## x must either be a summarytools object created with freq(), descr(), or a list of summarytools objects created using by()
tapply(ess$social_trust, ess$gndr, freq)
## x must either be a summarytools object created with freq(), descr(), or a list of summarytools objects created using by()
这里提出的解决方案不起作用。
我将感谢您的支持!