I have a list of vectors whose values are bounded between 1 and 100.
[[1]]
[[1]][[1]]
[1] "a"
[[1]][[2]]
[1] 41 5 53 55 56
[[2]]
[[2]][[1]]
[1] "b"
[[2]][[2]]
[1] 41 1 57 53 48
etc.
How do i somehow get to the following data.frame
no 1 2
1 NA b
41 a b
5 a NA
53 a NA
55 a NA
56 a NA
48 NA b
57 NA b
53 NA b
and from there fill in the missing rows and ordered according to the column “no” where column no. runs from 1 to 100?
eg.
no 1 2
1 NA b
2 NA NA
3 NA NA
4 NA NA
5 a NA
etc.
all the way until the 100th row.
Here is an approach with
lapply:The data:
The solution:
The output (the first 10 rows):