Home > Back-end >  Combining different data frames with ID column
Combining different data frames with ID column

Time:05-27

I have the follwing data frames Data1 region 1

SID chr beta pval

Rs500 21 0.45 0.005

Data 2 region 2

SID chr beta pval

Rs500 21 0.7 0.007

Data3 region 3


SID  chr  beta  pval

Rs500 21 0.57 0.003

I want to combine data as Data

SID  chr beta pval region

Rs500 21 0.45  0.005 region1

Rs500 21 0.7   0.007 region 2

Rs500 21 0.57. 0.003 region 3

Anyone can help with the code in r or linux Thanks chuchu

CodePudding user response:

First label your regions so that you can tell which region the data comes from.

data1$region <- 'Region 1'
data2$region <- 'Region 2'
data3$region <- 'Region 3'

Then combine:

rbind(data1, data2, data3) 
  • Related