[R] symbolic iteration
Dimitris Rizopoulos
dimitris.rizopoulos at med.kuleuven.ac.be
Tue Jun 15 10:34:49 CEST 2004
Dear Jin,
you could try something like,
L1 <- runif(10)
L2 <- runif(20)
L3 <- runif(30)
L4 <- runif(40)
res <- vector(mode="list", length=4)
ss <- paste("log(L", 1:4, ")", sep="")
for(i in 1:4) res[[i]] <- eval(parse(text=ss[i]))
res
I hope this helps.
Best,
Dimitris
----
Dimitris Rizopoulos
Doctoral Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven
Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/16/396887
Fax: +32/16/337015
Web: http://www.med.kuleuven.ac.be/biostat/
http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm
----- Original Message -----
From: "Jin Shusong" <jinss at hkusua.hku.hk>
To: "R Help" <r-help at stat.math.ethz.ch>
Sent: Tuesday, June 15, 2004 10:06 AM
Subject: [R] symbolic iteration
> Dear all,
> I have 122 vectors named from L1 to L122. Now I hope to
> take log to each of the series, say
> L1 <- log(L1)
> ...
> L122<-log(L122)
>
> Can anyone show me a iterative way to make the job simple.
> I mean the way something like
> for(i in 1:122){
> ...
> }
> or other similar methods.
> Many thanks.
>
>
> Jin
>
> ______________________________________________
> 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
More information about the R-help
mailing list