我有两个数据帧
DataFrame1 <- data.frame(StudentId = c(1:20), Subject = c(rep("Algebra", 4), rep("Geometry", 4), rep("English", 4), rep("Zoology", 4), rep("Botany", 4)), CGPA = c(random::randomNumbers(20, 70, 100, 1)), Country = c(rep("USA", 4), rep("UK", 4), rep("Germany", 4), rep("France", 4), rep("Japan", 4)))
和
DataFrame2 <- data.frame(StudentId = c(1:10), State = c(rep("NYC", 2), rep("Illinois", 2), rep("Texas", 2), rep("Virginia", 2), rep("Florida", 2)), Age = c(random::randomNumbers(10, 16, 20, 1)), Gender = c(rep("Male", 3), rep("Female", 3), rep("Male", 2), rep("Female", 2)))
我可以使用内部联接合并上面两个
merge(DataFrame1, DataFrame2)
如何合并为交叉连接两个数据帧而不重复值?
答案 0 :(得分:1)
尝试merge(DataFrame1, DataFrame2, all = T)
答案 1 :(得分:0)
尝试使用此功能进行交叉连接..
knitr :: kable(merge(x = DataFrame1,y = DataFrame2,by = NULL))