Does anyone know how to covert an R table output to an editable word document? For reference I tried the following code for my table, but seem to be getting an XML error. Any help would be appreciated.

Does anyone know how to covert an R table output to an editable word document? For reference I tried the following code for my table, but seem to be getting an XML error. Any help would be appreciated.

Daniel D. Sjoberg
On
You tagged the gtsummary package, so I presume you're using it to create the table?
There are various ways to convert a gtsummary table to Word output. Review this vignette for more details. https://www.danieldsjoberg.com/gtsummary/articles/rmarkdown.html
library(gtsummary)
trial %>%
tbl_summary(by = trt) %>%
as_gt() %>%
gt::gtsave(filename = "my_table.docx")
Copyright © 2021 Jogjafile Inc.
The best way and simpler one I found is to:
1- save your data frame as .CSV file using R code but you shouldn't save the indexes also like this:

write.csv(table1, "table1.csv", row.names= F)2- Open the .CSV file using Microsoft word by right-click and open with then choose word app
3- Click
ctrl + athen click onTable>Convert>Conevrt text to tableyou'll find this dialoge box:click OK.
Some notes: after doing this you can save the word file as XML file and you can design it as you want
Scources: https://www.rforecology.com/post/exporting-tables-from-r-to-microsoft-word/