create two dataframes and then join them by column variable in r

# Create two dataframes
df1 <- data.frame(ID = 1:3, Name = c("Alice", "Bob", "Charlie"))
df2 <- data.frame(ID = 1:3, Age = c(25, 30, 28))

# Join the dataframes by the common column "ID"
result <- merge(df1, df2, by = "ID")

# View the result
print(result)
257 chars
10 lines

related categories

gistlibby LogSnag