Home > Back-end >  regression model into table
regression model into table

Time:02-10

I have a summary regression model I want to put into a table. However, it keeps coming up with an error. Not sure what I am doing wrong here. I have included a reproducible data and steps I have taken below.

library(sjPlot)
library(sjmisc)
library(sjlabelled)
library(webshot)


x<-rnorm(1:20)

y<-(1:20)/10 x

m1<-lm(y~x) 

summary(m1)

test<-tab_model(m1, file="test.html")

webshot("test.html","test.png")


Could not load  file:///C:/Users/AB/Documents/test.html
Error in webshot("test.html", "test.png") : 
  webshot.js returned failure value: 1

I'm not sure what the problem is. I have even changed my working directory - just to be sure. Is there any other better way than what I am currently doing? Any help will be appreciated.

CodePudding user response:

You shouldn't assign the output of tab_model() to a variable - that prevents it from writing the HTML file. If you just run tab_model() without assigning it to test you'll be fine.

The following works for me:

library(sjPlot)
library(sjmisc)
library(sjlabelled)
library(webshot)

x<-rnorm(1:20)

y<-(1:20)/10 x

m1<-lm(y~x) 

summary(m1)

tab_model(m1, file="test.html")

webshot("test.html","test.png")
  •  Tags:  
  • r
  • Related