Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201867

Graph of World map for df with country listing

$
0
0

I am trying to map my data on a world map according to the number of times the country has been listed.

Let's say I have this dataset

company    country    ...
A          Germany
B          China
C          Argentina
D          United States of America
E          Germany
.....

According to how often in the df the country is listed I want a bigger or smaller bubble to "rank" that.

I found a way to plot it with ggplot2 but coordinates were necessary for that and since this is concerning the entire country I was wondering if there is an easier way to plot this without needing to add and search for long & lat:

mdat <- map_data('world') 
str(mdat) 
ggplot() + geom_polygon(dat=mdat, aes(long, lat, group=group), fill="grey50") + geom_point(data=un_all_years, aes(x=Lat, y=Lon, map_id=Location), col="red") mapBubbles(dF=un_all_years, nameZColour="Location",oceanCol="lightblue", landCol="wheat", addLegend=FALSE) 

A further advanced question on this behalf is also: If I have an extra information in my data set that I would like to also include in my world map like industry sector, how could I differentiate that (let's say the bubbles will take the according colour to sector still differing in size!)

company    country         industry sector           ...
A          Germany              a
B          China                a 
C          Argentina            b
D          USA                  c
E          Germany              d
.....

It would be nice if the result would look something like this in a simplified way: enter image description here


Viewing all articles
Browse latest Browse all 201867

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>