I am not sure if I am overseeing something, maybe there is an easy solution for this already (sorry if this is the case) but so far I haven't found one:
When I am passing a manually created data.frame
to apa_table()
with row names / column names / values containing RMarkdown syntax, for example "$p$"
or "$p > .001$"
, and try to knit it into a docx file, it will not work and just print it as it is. If I use label_variable(df, p="$p$)
it does work ofc as expected, but this is my solution only for column names, not for the other locations within a table. The same also accounts for the note = "$p$"
beneath an apa_table()
.
I am curious if it is possible or if a solution already exists, I'd be thankful for some help on this one! Best regards and thank you in advance Mischa
By default, apa_table()
escapes characters that are special in LaTeX (e.g., $
). You can turn this feature off by specifying escape = FALSE
. Moreover, if you want to enable full markdown support for your table body, I recommend to specify format = "pipe"
, which tells apa_table()
to return the table in pandoc's pipe format, which in turn supports markdown.
Consider this table with some markdown commands:
table_content <- data.frame(
"$\\mathit{df}$" = "$\\mathit{df} = 1$"
, b = c("**a**", "*b*")
, check.names = FALSE
)
A full call to apa_table()
might then look like the following:
apa_table(
table_content
, escape = FALSE
, format = "pipe"
)
A current limitation to this approach seems to be table notes: pandoc's pipe tables do not seem to support table notes, so using markdown syntax for the table's body while also adding a table note does not seem to work at the same time.