VOOZH about

URL: https://www.geeksforgeeks.org/r-language/how-to-merge-multiple-dataframes-in-r/

⇱ How to merge multiple DataFrames in R ? - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

How to merge multiple DataFrames in R ?

Last Updated : 30 Apr, 2021

In this article, we will discuss how to merge multiple dataframes in R Programming Language. Dataframes can be merged both row and column wise, we can merge the columns by using cbind() function and rows by using rbind() function

Merging by Columns

cbind() is used to combine the dataframes by columns.

Syntax:

cbind(data1,data2,..............,data n)

Parameters:

where data1 and data 2 are the data frames.

Example 1:

Output:

👁 Image

Example 2:

We can also merge specific columns in each dataframe by using $ operator we can access the dataframe column

Syntax:

dataframe_name$columnname

Output:

👁 Image

Example 3:

Output:

👁 Image

Merging by Rows

We can merge the rows between the dataframes using rbind() function.

Syntax:

rbind(dataframe1,dataframe2)

Example 1:

Output:

👁 Image

Example 2:

Output:

👁 Image
Comment

Explore