合并具有缺失值和非结构化数据集的csv

时间:2019-07-04 03:55:10

标签: r

嗨,我无法合并非结构化的csv文件。下面是我的代码:

file1 = read.csv("fileone.csv",header=TRUE,skip=0)
file2 = read.csv("filetwo.csv",header=TRUE,skip=0)

我有类似这样的数据集:

 Data:file1                                   Date:file2
 City     State                              City    State
Boston      MA                              Dallas     TX
Seattle     WA                              Lowell     MA
Miami       FL
Chicago     IL

我想要这样的结果:

  MergedData
City      State
Boston      MA                              
Seattle     WA                              
Miami       FL
Chicago     IL
Dallas      TX
Lowell      MA

1 个答案:

答案 0 :(得分:1)

尝试一下:

mergedFile =merge(file1,file2,all=TRUE,sort=FALSE)