I am using for loop to create linear mixed model. I have 2 problems:
- headers not showing in toc, though I have depth set to 4
sjPlot::tab_modelnot showing the summary
I have tried many different online solutions and nothing worked.
This is my code:
```{r}
#| error: TRUE
#| results: 'asis'
x<-c("body_mass_kg",
"bmi",
"obseg_nadlahti_relax",
"obseg_nadlahti_flex",
"obseg_goleni",
"obseg_stegna",
"kg_triceps",
"kg_biceps",
"kg_subscapular",
"kg_suprailiac",
"kg_front_thigh",
"kg_medial_calf",
"kg_abdominal")
for (element in x) {
cat('#### ',element, '\n\n')
dfSelect<-dfMixedModel %>%
dplyr::select(id, adiponectin_plasma_mg_ml, time_point, variable, value) %>%
dplyr::filter(variable==element) %>%
mutate(value=as.numeric(value),
time_point=time_point+2)
if (shapiro.test(dfSelect$value)$p.value>=0.05) {
print("Navaden linear-mixed model")
model <- lmer(value ~ adiponectin_plasma_mg_ml + time_point + (1|id), data = dfSelect)
} else {
print("Robusten linear-mixed model")
model <- rlmer(value ~ adiponectin_plasma_mg_ml + time_point + (1|id), data = dfSelect)
}
tab_model(model)
# cat("\n:::\n")
}
```