[R] Repeat if
Jim Lemon
jim at bitwrit.com.au
Thu Jun 28 13:01:03 CEST 2007
Birgit Lemcke wrote:
> 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
> + }
>
> I presume that the Vi is wrong, because in this syntax i is not known
> as a variable. But I don´t know how to say that it is a variable here.
> Would be nice if somebody could help me.
> Perhaps I´m thinking too complicated and there is an easier way to do
> this.
>
Hi Birgit,
This may be what you want:
for(i in 1:85)
print(do.call("range",list(as.name(paste("V",i,sep="")))))
Jim
More information about the R-help
mailing list