I have multiple files with tab separated data that looks like this:
A 25
B 50
C 10
D 30
What I would like is to invert and combine them. So it looks like this:
filename A B C D
file1 25 50 10 30
file2 20 15 0 10
file3 60 20 30 0
As you can see there are some files that have missing data (file2 lacks a value for C so there is no row C in that file). I would like to have any missing columns reported as 0.
I tried using data = lapply(filelist, read.table, sep = "\t") but this just gives me:
data
[[1]]
V1 V2
1 C 27660
2 B 4
3 E 40128
4 D 4584
5 G 43078
[[2]]
V1 V2
1 C 31530
2 E 47978
3 D 5268
4 G 54636
Which is not what I want. I want the letters to be the columns and the rows to be the file names.