Reputation: 47
I need to import several CSV files of 296x2 (296 rows x 2 columns) into a single dataset.
First column is the same for all files.
I would like to merge all the CSV into a single dataset columnwise (conserving only the first column as row name once. In other words, All the 329 CSV files are comma delimited and are all the same 296x2. I would like to end up with a 296x329 dataset that includes the second column of each dataset.
Thanks in advance Emiliano
Upvotes: 0
Views: 572
Reputation: 2077
Without knowing your data it's difficult to say, but assume you have your dataset in a folder name: C:/foo/. Try this one:
filenames <- list.files('C:/foo/', pattern="*.csv", full.names=TRUE)
la <- lapply(filenames, read.csv)
Reduce(function(x, y) merge(x, y, by="Wavelength"), la)
Upvotes: 1