I have to data frame as ‘datExpr’ and ‘Clin_dat’. Both of them has 50 rows that all row names are equally one by one but not in the same order. I would like to join them to new data frame based on row names. Clin_dat:
           batch_STF
STT5840_LMS     1
STT5977_LMS     1
STT5980_LMS     2
STT5528_LMS     1
STT516_LMS      2
And datExpr is:
             C9orf152     ELMO2       RPS11      CREB3L1    PNMA1
STT6023_LMS 4.091188    0.8606005   11.954766   3.012608    2.5594348
STT6024_LMS 3.488034    2.0236382   12.183710   3.672799    2.1944313
STT6027_LMS 4.463488    2.3819448   11.080929   6.182108    3.7694720
STT6030_LMS 3.284857    2.2709810   12.034030   9.193188    2.5655489
STT6032_LMS 3.608634    1.4886245   13.277227   6.375075    1.4886245
I use below command :
datExpr_batch <- merge(clin_dat,datExpr,by = "row.names", all=TRUE)
so my expectation is a new data frame by 50 rows and colnames equal names of 2 data frame same as below:
        batch_STF  C9orf152       ELMO2       RPS11      CREB3L1    PNMA1
STT5840_LMS 1       4.091188    0.8606005   11.954766   3.012608    2.5594348
STT5977_LMS 1       3.488034    2.0236382   12.183710   3.672799    2.1944313
STT5980_LMS 2       4.463488    2.3819448   11.080929   6.182108    3.7694720
STT5528_LMS 1       3.284857    2.2709810   12.034030   9.193188    2.5655489
STT516_LMS  2       3.608634    1.4886245   13.277227   6.375075    1.4886245
but datExpr_batch has 88 rows. Same as below:
      Row.names    batch_STF C9orf152    ELMO2         RPS11    CREB3L1     PNMA1
  1 STT1220_LMS     NA        4.535153  2.4097580   12.723243   7.664104    1.6585204
  2 STT1220_LMS     2         NA              NA         NA        NA          NA
  3 STT516_LMS      NA        5.946659  2.9526839   12.521319   3.584952    4.0230725
  4 STT516_LMS      2         NA              NA         NA        NA          NA
  5 STT5528_LMS     1         3.361717  2.2189714   11.534295   6.691495    1.8199992
  6 STT5839_LMS     NA      5.148852    2.5861328   11.561949   10.344959   3.7855736
  7 STT5839_LMS     1          NA          NA          NA          NA         NA
I apprecite it if anybody shares his/her comment with me.
 
    