Summarytools Error While Knitting in R Markdown

I am knitting a code below in R Markdown (I work on ESS9 data: )

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!

1 Answer

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)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Alexander Ross

Alexander Ross

Gaming, Esports & Interactive Media Writer

Alexander Ross has covered the video game industry for a decade, writing deep dives on game design, esports tournaments, VR developments, and gaming culture.

Share this article
Twitter Facebook Pinterest