'How to save table1 package output table to .doc format? R
Solution 1:[1]
Turns out it's very simple:
Just cmd+a the table in Rstudio viewer -> cmd+c -> paste Special in MS Word -> chose .html format!
Solution 2:[2]
I'm sorry to dig this up. However I learnt to love the two packages table1
and aswell flextable
and one other route would be to fastly convert the table1 object to a flextable
library(table1)
library(flextable)
library(magrittr)
# Create Table1 Object
tbl1<- table1(~Sepal.Length+Sepal.Width|Species,data=iris)
# Convert to flextable
t1flex(tbl1) %>%
save_as_docx(path="Iris_table1.docx")
Note that this give you the full flexibility over working with a flextable and an easy and save way to export to word. A nice guide on additional formatting with flextable can be found here
Solution 3:[3]
Another possible solution: The above strategy did not work for me when I had a similar issue, but it was resolved once I knitted the table1 object and opened the html in browser to copy the html table and successfully paste into word. Doing it within RStudio viewer would not work for me for some reason.
Solution 4:[4]
You can also save it as a .csv file for further manipulation (and from there to word)
mytable <- table1( ~ x | Y, data = df)
write.table (mytable , "my_table_1_file.csv", col.names = T, row.names=F, append= T, sep=',')
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | juststuck |
Solution 2 | Björn |
Solution 3 | drew.walkerr |
Solution 4 | Martin Gal |