I have 94 tab delimited files, no header, in a single directory '/path/' with gene names in the first column and counts in the second column. There are 23000 rows.
I would like to read all 94 files found in /path/ in to R and merge all of the 94 files to create a single data frame 'counts.table' where the first column contains the gene names (identical and in the same order in Column 1 of all 94 files) and second to ninety-fifth column contains the counts from each individual file (i.e. Column 2 of each of the 94 files, which are unique numbers). The final counts.table data frame will have 23000 rows and 95 columns.
Ideally like this:
Column1 Column2 Column3 Column4... to column 95
gene a 0 4 3
gene b 4 9 9
gene c 3 0 8
...
to row 23000
Column2 contains counts from sample X, Column3 counts from sample Y, column 4 from sample Z, etc.
Do I have to read each file in to R individually and then merge them all by adding the second column of each file with cbind to create 'counts.table'? Thanks in advance.