
Last chance! 50% off unlimited learning
Sale ends in
ggplot2
mUSMap
takes in one dataframe that includes information
about different US states. 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.
mUSMap(data, key, fill = NULL, plot = c("borders", "frame", "none"), style = c("compact", "real"))
data
that holds the unique
names of each statedata
used to specify the fill
color of states in the map (note: if fill
is not null, then
plot
cannot be set to "none")plot
= "none"
returns the merged data that is the result of merging the data
and the dataframe with the geographical coordinate information;
plot
= "frame" returns an empty (unplottable) ggplot object;
plot
= "border" (the default) returns a ggplot object with
one geom_polygon layer that shows the borders of the statescompact
gives
a polyconic projection with Alaska and Hawaii on the lower left corner;
real
gives the real size and position of all states without any
projection.USArrests2 <- USArrests %>% mutate(state = row.names(.))
mUSMap(USArrests2, key="state", fill = "UrbanPop")
Run the code above in your browser using DataLab