Open aporshnev opened 4 years ago
sjPlot is a great package and it works great, but today I observed strange behavoir - it does not make file in loops:
controls<-c("gender_text", "age_interval", "country_text", "sns", "education_text", "news_time", "news_language")
set.seed(111)
for (i in controls) { test_model <-paste0(baseline, "+", i) m_sbj <- glmer(test_model, data = work_table_REM, family=binomial) print(test_model)
tab_model(m_sbj, show.ci = FALSE, show.std = "std2", digits.p = 5, file = paste0(i,".doc")) }
I tried lapply lapply(controls, function(x) { tab_model(glmer(paste0(baseline, "+", x), data = work_table_REM, family=binomial), show.ci = FALSE, show.std = "std2", digits.p = 5, file = paste0("E:\RT\allstep1",x,".html")) print(x) })
No files generated in cycle and make a reproducable example:
data(cars) table(cars$dist) controls<-c("speed", "speed") cars$distBIN<- (cars$dist > 30) lapply(controls, function(x) { tab_model(glmer(paste0("distBIN~ (1|speed)+", x), data = cars, family=binomial), show.ci = FALSE, show.std = "std2", digits.p = 5, file = paste0("E:\RT\allstep1",x,".html")) print(x) })
if I just run x<-"speed" tab_model(glmer(paste0("distBIN~ (1|speed)+", x), data = cars, family=binomial), show.ci = FALSE, show.std = "std2", digits.p = 5, file = paste0("E:\RT\allstep1",x,".html")) Everything is fine and file appears
Try print() around your call to tab_model.
print()
sjPlot is a great package and it works great, but today I observed strange behavoir - it does not make file in loops:
controls<-c("gender_text", "age_interval", "country_text", "sns", "education_text", "news_time", "news_language")
set.seed(111)
for (i in controls) { test_model <-paste0(baseline, "+", i) m_sbj <- glmer(test_model, data = work_table_REM, family=binomial) print(test_model)
summary(m_sbj)
tab_model(m_sbj, show.ci = FALSE, show.std = "std2", digits.p = 5, file = paste0(i,".doc"))
}
I tried lapply lapply(controls, function(x) { tab_model(glmer(paste0(baseline, "+", x), data = work_table_REM, family=binomial), show.ci = FALSE, show.std = "std2", digits.p = 5, file = paste0("E:\RT\allstep1",x,".html"))
print(x) })
No files generated in cycle and make a reproducable example:
data(cars) table(cars$dist) controls<-c("speed", "speed") cars$distBIN<- (cars$dist > 30) lapply(controls, function(x) { tab_model(glmer(paste0("distBIN~ (1|speed)+", x), data = cars, family=binomial), show.ci = FALSE, show.std = "std2", digits.p = 5, file = paste0("E:\RT\allstep1",x,".html"))
print(x) })
if I just run x<-"speed" tab_model(glmer(paste0("distBIN~ (1|speed)+", x), data = cars, family=binomial), show.ci = FALSE, show.std = "std2", digits.p = 5, file = paste0("E:\RT\allstep1",x,".html")) Everything is fine and file appears