mWorldMap | R Documentation |
ggplot2
mWorldMap
takes in one dataframe that includes information
about different countries. It merges this dataframe with a dataframe
that includes geographical coordinate information. Depending on the
arguments passed, it returns this data or a ggplot object constructed
with the data.
mWorldMap(
data = NULL,
key = NA,
fill = NULL,
plot = c("borders", "frame", "none")
)
data |
A dataframe with countries as cases |
key |
The column name in the |
fill |
A variable in the |
plot |
The plot desired for the output. |
## Not run:
gdpData <- CIAdata("GDP") # load some world data
mWorldMap(gdpData, key="country", fill="GDP")
gdpData <- gdpData |> mutate(GDP5 = ntiles(-GDP, 5, format="rank"))
mWorldMap(gdpData, key="country", fill="GDP5")
mWorldMap(gdpData, key="country", plot="frame") +
geom_point()
mergedData <- mWorldMap(gdpData, key="country", plot="none")
ggplot(mergedData, aes(x=long, y=lat, group=group, order=order)) +
geom_polygon(aes(fill=GDP5), color="gray70", size=.5) + guides(fill=FALSE)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.