Skip to content

Instantly share code, notes, and snippets.

@yuifu
Last active July 1, 2017 04:14
Show Gist options
  • Save yuifu/e80ac66768f432b4540f7de8d6714a10 to your computer and use it in GitHub Desktop.
Save yuifu/e80ac66768f432b4540f7de8d6714a10 to your computer and use it in GitHub Desktop.
# Installation
# install.packages("dplyr")
library(dplyr)
df1 = data.frame(
A=c("A1", "A2", "A3", "A4")
)
df2 = data.frame(
B=c("A1", "A2", "A3", "A4", "A5"),
D=c("D1", "D2", "D3", "D4", "D5")
)
df3 = merge(df1, df2, by.x="A", by.y="B", all.x=TRUE)
colnames(df3)[2] = "C"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment