[R] merging data frame with world map
Michael Dewey
lists at dewey.myzen.co.uk
Mon Mar 7 14:15:09 CET 2016
Inline
On 07/03/2016 12:21, hoda rahmati via R-help wrote:
> Hi all,I have a data frame which have a column named COUNTRY, I want to merge my data frame with world map from ggmap to plot it on world map, but when I merge my data frame with world map I get 0 observations! Here is my main data frame (mydata):
> 'data.frame': 269265 obs. of 470 variables:
> $ Serial : num 41568 41568 41568 41568 41568 ...
> $ Duration : num 218 351 250 200 375 91 236 250 236 322 ...
> $ COUNTRY : Factor w/ 27 levels "","AU","BA","BE",..: 8 8 8 8 8
COUNTRY
> and here is the command for merging with world map:
> word_map=merge(world_map,mydata,by.x="region",by.y="country")
country
> str(world_map)
> 'data.frame': 0 obs. of 475 variables:
> $ Serial : num
> $ Duration : num
> $ COUNTRY : chr
> how should I correct this world_map structure to have all my observations? And I could not use rworldmap in R 3.2.3,anyone used this library in version 3.2.3?
> Thanks for any help.
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
>
--
Michael
http://www.dewey.myzen.co.uk/home.html
More information about the R-help
mailing list