Open friendly opened 2 years ago
What have you tried so far? You might have better luck on Stack Overflow
Yes, I should have tried something first and then commented on what didn't work. You can close this issue.
OK, so I've tried using the two French grids, fr_departements_grid1
(101 depts) and fr_departements_grid2
(69 depts).
I can post to SO, but trying again here for some direct pointers.
My Guerry data is based on SpatialPolygonsDataFrame
maps of France in 1830, Guerry::gfrance
with 86 depts and Guerry::gfrance85
(w/o Corsica)
The key variable in my data frames is dept
, an integer, I guess corresponding to code
in your grids. But neither of your grids match my maps. I tried:
ggplot(df_ranks, aes(Crime_pers)) +
geom_point() +
facet_geo(~dept, grid = "fr_departements_grid2")
but this gives errors
# Some values in the specified facet_geo column 'dept' do not match the 'code' column of the specified grid and will be removed: 1,
# 2, 3, 4, 5, 7, 8, 9, 17, 22, 23, 29, 50, 55, 59, 61, 62, 69, 70, 78, 87, 89, 200
# Error in `levels<-`(`*tmp*`, value = as.character(levels)) :
# factor level [33] is duplicated
I guess I need to create a new grid for my maps from 1830, but have no idea how to do this.
yes, I think you are correct. There is a tool to create and export a grid here: https://hafen.github.io/grid-designer/
Can someone help me get started using the geofacet package,
fr_departements_grid1
to plot one or more of the variables in the Guerry package.`> data(Guerry)