0

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!

1 Answers1

0

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)

Dominic Comtois
  • 10,230
  • 1
  • 39
  • 61