I am trying to do something that may not be possible in R, but I'm largely R self-taught so there is a good chance that I'm making an obvious error.
I am trying to use the list.files function to list only the files in a folder that are also listed in a reference data frame.
My data frame looks like this:
> G2_1A27
Treatment Date Chamber_ID GasmetID Spectrum.file
24 1A27 8/28/2018 11:51 <NA> G2 Spectrum_000024.spe
25 1A27 8/28/2018 11:53 <NA> G2 Spectrum_000025.spe
26 1A27 8/28/2018 11:55 <NA> G2 Spectrum_000026.spe
27 1A27 8/28/2018 11:57 <NA> G2 Spectrum_000027.spe
28 1A27 8/28/2018 11:59 <NA> G2 Spectrum_000028.spe
29 1A27 8/28/2018 12:01 <NA> G2 Spectrum_000029.spe
30 1A27 8/28/2018 12:03 <NA> G2 Spectrum_000030.spe
31 1A27 8/28/2018 12:05 <NA> G2 Spectrum_000031.spe
The list of files I want are the spectrum files under the Spectrum.file column and the folder I'm listing from contains the actual files and then some from other treatments. I have separate dataframes for each treatment and the spectrum files are split up by date.
current.folder <- "G:\\Team Drives\\USDA_SCRI\\UCSC_field_trial_results\\Gasmet\\G2\\180828_180829_G2\\Samples\\"
setwd("G:\\Team Drives\\USDA_SCRI\\UCSC_field_trial_results\\Gasmet\\G2\\180828_180829_G2\\Samples\\")
new.folder <- "C:\\Users\\pres9340\\Desktop\\test"
list.of.files = list.files(current.folder, G2_1A27$Spectrum.file)
I didn't expect this to work but when it runs it does reference the data frame but only outputs the first file rather than listing all files in the folder that match the files in the dataframe.