[R] merging multiple data frames
Steve Lianoglou
mailinglist.honeypot at gmail.com
Thu Sep 23 15:53:35 CEST 2010
Hi,
On Thu, Sep 23, 2010 at 9:04 AM, rasanpreet <rasanpreet.kaur at gmail.com> wrote:
>
> hi guys
> i have multiple data frames which i want to merge.
> there are four of them..eg
Can you provide a (correct) example of what you want your merged
data.frame to look like?
What column do you want to use in your data.frame to merge against?
I'm guessing SampleID(?), but then again, these aren't unique in your
`pdf` data.frame. For instance, what would the row for "SDM001" look
like in your merged data.frame?
-steve
> pdf
>
> SampleID UVDose_J RepairHours Day_0 Day_45 Day_90
> 1 SDM001 1.0 3 485.612 465.142 490.873
> 2 SDM001 1.0 3 503.658 457.863 487.783
> 3 SDM001 1.0 2 533.193 451.044 456.973
> 4 SDM001 1.0 2 538.334 452.887 474.915
> 5 SDM001 1.0 1 526.034 481.123 477.801
> 6 SDM001 1.0 1 546.543 472.322 481.546
> 7 SDM001 1.0 0 NA NA NA
> 8 SDM001 1.0 0 NA NA NA
> 9 SDM001 0.5 3 432.134 457.245 497.975
> 10 SDM001 0.5 3 432.605 450.184 489.468
> 11 SDM001 0.5 2 450.335 496.520 488.784
> 12 SDM001 0.5 2 439.590 474.371 470.182
> 13 SDM001 0.5 1 510.480 489.561 525.029
> 14 SDM001 0.5 1 487.934 467.258 488.784
> 15 SDM001 0.5 0 NA NA NA
> 16 SDM001 0.5 0 NA NA NA
> 20 SDM002 1.0 3 465.549 528.715 501.374
> 21 SDM002 1.0 3 458.168 505.480 489.244
> 22 SDM002 1.0 2 447.317 464.009 478.058
> 23 SDM002 1.0 2 452.020 438.446 470.996
> 24 SDM002 1.0 1 441.718 458.760 499.221
> 25 SDM002 1.0 1 447.017 402.616 548.797
> 26 SDM002 1.0 0 NA NA NA
> 27 SDM002 1.0 0 NA NA NA
> 28 SDM002 0.5 3 421.409 448.870 476.392
> 29 SDM002 0.5 3 404.089 446.413 477.080
> 30 SDM002 0.5 2 399.775 432.678 465.015
> 31 SDM002 0.5 2 427.157 443.418 477.048
> 32 SDM002 0.5 1 389.674 449.353 482.264
> 33 SDM002 0.5 1 418.147 455.983 495.486
> 34 SDM002 0.5 0 NA NA NA
> 35 SDM002 0.5 0 NA NA NA
> 39 SDM005 1.0 3 579.836 441.040 476.382
> 40 SDM005 1.0 3 578.525 443.875 472.867
> 41 SDM005 1.0 2 564.266 432.116 469.416
> 42 SDM005 1.0 2 571.045 447.658 458.233
> 43 SDM005 1.0 1 564.664 427.673 524.122
> 44 SDM005 1.0 1 568.182 458.039 477.237
> 45 SDM005 1.0 0 NA NA NA
> 46 SDM005 1.0 0 NA NA NA
> 47 SDM005 0.5 3 556.534 424.786 501.658
> 48 SDM005 0.5 3 474.027 441.418 507.635
> 49 SDM005 0.5 2 481.355 430.346 468.021
> 50 SDM005 0.5 2 478.922 466.933 471.025
> 51 SDM005 0.5 1 505.539 937.759 460.985
> 52 SDM005 0.5 1 497.913 457.932 493.152
> 53 SDM005 0.5 0 NA NA NA
> 54 SDM005 0.5 0 NA NA NA
> 58 SDM006 1.0 3 589.164 459.578 509.565
> 59 SDM006 1.0 3 608.477 480.233 519.785
> 60 SDM006 1.0 2 598.354 449.266 487.058
> 61 SDM006 1.0 2 617.823 456.908 507.467
> 62 SDM006 1.0 1 566.477 500.189 526.744
> 63 SDM006 1.0 1 622.170 462.463 550.675
> 64 SDM006 1.0 0 NA NA NA
> 65 SDM006 1.0 0 NA NA NA
> 66 SDM006 0.5 3 546.472 457.880 468.129
> 67 SDM006 0.5 3 525.069 444.575 505.154
> 68 SDM006 0.5 2 569.068 446.196 473.739
> 69 SDM006 0.5 2 534.205 470.366 476.570
>
> bdf
> SampleID UVDose_J RepairHours Day_0 Day_45 Day_90
> 17 SDM001 0.5 B 88.6145 388.3575 198.467
> 36 SDM002 0.5 B 100.0760 384.9505 234.740
> 55 SDM005 0.5 B 121.9595 300.3650 241.832
> 74 SDM006 0.5 B 174.7005 378.3435 291.272
> 93 SDM007 0.5 B 319.7750 335.4390 110.306
> 112 SDM008 0.5 B 292.8400 323.0370 172.615
> 131 SDM010 0.5 B 112.0225 281.0390 562.459
> 150 SDM011 0.5 B 125.0440 331.4650 230.026
> 169 SDM012 0.5 B 229.1310 264.5580 234.231
> 188 SDM013 0.5 B 212.9690 524.0240 420.211
> 207 SDM014 0.5 B 366.3350 225.0610 203.588
> 226 SDM016 0.5 B 305.6080 381.5770 155.052
> 245 SDM017 0.5 B 223.6260 281.7830 182.374
> 264 SDM018 0.5 B 200.7720 401.6350 193.573
> 283 SDM019 0.5 B 164.2360 156.9960 175.896
> 302 SDM023 0.5 B 198.8900 210.0600 215.629
> 321 SDM024 0.5 B 351.8460 100.0980 185.388
> 340 SDM026 0.5 B 190.4560 132.8970 160.213
> 359 SDM028 0.5 B 252.9760 158.2910 120.425
> 378 SDM029 0.5 B 411.0690 134.1060 138.528
>
> tdf
> SampleID UVDose_J RepairHours Day_0 Day_45 Day_90
> 19 SDM001 0.5 T 642.3255 579.6635 537.581
> 38 SDM002 0.5 T 531.2000 581.0030 557.537
> 57 SDM005 0.5 T 619.5420 539.9010 548.100
> 76 SDM006 0.5 T 707.0940 563.1125 575.318
> 95 SDM007 0.5 T 679.3480 794.3410 332.972
> 114 SDM008 0.5 T 535.6860 759.0300 452.312
> 133 SDM010 0.5 T 756.8055 549.2960 916.447
> 152 SDM011 0.5 T 530.1690 557.1600 564.988
> 171 SDM012 0.5 T 570.6130 586.7140 643.590
> 190 SDM013 0.5 T 801.2055 711.1110 846.603
> 209 SDM014 0.5 T 681.6570 579.3980 464.721
> 228 SDM016 0.5 T 646.3070 796.6570 461.541
> 247 SDM017 0.5 T 598.1090 600.5710 380.724
> 266 SDM018 0.5 T 478.8850 763.9780 487.901
> 285 SDM019 0.5 T 551.8080 393.5920 427.805
> 304 SDM023 0.5 T 540.6330 432.2220 521.390
> 323 SDM024 0.5 T 907.8530 423.7630 606.219
> 342 SDM026 0.5 T 491.7560 351.3230 397.250
> 361 SDM028 0.5 T 856.5920 433.1750 521.138
> 380 SDM029 0.5 T 1016.0070 402.5070 530.783
>
> udf
> SampleID UVDose_J RepairHours Day_0 Day_45 Day_90
> 18 SDM001 0.5 U 550.8855 526.7340 529.872
> 37 SDM002 0.5 U 412.3365 509.4620 550.017
> 56 SDM005 0.5 U 480.2640 483.4895 542.689
> 75 SDM006 0.5 U 540.4710 511.0770 560.678
> 94 SDM007 0.5 U 570.0560 681.3420 319.796
> 113 SDM008 0.5 U 519.8770 645.7330 388.029
> 132 SDM010 0.5 U 585.8030 500.4690 807.349
> 151 SDM011 0.5 U 478.6695 551.5200 558.238
> 170 SDM012 0.5 U 511.4090 559.7340 616.184
> 189 SDM013 0.5 U 600.0280 640.7730 742.612
> 208 SDM014 0.5 U 678.5090 533.0730 437.730
> 227 SDM016 0.5 U 590.0480 753.8820 439.535
> 246 SDM017 0.5 U 541.5020 596.2840 358.916
> 265 SDM018 0.5 U 472.7440 633.3910 475.366
> 284 SDM019 0.5 U 463.6920 371.9310 395.282
> 303 SDM023 0.5 U 475.2470 429.0660 447.901
> 322 SDM024 0.5 U 829.9080 409.1480 542.602
> 341 SDM026 0.5 U 451.6500 347.2890 352.653
> 360 SDM028 0.5 U 697.7690 384.7120 520.445
> 379 SDM029 0.5 U 943.3400 351.4490 527.495
>
>
> now i want to merge all these data frames and perform calculation like
> (pdf$Day_0-bdf$Day_0)/(tdf$Day_0-bdf$Day_0)
> (udf$Day_0-bdf$Day_0)/(tdf$Day_0-bdf$Day_0)
>
> please note the Repair hours and UV dose is different
>
> please help....really urgent
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/merging-multiple-data-frames-tp2551995p2551995.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
Steve Lianoglou
Graduate Student: Computational Systems Biology
| Memorial Sloan-Kettering Cancer Center
| Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact
More information about the R-help
mailing list