Combine Vectors, Matrix or Data Frames by Rows in R Language – rbind() Function

rbind() function in R Language is used to combine specified Vector, Matrix or Data Frame by rows.

Syntax: rbind(x1, x2, …, deparse.level = 1)

Parameters:
x1, x2: vector, matrix, data frames
deparse.level: This value determines how the column names generated. The default value of deparse.level is 1.

Example 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

# R program to illustrate
# rbind function
  
# Initializing two vectors
x <- 2:7
y <- c(2, 5)
  
# Calling rbind() function
rbind(x, y)

chevron_right


Output:

  [, 1] [, 2] [, 3] [, 4] [, 5] [, 6]
x    2    3    4    5    6    7
y    2    5    2    5    2    5

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

# R program to illustrate
# rbind function
  
# Initializing a vector
x <- 1:5
  
# Calling rbind() function
rbind(x, 4)
rbind(x, 5, deparse.level = 0)
rbind(x, 6, deparse.level = 2)
rbind(x, 4, deparse.level = 6)

chevron_right


Output:

  [, 1] [, 2] [, 3] [, 4] [, 5]
x    1    2    3    4    5
     4    4    4    4    4

     [, 1] [, 2] [, 3] [, 4] [, 5]
[1, ]    1    2    3    4    5
[2, ]    5    5    5    5    5

  [, 1] [, 2] [, 3] [, 4] [, 5]
x    1    2    3    4    5
6    6    6    6    6    6

     [, 1] [, 2] [, 3] [, 4] [, 5]
[1, ]    1    2    3    4    5
[2, ]    4    4    4    4    4
My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.