Open 1to1 left.csv: | Open 1to1 right.csv: |
left <- read.csv('1to1 left.csv') | right <- read.csv('1to1 right.csv') |
left key Veggies 1 Mon Broccoli 2 Tue Celery 3 Thu Lettuce 4 Fri Spinach | right key Fruits 1 Mon Apples 2 Wed Bananas 3 Thu Cherries 4 Sat Dates |
# The variables need to have the same names
names(left)[2] <- 'Veggies_Fruits'
names(right)[2] <- 'Veggies_Fruits'
add_rows1 <- rbind(left, right)
add_rows1
key Veggies_Fruits
1 Mon Broccoli
2 Tue Celery
3 Thu Lettuce
4 Fri Spinach
5 Mon Apples
6 Wed Bananas
7 Thu Cherries
8 Sat Dates
# Or using the dplyr package
library(dplyr)
add_rows2 <- left %>% bind_rows(right)
add_rows2
Source: local data frame [8 x 2]
key Veggies_Fruits
1 Mon Broccoli
2 Tue Celery
3 Thu Lettuce
4 Fri Spinach
5 Mon Apples
6 Wed Bananas
7 Thu Cherries
8 Sat Dates
Functions referenced:
bind_rows (page 40)
More information:
RStudio Data Wrangling Cheatsheet
--- The End ---