在R语言中,合并两个数据集可以使用merge()函数或者dplyr包中的left_join()、right_join()、inner_join()、full_join()等函数来实现。
merged_data <- merge(data1, data2, by = "key_column")
library(dplyr)
# left join
merged_data <- left_join(data1, data2, by = "key_column")
# right join
merged_data <- right_join(data1, data2, by = "key_column")
# inner join
merged_data <- inner_join(data1, data2, by = "key_column")
# full join
merged_data <- full_join(data1, data2, by = "key_column")