DATE: 28th march 2018

R Markdown and leaflet

This is my first map with some of the metro stations in Madrid.

library(leaflet)
## Warning: package 'leaflet' was built under R version 3.3.3
my_map <- leaflet() %>% 
        addTiles()
my_map
library(leaflet)
nycIcon <- makeIcon(
    iconUrl = "https://seeklogo.com/images/M/Metro_Madrid-logo-4586FB71C7-seeklogo.com.png",
    iconWidth = 50*215/230, iconHeight = 25,
    iconAnchorX = 20*215/230/2, iconAnchorY = 16
  )
  
 
nycLatLong <- data.frame(
    lat = c(40.446198,40.458352,40.453887),
    lng = c(-3.692332, -3.690316,-3.702896 ))
  
nycLatLong %>% 
    leaflet() %>%
    addTiles() %>%
    addMarkers(icon = nycIcon)
metroSites <- c(
    "<a href='https://es.wikipedia.org/wiki/Nuevos_Ministerios/'> Nuevos ministerios</a>",
    "<a href='https://es.wikipedia.org/wiki/Plaza_de_Cuzco/'> Cuzco</a>",
    "<a href='https://es.wikipedia.org/wiki/Estaci%C3%B3n_de_Estrecho/'> Estrecho </a>"
  )
  
nycLatLong %>% 
    leaflet() %>%
    addTiles() %>%
    addMarkers(icon = nycIcon, popup = metroSites)