search for: tableofresult

Displaying 1 result from an estimated 1 matches for "tableofresult".

Did you mean: tableofresults
2009 Nov 11
1
loop through variable names
Often I perform the same task on a series of variables in a dataframe, by looping through a character vector that holds the names and using paste(), eval(), and parse() inside the loop. For instance: thesevars<-names(environmental) environmental$ToyOutcome<-rnorm(nrow(environmental)) tableOfResults<-data.frame(var=thesevars) tableOfResults$Beta<- NA rownames(tableOfResults)<-thesevars for( thisvar in thesevars) { thiscommand<- paste("thislm <- lm( ToyOutcome ~ ", thisvar, ", data=environmental)") eval(parse(text=thiscommand)) tableOfResults[thisvar,...