[R] for loop

Daniel Malter daniel at umd.edu
Wed Aug 5 19:49:25 CEST 2009


No, Jim is right. My answer is a shot in the blue, an attempt to guess from
your writing what you (might) want to do. It is actually completely unclear
from your question what you mean by "pass the next value of c into
Initial.State" What is "c" anyway? There is no "c" in your code.

That your function is self-contained does not help at all in that regard
because the entire code is not. The posting guide requires to post minimally
self-contained code and, therefore, either real or simulated data as well as
information on the packages necessary so that the error you encounter is
reproducible (by the way, often creating this code leads to the solution of
the error by yourself).

In addition, your statement 'the code stops after 1 model is complete' does
not unambiguously tell us whether the first loop runs through correctly or
whether there is an error and, if so, where this error resides. That's what
I mean when I say it is a shot in the blue because I assumed that your loop
indeed fails in iterating the loop appropriately rather than executing your
Models function. However, we cannot know.

Therefore, please read (and follow) the posting guide. And no worries, I
have asked questions like yours before. It just takes some willingness and
effort to learn to ask better questions in order to get helpful answers.

Daniel

-------------------------
cuncta stricte discussurus
-------------------------

-----Ursprüngliche Nachricht-----
Von: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] Im
Auftrag von waltzmiester
Gesendet: Wednesday, August 05, 2009 1:22 PM
An: r-help at r-project.org
Betreff: Re: [R] for loop


Jim

Settle down, just because you can't understand my post doesn't mean I didn't
follow the guidlines.
1)The code is commented. 
2)The problem in the code is succinct and therefore "minimal" even though it
cannot be self contained, the user-defined function itself is.
3) In order for you to be able to reproduce my code, you would need to to
install 13 packages and blend in 187 lines of patch code that I would need
to send you.

I meant that it will model (with function Models) the first species in i,
and will not model any of the others.

-C



jholtman wrote:
> 
> What do you mean by "stop"?  Is there an error message?  What are you 
> getting as output?  I don't see you saving or printing the output from 
> "Models" (whatever that is). PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> On Wed, Aug 5, 2009 at 11:37 AM, waltzmiester<cwalte03 at shepherd.edu>
> wrote:
>>
>> I am trying to get the function "Models" to work each time there is 
>> an instance of k. This code will stop after the first model is 
>> complete. I need it to come back and pass the next value of c into 
>> the "Initial.State"
>> function. any ideas?
>>
>>
>> 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) }
>>
>>
>> -Chris
>> --
>> View this message in context:
>> http://www.nabble.com/for-loop-tp24830984p24830984.html
>> Sent from the R help mailing list archive at Nabble.com.
>>
>> ______________________________________________
>> 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.
>>
> 
> 
> 
> -- 
> Jim Holtman
> Cincinnati, OH
> +1 513 646 9390
> 
> What is the problem that you are trying to solve?
> 
> ______________________________________________
> 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.
> 
> 

-- 
View this message in context:
http://www.nabble.com/for-loop-tp24830984p24832491.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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.




More information about the R-help mailing list