[R] for loops?
Winfried Theis
theis at statistik.uni-dortmund.de
Mon Feb 2 17:36:15 CET 2004
Hello Cathy
you should open some curly brackets after the "for" statement e.g.
for(i in 1:1000){
print("Hello!")
print(sum(15+i*3))
}
or simlarly. But please keep in mind that R is rather slow with loops.
So have a look at apply & friends and check if you can rephrase your
problem to use them.
cheers,
Winni
On Mon, 2004-02-02 at 14:42, Catherine Stein wrote:
>
> Hello R people!
>
> How can one use a for loop (or something similar) in R? As I type in each
> line, I get syntax errors... I'm just confused how much to type in at each
> ">" prompt.
>
> Thanks for your help,
> cathy
>
>
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Catherine M. Stein
> Research Assistant, Tuberculosis Research Unit
> Doctoral Candidate in Genetic Epidemiology
> Department of Epidemiology and Biostatistics
> Case Western Reserve University
> office: (216)368-0875 or (216)778-1378
> e-mail: kasia at darwin.cwru.edu, or cmstein at cwru.edu
> http://darwin.cwru.edu/~kasia
>
> EPBI Student Resources Page:
> http://hal.epbi.cwru.edu/stures/
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
--
---------------------------------------------------------------------
Dipl.-Math. Winfried Theis
SFB 475, Fachbereich Statistik, Universit"at Dortmund, 44221 Dortmund
Tel.: +49-231-755-5903 FAX: +49-231-755-4387
More information about the R-help
mailing list