简体   繁体   English

在R列中导入多个CSV文件

[英]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. 我需要将多个296x2(296行x 2列)的CSV文件导入单个数据集中。

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. 我想将所有CSV逐列合并到单个数据集中(一次仅将第一列保存为行名。换句话说,所有329个CSV文件都以逗号分隔,并且都相同296x2。 296x329数据集,其中包括每个数据集的第二列。

Thanks in advance Emiliano 在此先感谢Emiliano

Without knowing your data it's difficult to say, but assume you have your dataset in a folder name: C:/foo/. 不知道您的数据很难说,但是假设您的数据集位于一个文件夹名称中: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)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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