Installation
You can install the package with devtools::install_github
:
# install.packages("devtools")
devtools::install_github("gibonet/ggswissmaps")
Content
First of all, load the package:
library(ggswissmaps)
## Loading required package: ggplot2
We can use the ls
function to look at the content:
ls("package:ggswissmaps")
## [1] "maps" "maps2" "shp_df" "theme_white_f"
Or launch the help:
utils::help(package = "ggswissmaps")
There is some data:
data(package = "ggswissmaps")
Examples
Using the data
data("shp_df")
class(shp_df)
## [1] "list"
length(shp_df)
## [1] 16
names(shp_df)
## [1] "g1b15" "g1g15_encl" "g1g15_li" "g1g15" "g1k15"
## [6] "g1l15" "g1r15" "g1s15" "g2b15" "g2g15_encl"
## [11] "g2g15_li" "g2g15" "g2k15" "g2l15" "g2r15"
## [16] "g2s15"
# Data description
?shp_df
Some maps
data("maps2")
names(maps2)
## [1] "g1b15" "g1g15_encl" "g1g15_li" "g1g15" "g1k15"
## [6] "g1l15" "g1r15" "g1s15" "g2b15" "g2g15_encl"
## [11] "g2g15_li" "g2g15" "g2k15" "g2l15" "g2r15"
## [16] "g2s15"
# By name
maps2[["g1k15"]]

# By index
maps2[[5]]

The objects contained in maps2
are ggplot
objects. They have been created with ggplot2::ggplot
plus a ggplot2::geom_path
layer with the data in shp_df
. As an example, the previous map is the same as:
ggplot(shp_df[["g1k15"]], aes(x = long, y = lat, group = group)) +
geom_path() +
coord_equal() +
theme_white_f()
