[R] for loop

Steve Lianoglou mailinglist.honeypot at gmail.com
Wed Aug 5 20:52:29 CEST 2009


Hi,

On Aug 5, 2009, at 2:36 PM, waltzmiester wrote:

> Um I still followed the guidelines...

Focus on trying to ask a better question rather than going down this  
route ...

Honestly, your original question is rather vague and leaves us to  
guess (i) what you're trying to do, and (ii) how to help.

For example:


col<-c(23:28)

#Setup
for(k in col){
Initial.State(Response=zample[,c(k,29)],
Explanatory=zample[,variable_columns],
IndependentResponse=population[,c(k,29)],
IndependentExplanatory=population[,variable_columns])

#Modeling
Models(GLM=T, GAM=T, RF=T, GBM=T, TSS=T, KeepPredIndependent=T)
}

Your for loop is correct and should iterate 6 times, and k is getting  
vals 23 to 28:

You say that this code stops after the first model is complete, but if  
all goes well, it really shouldn't, eg:

===
col<-c(23:28)
for(k in col) {
cat(k, ' ')
}

Prints:
23  24  25  26  27  28  >
===

This means R should be giving you some type of error message and w/o  
telling us more, we're left to take stabs at the dark, which isn't a  
goof use of anybody's time.

--
Steve Lianoglou
Graduate Student: Computational Systems Biology
   |  Memorial Sloan-Kettering Cancer Center
   |  Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact




More information about the R-help mailing list