[R] extremely simple "for loop" question

Brian Quinif bquinif at gmail.com
Thu Apr 13 01:38:23 CEST 2006


Thanks.  The c(...) is what i was missing.

BQ

2006/4/12, David Scott <d.scott at auckland.ac.nz>:
> On Wed, 12 Apr 2006, Brian Quinif wrote:
>
> > I am sorry to ask such a simple question, but my knowledge of
> > programming language is extremely limited, and I couldn't find the
> > answer in any of the normal resources.
> >
> > I want to do a for loop in which m takes on the values 1, 5, 10, 15,
> > 20.  What is the syntax for doing that?
> >
> > I had been doing a loop for m in 1:20, but I only want those values above.
> >
> > Thanks,
> >
> > Brian
> >
>
> An easy one that doesn't need an answer from Gabor
>
> for (m in c(1,5,10,15,20)){
>   print(m)
> }
>
> or
>
> for (m in c(1,5*(1:4))){
>   print(m)
> }
>
>
> David Scott
>
> _________________________________________________________________
> David Scott     Department of Statistics, Tamaki Campus
>                The University of Auckland, PB 92019
>                Auckland        NEW ZEALAND
> Phone: +64 9 373 7599 ext 86830         Fax: +64 9 373 7000
> Email:  d.scott at auckland.ac.nz
>
>
> Graduate Officer, Department of Statistics
>
> ASC/NZSA 2006: "Statistical Connections"
> The joint conference of the Statistical Society of Australia Inc.
> and the New Zealand Statistical Association, July 3--6, 2006
> in Auckland. Go to:
>
> http://www.statsnz2006.com/
>
>




More information about the R-help mailing list