I want to repeat a statistical function (like -lm-, -glm- or -glmgee-) for a lot of variables. But, it does not work for statistical functions (example 1) but works for simple functions (example 2).
Important: I do not mean multivariate regression and using cbind()!
Example 1:
a = rnorm(10, 5, 1)
b = rnorm(10, 7, 1)
c = rnorm(10, 9, 1)
d = rnorm(10, 10, 1)
i = list(a, b, c)
for (x in i) {
lm(x~d)
}
Example 2:
a = rnorm(10, 5, 1)
b = rnorm(10, 7, 1)
c = rnorm(10, 9, 1)
d = rnorm(10, 10, 1)
i = list(a, b, c)
for (x in i) {
plot(x+d)
}
You can check in this site: https://rdrr.io/snippets/