rbind Function in R (Example)
This page explains how to bind the rows of two data frames with the rbind() function in the R programming language.
Example Data Frames
First data frame:
my_data <- data.frame(x1 = 1:5, # Create first data frame x2 = letters[1:5]) my_data # x1 x2 # 1 a # 2 b # 3 c # 4 d # 5 e |
my_data <- data.frame(x1 = 1:5, # Create first data frame x2 = letters[1:5]) my_data # x1 x2 # 1 a # 2 b # 3 c # 4 d # 5 e
Second data frame:
new_data <- data.frame(x1 = 999, # Create second data frame x2 = "new") new_data # x1 x2 # 999 new |
new_data <- data.frame(x1 = 999, # Create second data frame x2 = "new") new_data # x1 x2 # 999 new
Apply rbind Function to Data Frames
combined_data <- rbind(my_data, new_data) # Bind both data frames combined_data # x1 x2 # 1 a # 2 b # 3 c # 4 d # 5 e # 999 new |
combined_data <- rbind(my_data, new_data) # Bind both data frames combined_data # x1 x2 # 1 a # 2 b # 3 c # 4 d # 5 e # 999 new
Video Example
The following video shows another example on how to apply the rbind function in R. Furthermore, the video shows how to apply the rbind.fill function of the dplyr package.

By loading the video, you agree to YouTube’s privacy policy.
Learn more