[R] Repeat if

john seers (IFR) john.seers at bbsrc.ac.uk
Thu Jun 28 12:23:17 CEST 2007


 
Hi

I think a for loop would be more what you want.

Something along the lines of:


V<-list(a=c(1,2,3), b=c(2,3,4)) # list of 2 vectors

for ( i in 1:2 ) {          # 2 vectors (replace with 85 ...)
    print(range (V[i], na.rm = TRUE))
}


Regards

JS
 
---

-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Birgit Lemcke
Sent: 28 June 2007 10:48
To: R Hilfe
Subject: [R] Repeat if

Hello,
(Power Book G4, Mac OS X, R 2.5.0)

I would like to repeat the function range for 85 Vectors (V1-V85).
I tried with this code:

i<-0
 > repeat {
+ i<-i+1
+ if (i<85) next
+ range (Vi, na.rm = TRUE)
+ if (i==85) break
+ }



More information about the R-help mailing list