Search code examples
rr-markdownpapaja

apa_table() returns a blank result while the table appears at the end of the pdf file


I'm trying to write a paper in papaja/Rmarkdown. I use the following code to create an APA table:

descriptives <- mydata%>% 
   filter(!is.na(scores))%>%
   group_by(class) %>%
  summarize(
    totalmean = mean(scores)
    , totalsd = sd(scores)
    , n.total = n())%>%
  mutate(se.scores = totalsd / sqrt(n.total),
         lower.ci.scores = totalmean  - qt(1 - (0.05 / 2), n.total - 1) * se.scores,
         upper.ci.scores = totalmean  + qt(1 - (0.05 / 2), n.total - 1) * se.scores)

descriptives <- descriptives %>% rename("Total Score"= totalmean, SD= totalsd, N= n.total,SE = se.scores, "CI lower"=lower.ci.scores, "CI upper" = upper.ci.scores)

descriptives[, -1] <- printnum(descriptives[, -1])


apa_table(descriptives)

The funny thing about the error is while the table does not appear in RStudio or in the correct section of my paper's pdf, it is listed at the end of the paper perfectly constructed according to my code.

Any suggestions?


Solution

  • The answer was simple, I had to change an option in the YAML metadata of my document.

    This: floatsintext : no

    to this:

    floatsintext : yes