I have a very unfriendly list and need to convert it into a df (res) for further processing.
The structure of the columns is always the same with value, count, value.1,count.1......etc. Ideal form of the dataframe:
value count value.1 count.1 value.2 count.2
1 12 1 6 1 5
2 3 2 4 2 6
3 4 3 5 3 8
4 7 4 3
5 8
So far , I have tried
do.call(c, lapply(res, rownames))
and unlist(lapply(res, rownames))
but it just gets mixed up and seperated in the wrong colums. In the following code, I nearly get there:
require(reshape2)
res$value<- rownames(res)
b<-melt(res)
and the output looks like this:
Var1 Var2 value L1
1 value 2 1
2 value 5 1
3 count 1 1
4 count 2 1
5 value 7 2
6 value 9 2
7 count 10 2
8 count 2 2