Here is my list of lists
$cor
[1] 0.10194656 0.09795653 0.18832356 0.12265421 0.09669338 0.13781369 0.16763787 0.15137726 0.10203826 0.12649443 0.16451622 0.18429656 0.21234920
[14] 0.18254895 0.10761731 0.15354220 0.13458206
$cor
[1] 0.3332299 0.3909873 0.3631544
$cor
[1] 0.11601617 0.10834637 0.10138418 0.13864724 0.17582967 0.15005935 0.05481153 0.15443826 0.08987235 0.19109966 0.13404778 0.15816381
I want all values to be in one list in the order they appear.
CodePudding user response:
I'm not sure what you are trying to do. But base R has an unlist
function which outputs what you may be looking for:
c1 <- 1:5
c2 <- 6:10
cor <- list(c1, c2)
cor
[[1]]
[1] 1 2 3 4 5
[[2]]
[1] 6 7 8 9 10
unlist(cor)
[1] 1 2 3 4 5 6 7 8 9 10
CodePudding user response:
Using the following example data:
lst <- list(cor = 1:3, cor = 4:6)
lst
$cor
[1] 1 2 3
$cor
[1] 4 5 6
You could use the following, which places all items in one vector, in their original order:
do.call(c, lst)
cor1 cor2 cor3 cor1 cor2 cor3
1 2 3 4 5 6
Reduce()
also works similarly:
Reduce(c, lst)
[1] 1 2 3 4 5 6