Skip to content
Prev 293295 / 398502 Next

list objects calculation

Hi

you maybe can use mapply

If you have 2 lists

xl<-list(x, x+5)
 xl
[[1]]
[1] 1 2 3 4 5

[[2]]
[1]  6  7  8  9 10
[[1]]
[1] 9

[[2]]
[1] 10

and this function


fff<- function(xl,yl) (xl-yl)/yl

mapply(fff, xl, yl)
           [,1] [,2]
[1,] -0.8888889 -0.4
[2,] -0.7777778 -0.3
[3,] -0.6666667 -0.2
[4,] -0.5555556 -0.1
[5,] -0.4444444  0.0

gives you probably desired result.

Regards
Petr
http://r.789695.n4.nabble.com/list-objects-
http://www.R-project.org/posting-guide.html