I'm drawing a geographical map next to a table with some data about it. I'm using shapefiles and a dataset.
The shapefiles are contained in a directory and I don't think there is a way to upload it in here. In my code I import from this directory the file ".sph" calling it "prov2022".
dput(prov2022)
.....
.....
.....
2L)))), class = c("XY", "MULTIPOLYGON", "sfg"))), n_empty = 0L, crs = structure(list(
input = "WGS 84 / UTM zone 32N", wkt = "PROJCRS[\"WGS 84 / UTM zone 32N\",\n BASEGEOGCRS[\"WGS 84\",\n DATUM[\"World Geodetic System 1984\",\n ELLIPSOID[\"WGS 84\",6378137,298.257223563,\n LENGTHUNIT[\"metre\",1]]],\n PRIMEM[\"Greenwich\",0,\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n ID[\"EPSG\",4326]],\n CONVERSION[\"UTM zone 32N\",\n METHOD[\"Transverse Mercator\",\n ID[\"EPSG\",9807]],\n PARAMETER[\"Latitude of natural origin\",0,\n ANGLEUNIT[\"Degree\",0.0174532925199433],\n ID[\"EPSG\",8801]],\n PARAMETER[\"Longitude of natural origin\",9,\n ANGLEUNIT[\"Degree\",0.0174532925199433],\n ID[\"EPSG\",8802]],\n PARAMETER[\"Scale factor at natural origin\",0.9996,\n SCALEUNIT[\"unity\",1],\n ID[\"EPSG\",8805]],\n PARAMETER[\"False easting\",500000,\n LENGTHUNIT[\"metre\",1],\n ID[\"EPSG\",8806]],\n PARAMETER[\"False northing\",0,\n LENGTHUNIT[\"metre\",1],\n ID[\"EPSG\",8807]]],\n CS[Cartesian,2],\n AXIS[\"(E)\",east,\n ORDER[1],\n LENGTHUNIT[\"metre\",1]],\n AXIS[\"(N)\",north,\n ORDER[2],\n LENGTHUNIT[\"metre\",1]],\n ID[\"EPSG\",32632]]"), class = "crs"), class = c("sfc_MULTIPOLYGON",
"sfc"), precision = 0, bbox = structure(c(xmin = 313279.2522,
ymin = 3933682.9322, xmax = 1312016.151, ymax = 5220292.2928), class = "bbox"))), row.names = c(NA,
-107L), class = c("sf", "data.frame"), sf_column = "geometry", agr = structure(c(COD_RIP = NA_integer_,
COD_REG = NA_integer_, COD_PROV = NA_integer_, COD_CM = NA_integer_,
COD_UTS = NA_integer_, DEN_PROV = NA_integer_, DEN_CM = NA_integer_,
DEN_UTS = NA_integer_, SIGLA = NA_integer_, TIPO_UTS = NA_integer_,
SHAPE_AREA = NA_integer_, Shape_Leng = NA_integer_), class = "factor", levels = c("constant",
"aggregate", "identity")))
This is instead an example of the dataset
`City Name` `Average amount` `Nominal Difference` `%` `Real Wage` `Real Difference`
Barletta 2457 1007 41.0 27.5 11.3
Caserta 2445 910 37.2 27.4 10.2
Avellino 2363 1016 43.0 26.5 11.4
Lecce 2342 981 41.9 26.2 11.0
Benevento 2335 1157 49.6 26.1 13.0
Isernia 2334 1078 46.2 26.1 12.1
L'Aquila 2324 1010 43.5 26.0 11.3
Catanzaro 2310 1533 66.3 25.9 17.2
Campobasso 2259 1106 49.0 25.3 12.4
Enna 2242 922 41.1 25.1 10.3
This is my script
# GEOGRAPHIC MAP
MAP <- right_join(prov2022, dataset, by = "COD_PROV") %>%
ggplot(aes(fill = `Real Difference` >= 10 ))+
geom_sf() +
theme_void() +
scale_fill_manual(values = c('white', 'red'))
#TABLE
TABLE <- subset(cc , `Real Difference` >= 10, c("City Name", "Average amount", "Nominal Difference", "%", "Real Wage", "Real Difference" ))
TABLE <- arrange(TABLE, -`Real Wage`)
TABLE <- tableGrob(TABLE, theme = ttheme_default(base_size = 15))
#PLOTTING TOGETHER
grid.arrange(arrangeGrob(MAP, TABLE, ncol=2))
The script work fine, but there is too much empty space between the MAP on the left and the TABLE of the right, and (as consequence) the table is cut because it goes outside the canvas.
Is there something that I can set in grid.arrange to remove ( or reduce) this space between the 2 plots? or can I directly shift the table a little more on the left to avoid it goes out from tha canvas?
I already know that I can reduce the size of the table setting theme = ttheme_default(base_size = 15)
with a lower values, but in this way all the characters become small and difficult to be read