May I say also ask one thing?  @OP: sorry to use your post.

What would you use instead of loops?  I am aware of the apply() functions,
but they are wrapper function of for loops, so they are slower.  At one
point, I was told to go back to C for faster implementation, but I like R
much more.

In the case of repeated simulation such as Monte Carlo, what would you use
instead of for loop?

Mike
On Sun, Apr 7, 2013 at 7:43 AM, John Kane <jrkrid...@inbox.com> wrote:

>
> http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
>
> Loops are seldom a good solution in R so some more information and data
> would be useful
>
> At the simplist, for your specific question  I think you could set up two
> vectors (e.g. v1  <-  rep(NA, 10 ) and just write the values into the
> vectors as you proceed through the loop.
>
> John Kane
> Kingston ON Canada
>
>
> > -----Original Message-----
> > From: bayywa...@gmail.com
> > Sent: Sun, 7 Apr 2013 14:36:33 +1200
> > To: r-help@r-project.org
> > Subject: [R] While loop history
> >
> > Hi,
> > I am new at R and still trying to get the hang of things.
> > I am running a while loop and wish to save the results of each iteration.
> > The results are a vector x of length two and I wish to save the results
> > of
> > each iteration as two vectors, one for x[1] and the other for x[2].
> >
> > Thanks!
> >
> >       [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-help@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.
>
> ____________________________________________________________
> GET FREE SMILEYS FOR YOUR IM & EMAIL - Learn more at
> http://www.inbox.com/smileys
> Works with AIM®, MSN® Messenger, Yahoo!® Messenger, ICQ®, Google Talk™ and
> most webmails
>
> ______________________________________________
> R-help@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.
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to