Hello, Indrajit,
a "quick and dirty" solution could be to loop over the names of the
relevant variables of the data frame (in your case over the first three
variables) and use "[[ ]]" for indexing:
for (i in names( df)[ 1:3]) {
z <- glm( df[[ i]] ~ df$Independent1)
print( z)
}
An output
Hi,
I have created a dataframe (lets call is df) that contains the following
variables
"Dependent1" "Dependent2" Dependent3" "Independent1"
I want to do the following regressions:
z<- glm( df$Dependent1 ~ df$Independent1)
z<- glm( df$Dependent2 ~ df$Independent1)
z<- glm( df$Dependent3 ~ df$I
2 matches
Mail list logo