'Export tab_model() output to a csv in R
I'm trying to export the results of a glmmTMB model. I am able to format my output using the tab_model(), but then I cannot export this HTML file while still maintaining the formatting.
For illustrative purposes, a similar dataset to the one I am using would be the ChickWeight dataset in base R.
#load packages
library(glmmTMB)
library(sjPlot)
library(sjmisc)
library(sjlabelled)
#model
model<-glmmTMB(weight ~ Time + Diet + (1|Chick), family=nbinom2, data=ChickWeight)
To view the output in exactly the way I want it in my paper:
tab_model(model, transform = NULL, auto.label = FALSE, collapse.ci=TRUE)
Which gives me a beautifully formatted table (see here).
I tried to export it as a csv using write.csv(as.data.frame(summary(model)), "~/Desktop/model output.csv"), but this solution is not possible for glmmTMB models.
How can I export the HTML file with the same formatting to a CSV (e.g., estimate with CIs in brackets all on the same line)?
Solution 1:[1]
You can simply add file = to your code like so: tab_model(model, transform = NULL, auto.label = FALSE, collapse.ci=TRUE, file = "results.xls")
Then you can import, manimpulate, save as .csv, and etc. But, note that Excel and R will think it is a 'webpage' even though it is saved with .xls. To fix this you will have to open with Excel and then save as .xls (or .csv or .xlsx)
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 |
