[R] Data Frame Variable Names

From: Indrajit Chatterjee <indrajit.chatterjee_at_gmail.com>
Date: Tue, 15 Mar 2011 01:10:57 -0500


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$Independent1)

and so on

I wanted to put this in a for loop e.g.

for (i in 1:3) {

z<- glm( df$ColumnName_i ~ df$Independent1) print(z)

}

How do I specify the column name in the regression above for the dependent variable

        [[alternative HTML version deleted]]



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Tue 15 Mar 2011 - 07:38:31 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 15 Mar 2011 - 08:30:23 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive