## loading the example data
data(monographaR_examples)
monographaR_examples$map_data -> data
head(data)
## running the function with grid
map.table <- mapTable(data, type="grid", resolution=3,
write.output=FALSE)
map.table$table
t(map.table$table)
map.table$grid -> grid
### load world map
library(rnaturalearth)
library(sf)
library(sp)
ne_countries(type="countries", returnclass = "sv") -> wrld_simpl
st_as_sf(wrld_simpl) -> wrld_simpl
as_Spatial(wrld_simpl) -> wrld_simpl
### plot
plot(grid, border="white")
plot(wrld_simpl, add=TRUE)
plot(grid, add=TRUE)
raster::text(grid, grid@data$layer, cex=1)
Run the code above in your browser using DataLab