Here my data frame (reproducible example)
set.seed(42)
n <- 6
dat <- data.frame(id=rep(1:n, 2),
group= as.factor(rep(LETTERS[1:2], n/2)),
VD1 = rnorm(n),
VD2 = runif(n*2, min=0, max=100),
VD3 = runif(n*2, min=0, max=100),
VD4 = runif(n*2, min=0, max=100),
VD5 = runif(n*2, min=0, max=100))
I am fitting the following mlm for one dependent variable "VD1"
> mlm_VD1 <- lmer(formula = VD1 ~ group + (1|id)
> , data = dat)
summary(mlm_VD1)
I would like to automatize the analyses of all the other dependent variables VD2, VD3, VD4, VD5 by creating a loop through all the columns of my dataframe (dat[, 4:ncol(dat)])
I would like then to save all the summaries of the different mlm (mlm_VD1, mlm_VD2, mlm_VD3, mlm_VD4, mlm_VD5) in a pdf file to read outside the R environment
Thanks!