There are two lists of lists, one contains only values:
lists <- list(list(c(0, 0), c(2, 2, 2), c(3, 4, 4, 5), c(5, 6, 7, 5)),
list(c(0, 0), c(1, 1, 2), c(5, 5, 5), c(6, 6, 7, 7)))
> lists
[[1]]
[[1]][[1]]
[1] 0 0
[[1]][[2]]
[1] 2 2 2
[[1]][[3]]
[1] 3 4 4 5
[[1]][[4]]
[1] 5 6 7 5
[[2]]
[[2]][[1]]
[1] 0 0
[[2]][[2]]
[1] 1 1 2
[[2]][[3]]
[1] 5 5 5
[[2]][[4]]
[1] 6 6 7 7
And the other list contains only corresponding names:
names <- list(list(c(1, 2), c(1, 2, 3), c(1, 2, 3, 4), c(1, 2, 3, 4)),
list(c(1, 2), c(1, 2, 3), c(1, 2, 3), c(1, 2, 3, 4)))
> names
[[1]]
[[1]][[1]]
[1] 1 2
[[1]][[2]]
[1] 1 2 3
[[1]][[3]]
[1] 1 2 3 4
[[1]][[4]]
[1] 1 2 3 4
[[2]]
[[2]][[1]]
[1] 1 2
[[2]][[2]]
[1] 1 2 3
[[2]][[3]]
[1] 1 2 3
[[2]][[4]]
[1] 1 2 3 4
The two lists of lists have exactly the same structure and number of elements. How can I make each element in the list names to be the name of each corresponding element in the list lists (and add a "t" as prefix), like the following?
[[1]][[1]]
t1 t2
0 0
[[1]][[2]]
t1 t2 t3
2 2 2
[[1]][[3]]
t1 t2 t3 t4
3 4 4 5
[[1]][[4]]
t1 t2 t3 t4
5 6 7 5
[[2]]
[[2]][[1]]
t1 t2
0 0
[[2]][[2]]
t1 t2 t3
1 1 2
[[2]][[3]]
t1 t2 t3
5 5 5
[[2]][[4]]
t1 t2 t3 t4
6 6 7 7