You can also use unlist()
, which is often useful for handling lists:
> mylist <- list(A = c(1:3), B = c(4:6), C = c(7:9))
> mylist
$A
[1] 1 2 3
$B
[1] 4 5 6
$C
[1] 7 8 9
> unlist(mylist)
A1 A2 A3 B1 B2 B3 C1 C2 C3
1 2 3 4 5 6 7 8 9
> length(unlist(mylist))
[1] 9
unlist() is a simple way of executing other functions on lists as well, such as:
> sum(mylist)
Error in sum(mylist) : invalid 'type' (list) of argument
> sum(unlist(mylist))
[1] 45