1

I was using functions form package broom. But the results span over multiple pages. For example, using mtcars data, I fitted a linear model with

model1 <- lm(mpg~. , data=mtcars) # mpg regressed on all other variables of dataset.

I want to see the regression results (like R-squared, AIC, etc.) using thebroom::glance function, but the table showing the regression results is wider than the page width. Is there any way such that the remaining columns can be shown in the next rows? I tried knitr::kable also along with it, but that doesn't work either.

B--rian
  • 5,578
  • 10
  • 38
  • 89
Eva
  • 663
  • 5
  • 13

2 Answers2

0

You can use the following code to save the output in .csv file

library(broom)

model1 <- lm(mpg~., data=mtcars)
tmp <- glance(model1)
#To have the result in the console
write.csv(tmp)
#To write the results in .csv file
write.csv(tmp, "lm_results.csv")
UseR10085
  • 7,120
  • 3
  • 24
  • 54
  • That's a fair idea, but I want to keep the results in an R markdown document to keep it reproducible. Writing csv file doesn't serve my purpose. – Eva Jan 29 '20 at 12:46
0

If you want to see it in the console, you can do:

options(width=140)
glance(mdl)

or

data.frame(glance(mdl))
StupidWolf
  • 45,075
  • 17
  • 40
  • 72