Consider the command that creates a list of list as follows:
myList <- list(a = list(1:5), b = "Z", c = NA)
This creates something like:
$a
$a[[1]]
[1] 1 2 3 4 5
$b
[1] "Z"
$c
[1] NA
Now when I do unlist to this,
unlist(myList, recursive = FALSE)
I get
$a
[1] 1 2 3 4 5
$b
[1] "Z"
$c
[1] NA
whereas what I am actually looking for is the first element from each sublist , i.e.
1
"Z"
NA
Loops are very slow. No loops please.
I guess it depends on what you consider to be a loop. e.g. I’d call this a loop, but maybe it’s okay for you?
If you do not want the names