Learn R Programming

mlspatial (version 0.1.1)

plot_single_map: Build a tmap for a single variable

Description

Creates a thematic map using the tmap package for a single variable in an sf object.

Usage

plot_single_map(sf_data, var, title, palette = "reds")

Value

A tmap object representing the thematic map.

Arguments

sf_data

An sf object containing spatial data.

var

Variable name as a string to map.

title

Legend title for the fill legend.

palette

Color palette for the map (default is "reds").

Examples

Run this code
# \donttest{
library(sf)
# Create example sf object
nc <- st_read(system.file("shape/nc.shp", package = "sf"), quiet = TRUE)
nc$incidence <- runif(nrow(nc), 0, 100)

# Plot
p1 <- plot_single_map(nc, "incidence", "Incidence")
# }

Run the code above in your browser using DataLab