Hello everyone,

Merging two dataframes should be easy.  However when I try to merge, R
doesn't recognize identical values, even if I am doing it by values that
have no decimals.

willclayong:
   vs30      LON     LAT  Net  X wills.cat wills.vs30 clahan.cat clahanvs30
PolyID.wills PolyID.clahan tif.cat STA ELEVATION tif.vs30
1 338.539 -3849590 4319319 <NA>  2         D        301          D
377         1958          1942       1 150        NA      519
2 712.822 -3849590 4319319 <NA>  3         D        301          D
377         1958          1942       1 479        NA      519
3 477.652 -3836584 4288164 <NA> 10         C        464          C
489         1194          9353       3 148        NA      547
4 513.703 -3836575 4287739 <NA> 11         C        464          C
489         1194          9353       3 485        NA      547
5 477.652 -3835886 4289120 <NA> 12         C        464          C
489         1194          9353       7 147        NA      388

wald:

> wald_ol_sta[1:10,]
    X Wald.vs30  STA    vs30      LON     LAT
1   1   434.417 1502 274.500 -3077929 3759564
2   2   378.049 NEE2 363.000 -3086165 3718184
3   3   196.848  EMS 336.000 -3143337 3500449
4   4   557.625 1498 659.600 -3103738 3871531
5   5   263.878 1497 274.500 -3102944 3878068
6   6   374.898 1499 274.500 -3109753 3858460
7   7   150.000  230 274.500 -3154048 3482703
8   8   248.342 1205 207.469 -3153294 3497116
9   9   422.256 1495 338.600 -3097854 3990339
10 10   322.540 1496 274.500 -3115300 3863905

willsclayongwald<-merge(wald_ol_sta, willsclayong, by=c("LON", "LAT", "STA",
"vs30"))

returns nothing... if I modify the previous script by adding "all=TRUE", I
get this:


lsclayongwald[1:10,]
        LON     LAT STA    vs30  X.x       Wald.vs30  Net X.y wills.cat
wills.vs30 clahan.cat clahanvs30 PolyID.wills PolyID.clahan tif.cat
ELEVATION tif.vs30
1  -3854850 4321856 478  513.703 1155       586.685 <NA>  NA
<NA>         NA       <NA>         NA           NA            NA
NA        NA       NA
2  -3849590 4319319 150  338.539   NA         NA <NA>   2         D
301          D        377         1958          1942       1        NA
519
3  -3849590 4319319 479  712.822   NA         NA <NA>   3         D
301          D        377         1958          1942       1        NA
519
4  -3849590 4319319 150  338.539 1152       336.794 <NA>  NA
<NA>         NA       <NA>         NA           NA            NA
NA        NA       NA


rows 2 and 4 should have merged.  Why didn't they?


thanks!


Mehdi Khan

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to