I am working with a list as follows:
> l <- list(c(2,4,9), c(4,2,6,1))
> m <- melt(l)
> m
value L1
2 1
4 1
9 1
4 2
2 2
6 2
1 2
i want to add index i
for my resulting data frame m
looks like this:
> m
i value L1
1 2 1
2 4 1
3 9 1
1 4 2
2 2 2
3 6 2
4 1 2
i
indicating 3 values belongs to first list element and 4 values belongs to the second list element.
How can i archive it please, can anyone help?