Rather than View(make_a_map)
have you tried making the last line simply make_a_map
? It looks like make_a_map
is already a leaflet object and just needs to be displayed by calling it directly (see example below).
Find what a function does by typing ?FUNCTION_NAME
in the R command prompt. For example, ?View
brings up the help which says that View()
invokes a spreadsheet-style data viewer on a matrix-like R object. It is for looking at data frames rather than maps.
The leaflet library offers examples of how to construct interactive map visualizations.
library(leaflet)
m <- leaflet() %>%
addTiles() %>% # Add default OpenStreetMap map tiles
addMarkers(lng=174.768, lat=-36.852, popup="The birthplace of R")
m # Print the map
Note how m
is assigned to a leaflet()
object and then simply called in the last line of the code chunk.