0

Thanks in advance. Basically, I've produced a table and now I just want to print that onto a word document. For some reason however, when I do so it removes all the variables from the table. Could someone pls help me out?

the first line of code is what produced the Rmarkdown table, the second is the one that printed it onto a word document.

Table_1c <- knitr::kable(Table_1b, digits = 3, caption = "Table 1. Descriptive Statistics")

tab_df(Table_1b, title = "Table 1. Descriptive Statistics", file = "Table_1c.doc")
  • I think you'll have to make this a reproducible question because I don't have any problems with this function in and of itself. It looks like you're new to SO; welcome to the community! If you want great answers quickly, it's best to make all of your questions reproducible. This includes sample data like the output from `dput(head(dataObject)))` and any libraries you are using. Check it out: [making R reproducible questions](https://stackoverflow.com/q/5963269). – Kat Mar 10 '22 at 15:03

1 Answers1

1

The file option in the tab_df function allows to save the table as image in a HTML file. I will show you an example.

First the data sample as example:

# DATA
Table_1b <- iris[1:5,]
Table_1b

Output:

  Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1          5.1         3.5          1.4         0.2  setosa
2          4.9         3.0          1.4         0.2  setosa
3          4.7         3.2          1.3         0.2  setosa
4          4.6         3.1          1.5         0.2  setosa
5          5.0         3.6          1.4         0.2  setosa

Next load package and set working directory to store the table as html file:

library(sjPlot)
# Set working directory
setwd("~/Downloads")
tab_df(Table_1b, title = "Table 1. Descriptive Statistics", file = "Table_1c.html")

With this as output: enter image description here

Quinten
  • 35,235
  • 5
  • 20
  • 53