问题
I have 2 large csv files that contain information about the same shops.
File1:
Dates1 Sales
02-11-2017 100
04-11-2017 90
01-08-2016 80
01-02-2013 99
01-09-2016 12
File2:
Dates2 Stores
02-11-2017 A
04-11-2017 B
01-09-2016 C
What I need is find the matching dates and create the following table:
NewDates Stores Sales
02-11-2017 A 100
04-11-2017 B 90
01-09-2016 C 12
The files have different number of rows and the same date can be contained in a different row in the respecting file. Can you please help me solve this in R?
回答1:
library(data.table)
df1 <- fread("file1")
df2 <- fread("file2")
merge(df1, df2, by.x = 'Dates.1', by.y = 'Dates.2')
The data.table
package can handled large files.
来源:https://stackoverflow.com/questions/48191031/matching-values-in-columns-in-r