Working with lists of different levels

Navaak

Member
Hi everybody,

Let us suppose that I have the following two lists:
Code:
x1 <- list(a1=list(n=1,
z='a'),
a2=list(n=2,
z='b'),
a3=list(n=3,
z='c')
)

x2 <- list(a1=list(b1=list(n=1,
z='a'),
b2=list(n=2,
z='b'),
b3=list(n=3,
z='c')),
a2=list(b1=list(n=4,
z='d'),
b2=list(n=5,
z='e'),
b3=list(n=6,
z='f'))
)
Then, I would like (say) to run a function that returns paste(n, z), which would have to run on the lowest level of each list (the part containing the elements named n and z). How could I structure the code (or the function) to run on both lists?

Thank you in advanced for any ideas!