arsenal icon indicating copy to clipboard operation
arsenal copied to clipboard

The output of the knitr option "word_document" shows the name of the variable and not its assigned labels

Open cjaa-old opened this issue 3 years ago • 2 comments

When I run the chunk of code individually from Rmarkdown the output is a "knit_asis" type table that perfectly displays the table (including the labels for each variable). However, when I generate a word document using "knitr" the names shown in the table are those of the original variables (e.g. "age") and not the labels assigned to them (e.g. "Age in Years"). It seems that the problem is at the moment of generating the word document. I don't know if there is an option to show the labels and not the original variable name. Thank you.

Output in Rmarkdown image

Output in Word image

cjaa-old avatar Apr 16 '21 03:04 cjaa-old

I just realized that I would have to specify in the function "summary", argument "labbelTranslations", the name of the labels of each variable for it to appear in the word, even though by default each variable has a label assigned to it. That is to say, if I do not specify the value of the argument "labbelTranslations" in the output of the chunk of code, I still get the labels and not the original name of the variable. Is there any way to show the labels already assigned automatically?

Output in Rmarkdown

image

Output in Word document

image

cjaa-old avatar Apr 16 '21 04:04 cjaa-old

Without seeing your session, it's hard for me to tell what's going on. I'm wondering if your interactive objects aren't matching what gets produced by Rmarkdown when you knit in a new session. If that's the case, try restarting your R session, running every code chunk above this one, and then seeing what the output is in the knit_asis environment.

eheinzen avatar May 13 '21 17:05 eheinzen