`escalc` class objects may have trouble printing with Rmarkdown/Quarto Documents
Hello,
When I have this R code in a chunk, it seems to have trouble printing
bcg <- metadat::dat.bcg
metafor::escalc(
measure = "RR",
ai = tpos, # Got tubercolis and in treatment
bi = tneg, # Did not get tubercolis and in treatment
ci = cpos, # Got tubercolis and in control
di = cneg, # Did not get tubercolis and in control
data = bcg,
append = TRUE
) |>
dplyr::mutate(sei = sqrt(vi)) |>
head()
However, when I remove the escalc class, by converting into a data.frame, then everything is fine.
bcg <- metadat::dat.bcg
metafor::escalc(
measure = "RR",
ai = tpos, # Got tubercolis and in treatment
bi = tneg, # Did not get tubercolis and in treatment
ci = cpos, # Got tubercolis and in control
di = cneg, # Did not get tubercolis and in control
data = bcg,
append = TRUE
) |>
dplyr::mutate(sei = sqrt(vi)) |>
as.data.frame()
This works for me without any problems on the console or in an Rmarkdown document when rendering the document. This appears to be an issue with RStudio and their 'Chunk Output Inline' option. If you use 'Chunk Output in Console' it works just fine. I did some digging and I see where the issue is coming from. The development version circumvents the issue, so it should now print inline as well. However, note that you will get two inline outputs, the first arising from the extra space that is added before the data frame is printed. If this annoys you, you can use setmfopt(space=FALSE) to suppress that extra space.
Thanks for the quick fix! @wviechtb I'll try to take a look at it when I get a chance