[R] merging dataframes

ManuelPerera-Chang@fmc-ag.com ManuelPerera-Chang at fmc-ag.com
Thu Nov 3 14:44:19 CET 2005





Hi,

what about padding both datasets with dummy missing records ... and then
play with cbind and rbind

... like e.g.

> species5<-c(NA,NA,NA,NA)

> modmat2<-cbind(mat2,species1,species5)

and then similarly with mat1 ...
e.g.
species2<-c(NA,NA,NA,NA,NA)

> modmad1<-cbind(mat1,species2,species4,species9)

> rbind(modmad1,modmat2)
        species1    species3   species5   species7   species2   species4
species9
site1 -0.7190044 -0.52482580 -1.1813567 -1.5584831         NA         NA
NA
site2 -1.1782180  1.72337964  0.1652343 -0.9026087         NA         NA
NA
site3  0.3823015 -0.07226644 -1.2907470 -0.3692091         NA         NA
NA
site4 -1.3051131 -0.61107947  0.6264416  1.5259373         NA         NA
NA
site5  0.2028565 -1.28374638  1.6284780 -1.2975163         NA         NA
NA
site6         NA  1.19088414         NA  0.3159949 -0.1624538  0.5987733
0.2205512
site7         NA  0.75292176         NA  1.7524988  0.8335334 -0.7998774
-0.9788762
site8         NA -0.47803396         NA -1.3041628  1.7925165 -0.4153879
-0.4708165
site9         NA -0.20063523         NA  1.8119115  1.5351801 -1.3334419
0.5812675

it will need modifications of course if you are working with several
datasets

Saludos,

Manuel




More information about the R-help mailing list