0

I have this simple code that tries to print many tab_model objects in a single html file. For some reason, each model gets its own html file and the main file remains empty..

Any thoughts?

{r printing, echo=FALSE, cache=FALSE, results='asis'}

library(sjPlot)

for (i in 1:3) {
  flights <- nycflights13::flights
  flights <- dplyr::sample_n (flights, 500)
  m1 <- glm(formula = arr_delay ~ dep_time + origin+ air_time+ distance , data = 
  flights)
  print(tab_model(m1))
}
rawr
  • 20,481
  • 4
  • 44
  • 78
Stat.Enthus
  • 335
  • 1
  • 12
  • 1
    not sure if it is the "correct" way, but you can use `cat(tab_model(m1)$knitr, sep = '\n')` instead of `print`. that package sjPlot is annoying, so I'd rather not dive into the code. also is there any reason why you are including a list of packages not used in your question? – rawr Dec 13 '20 at 21:00
  • yes, this is part of a different code i am using all these packages with different data. I just wanted to make sure it's not about interference or libraries. sjPlot is indeed a bit annoying :-) – Stat.Enthus Dec 14 '20 at 10:05
  • Do you know how to omit the R from the table? – Stat.Enthus Dec 14 '20 at 10:15
  • do you mean the r squared? `tab_model(m1, show.r2 = FALSE)` – rawr Dec 14 '20 at 10:23
  • Thanks! Any more ways to make this more printable / copyable to word? – Stat.Enthus Dec 14 '20 at 10:47
  • no, I don't use word, I typically keep everything in html, you can open an html file of the table in excel to make any final edits and then copy over to word which is not really ideal if you have a large number of tables. or you can see here a similar question https://stackoverflow.com/questions/60997710/regression-models-in-r-output-table-to-word – rawr Dec 15 '20 at 19:56

0 Answers0