I am looking for a way to create a vector which contains the second element of 
every vector in the list. However, not every vector has two components, so I 
need to generate an NA for those missing. For example, I have created the 
following list:

lst <- list(c("a", "b"), c("c"), c("d", "e"), c("f", "g"))

> lst
[[1]]
[1] "a" "b"
[[2]]
[1] "c"
[[3]]
[1] "d" "e"
[[4]]
[1] "f" "g"

I would like the output to be the following:

> output
[1] "b"   NA "e"   "g"

I know I can accomplish this using a for loop, but I am wondering if there's a 
simple and neat way of getting this done in one step?

Thanks in advance.

- Andrew


      
	[[alternative HTML version deleted]]

