简体   繁体   中英

Import multiple CSV files in R columnwise

在此处输入图片说明 I am reshaping my question,

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

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM