'summarytools error while knitting in R Markdown
I am knitting a code below in R Markdown (I work on ESS9 data: 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)`
The code works while being run manually (also in a separate R document) but after knitting (both to pdf and HTML) I receive such errors:
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()
The solution proposed here doesn't work.
I will be grateful for your support!
Solution 1:[1]
A workaround is to loop over the objects inside the object created by tapply:
tlist <- tapply(iris$Sepal.Length, list(iris$Species), dfSummary)
for (obj in tlist)
print(obj)
(A fix will be included in version 1.0.1)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
