简体   繁体   English

如何将多个数据csv文件合并到单个数据帧中?

[英]How to combine multiple data csv files in to single data frame?

I am having multiple csv files imported(files all are in same directory) into R with different number of columns.How can I combine them in to single data frame? 我将多个csv文件(文件都在同一目录中)导入到R中,具有不同的列数。如何将它们合并到单个数据帧中?

一类文件第二类文件

I would like to have a single dataframe like biomarkers and allclinical. 我希望有一个单一的数据框,例如生物标志物和临床药物。

Doing Column bind I will end up with a huge number of columns where as with row bind null values and data redundancy would occur. 进行列绑定我最终将获得大量列,其中与行绑定一样,空值会出现,并且会发生数据冗余。

whats the best way to deal with this solution. 什么是处理此解决方案的最佳方法。 regards, akshay 问候,akshay

use 采用

library(gtools)
df_combines <- smartbind(df1,df2,df3......)

good thing about gtools is that it will append all the data with same column name and only if the column name does not match it will add a new column to the final combined data frame . 关于gtools的好处是它会附加所有具有相同列名的数据,并且只有当列名不匹配时,它才会在最终的组合数据框架中添加一个新列。

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

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