Skip to contents

Creates an interactive map with colors

Usage

plot_map(
  dt,
  lng_var,
  lat_var,
  color = NULL,
  color_var = NULL,
  color_palette = NULL,
  label_var = NULL,
  map_provider = "CartoDB",
  radius = 6,
  radius_var = NULL,
  cluster_points = FALSE
)

Arguments

dt

A data.table with the points to show.

lng_var

A character vector indicating the longitude in dt.

lat_var

A character vector indicating the latitude in dt.

color

A character vector to define a custom color for all points.

color_var

A character vector indicating a categorical column in dt.

color_palette

A character selecting the color to use by each level.

label_var

A character vector indicating a categorical column in dt with information .

map_provider

A character vector indicating

radius

A double defining the size of circles to plot.

radius_var

A character vector indicating a numeric column.

cluster_points

If TRUE if we have many points it will stop showing all points and showing the sum by sub-regions.

Value

An interactive map

Examples


dt = data.table::data.table(
  Borough = c("Queens", "Manhattan", "Brooklyn"),
  Zone = c("Steinway", "Highbridge Park", "Canarsie"),
  lat = c(40.77376, 40.84173, 40.64364),
  long = c(-73.90494, -73.9355, -73.90069)
)

plot_map(
  dt,
  lng_var = "long",
  lat_var = "lat",
  color_var = "Borough",
  color_palette = c('Manhattan' = '#e41a1c',
                    'Queens' = '#377eb8',
                    'Brooklyn'= '#4daf4a'),
  label_var = "Zone"
)