[R] merging df with world map

chalabi.elahe at yahoo.de chalabi.elahe at yahoo.de
Fri Jun 17 22:06:29 CEST 2016


Hi all,
I want to use world map in ggplot2 and show my data on world map. my df is:


    $ COUNTRY           : chr  "DE" "DE" "FR" "FR" ..

    $ ContrastColor     : int  9 9 9 9 13 9 9 9 9 ..

    $ quant             : Factor w/ 4 levels "FAST","SLOW",..I need to merge my df with world_map data which is like this:

    
    world_map=map_data("world")
    data.frame':   99338 obs. of  6 variables:
    $ long     : num  -69.9 -69.9 -69.9 -70 -70.1 ...
    $ lat      : num  12.5 12.4 12.4 12.5 12.5 ...
    $ group    : num  1 1 1 1 1 1 1 1 1 1 ...
    $ order    : int  1 2 3 4 5 6 7 8 9 10 ...
    $ region   : chr  "Aruba" "Aruba" "Aruba" "Aruba" ...
    $ subregion: chr  NA NA NA NA ...
but by merging my df with world map data I get a data frame with zero observation in it,I use this command for merging:


    world_map=merge(world_map,df,by.x="region",by.y="COUNTRY")
    str(world_map) 

    'data.frame':   0 obs. of  133 variables:
    $ region            : chr 
    $ long              : num 
    $ lat               : num 
    $ group             : num 
    $ order             : int 
    $ subregion         : chr
does anyone know what is the problem of this merging that I am currently using?
thanks for any help!
Elahe



More information about the R-help mailing list