Link case id to file name in R

Viewed 24

I have a ton of files, and I need to link those files with sample.ID's I have together in another file:

file1
file2
file3
file4


   filename sample.id
1:    file1       abc
2:    file2       adf
3:    file3       gfd
4:    file4       dsf

what I need to do is, to file 1,2,3 and 4 add a column saying : file1, sample.id: abc etc.

I thought this would do the trick::

df$Sample.ID <- datafile$sample.id[match(df$Sample.ID, datafile$File.Name)]

but that did not work, anyone ever did something like this?

0 Answers
Related