**Rbind() Function**

The rbind() function is used to perform the row binding that binds the data by row.

**In a Vector
**Rbind() is used to perform the row binding that binds the multiple vectors by row.

**Syntax**

Where vector_object is the vector.

**Example
**In this example, we perform the row binding on three vectors.

apples=c(34,45)

mangoes=c(14,35)

guava=c(12,34)

#perform row bind on these three vectors

print(rbind(apples,mangoes,guava))

**Result**

We can see that the vectors are combined by row.

**In a List
**Rbind() is used to perform the row binding that binds the multiple lists by row.

**Syntax**

Where list_object is the list.

**Example
**In this example, we perform the row binding on three lists.

apples=list(34,45)

mangoes=list(14,35)

guava=list(12,34)

#perform row bind on these three lists

print(rbind(apples,mangoes,guava))

**Result**

We can see that the lists are combined by row.

**In a Dataframe
**Rbind() is used to perform the row binding that binds the multiple dataframes by row.

**Syntax**

Where dataframe_object is the dataframe.

**Example 1
**In this example, we perform the row binding on the market_id column in three dataframes.

apples=data.frame(market_id=c(1,2,3),market_name=c('M1','M2','M3'))

mangoes=data.frame(market_id=c(4,5,6),market_name=c('M1','M2','M3'))

guava=data.frame(market_id=c(7,8,9),market_name=c('M1','M2','M3'))

#perform row bind on market_id columns

print(rbind(apples$market_id,mangoes$market_id,guava$market_id))

**Result**

We can see that the market_id column in three dataframes is combined by row.

**Example 2
**In this example, we perform the row binding on three dataframes.

apples=data.frame(market_id=c(1,2,3),market_name=c('M1','M2','M3'))

mangoes=data.frame(market_id=c(4,5,6),market_name=c('M1','M2','M3'))

guava=data.frame(market_id=c(7,8,9),market_name=c('M1','M2','M3'))

#perform row bind on all columns

print(rbind(apples,mangoes,guava))

**Result**

We can see that all columns in three dataframes is combined by row.

**In a Matrix
**Rbind() is used to perform the row binding that binds the multiple matrices by row.

**Syntax**

Where matrix_object is the matrix.

**Example
**In this example, we perform the row binding on two matrices.

fruits=c(23,4,43,3,4,5,6,7,8,967,65,43,5,56,78,67,45,44,67,665)

#pass the vector to a matrix with 5 rows and 4 columns

matrix_object1=matrix(fruits,nrow=5,ncol=4)

#create vector for vegetables

vegetables=c(23,4,43,3,4,5,6,7,8,967,65,43,5,56,78,67,87,90,87,0)

#pass the vector to a matrix with 4 rows

matrix_object2=matrix(vegetables,nrow=5,ncol=4)

#perform row bind

print(rbind(matrix_object1,matrix_object2))

**Result**

We can see that all rows and columns in two matrices are combined by row.

**Cbind() Function**

The cbind() function is used to perform the column binding that binds the data by column.

**In a Vector
**Cbind() is used to perform the column binding that binds the multiple vectors by column.

**Syntax**

Where vector_object is the vector.

**Example
**In this example, we perform the column binding on three vectors.

apples=c(34,45)

mangoes=c(14,35)

guava=c(12,34)

#perfrom column binding on these three vectors

print(cbind(apples,mangoes,guava))

**Result**

We can see that the vectors are combined by column.

**In a List
**Cbind() is used to perform the column binding that binds the multiple lists by column.

**Syntax**

Where list_object is the list.** **

**Example
**In this example, we perform the column binding on three lists.

apples=c(34,45)

mangoes=c(14,35)

guava=c(12,34)

#perfrom column binding on these three vectors

print(cbind(apples,mangoes,guava))

**Result**

We can see that the lists are combined by column.

**In a Dataframe
**Cbind() is used to perform the column binding that binds the multiple dataframes by column.

**Syntax**

Where dataframe_object is the dataframe.

**Example 1
**In this example, we perform the column binding on the market_id column in three dataframes.

apples=list(34,45)

mangoes=list(14,35)

guava=list(12,34)

#perform column binding on these three lists

print(cbind(apples,mangoes,guava))

**Result**

We can see that the market_id column in three dataframes is combined by column.

**Example 2
**In this example, we perform the column binding on three dataframes.

apples=data.frame(market_id=c(1,2,3),market_name=c('M1','M2','M3'))

mangoes=data.frame(market_id=c(4,5,6),market_name=c('M1','M2','M3'))

guava=data.frame(market_id=c(7,8,9),market_name=c('M1','M2','M3'))

#perform column binding on market_id columns

print(cbind(apples$market_id,mangoes$market_id,guava$market_id))

**Result**

We can see that all columns in the three dataframes are combined by column.** **

**In a Matrix
**Cbind() is used to perform the column binding that binds the multiple matrices by column.

**Syntax**

Where matrix_object is the matrix.** **

**Example
**In this example, we perform the column binding on two matrices.

fruits=c(23,4,43,3,4,5,6,7,8,967,65,43,5,56,78,67,45,44,67,665)

#pass the vector to a matrix with 5 rows and 4 columns

matrix_object1=matrix(fruits,nrow=5,ncol=4)

#create vector for vegetables

vegetables=c(23,4,43,3,4,5,6,7,8,967,65,43,5,56,78,67,87,90,87,0)

#pass the vector to a matrix with 4 rows

matrix_object2=matrix(vegetables,nrow=5,ncol=4)

#perform column binding

print(cbind(matrix_object1,matrix_object2))

**Result**

We can see that all rows and columns in two matrices are combined by column.

**Conclusion**

In this R tutorial, we learned how to perform the row binding and column binding on vectors, lists, dataframes, and matrices using the rbind() and cbind() functions.