Given the data structure you provided, I would use sapply :
sapply(people, function(x) x[2]) > sapply(people, function(x) x[2]) age age age age age "23" "35" "20" "31" "26"
However, you will notice that the results of this are character data.
> class(people[[1]]) [1] "character"
One approach would be to force as.numeric() or as.integer() in a sapply call.
Alternatively, if you have the flexibility regarding how you store data in the first place, it might make sense to save it as a list of data.frame s:
people = vector("list", 5) people[[1]] = data.frame(name="Paul", age=23) people[[2]] = data.frame(name="Peter", age=35) ...
If you are going to go this far, you can also consider one data file for all of your data:
people2 <- data.frame(name = c("Paul", "Peter", "Sam", "Lyle", "Fred") , age = c(23,35,20,31, 26))
Perhaps there is another reason why you did not consider this approach for the first time, though ...
Chase
source share