Summary

This is my report for the Week 2 course project for the Creating Data Products course from Johns Hopkins University on Coursera. The assigment was to create a web page using R Markdown that includes a map created using Leaflet.

I have decided to create a map with pointers to all of the stadiums for the teams playing in the 2017-2018 Premier League, the top division of english football. The data for the stadium names and capacities are taken from the Wikipedia page for the above mentioned season. The coordinates were taken from the individual stadium Wikipedia pages and converted to decimal form.

Data and map creation

First we create a data frame with the latitude and longitude for the 20 stadiums.

library(leaflet)
PLstadiums <- data.frame(
        lat = c(51.554901, 50.735199, 50.860901, 53.788799, 51.481602, 51.3983, 53.438702, 53.654301, 52.6203, 53.430801, 53.483002, 53.4631, 54.975601, 50.9058, 52.9884, 51.642799, 51.555901, 51.649799, 52.508999, 51.5383), 
        lng = c(-0.108436, -1.83839, -0.08014, -2.23018, -0.191034, -0.085455, -2.96619, -1.76837, -1.14217, -2.96096, -2.20024, -2.29139, -1.62179, -1.39114, -2.17542, -3.93473, -0.279543, -0.401569, -1.96418,-0.016587))

Next we create popup info for the 20 markers, with a link to the team webpage, stadium name and capacity.

PLpopups <- c(
        "<a href='https://www.arsenal.com'>Arsenal</a></br>Emirates Stadium</br>Capacity 59,867",
        "<a href='https://www.afcb.co.uk'>Bournmouth</a></br>Vitality Stadium</br>Capacity 11,360",
        "<a href='https://www.seagulls.co.uk'>Brighton & Hove Albion</a></br> American Express Stadium</br>Capacity 30,666",
        "<a href='https://www.burnleyfootballclub.com'>Burnley</a></br>Turf Moor</br>Capacity 21,944",
        "<a href='https://www.chelseafc.com/'>Chelsea</a></br>Stamford Bridge</br>Capacity 41,631",
        "<a href='https://www.cpfc.co.uk'>Crystal Palace</a></br>Selhurst Park</br>Capacity 25,456",
        "<a href='https://www.evertonfc.com'>Everton</a></br>Goodison Park</br>Capacity 39,595",
        "<a href='https://www.htafc.com'>Huddersfield Town</a></br>John Smith's Stadium</br>Capacity 24,169",
        "<a href='https://www.lcfc.com'>Leicester City</a></br>King Power Stadium</br>Capacity 32,273",
        "<a href='https://www.liverpoolfc.com'>Liverpool</a></br>Anfield</br>Capacity 53,394",
        "<a href='https://www.mancity.com'>Manchester City</a></br>Etihad Stadium</br>Capacity 55,017",
        "<a href='https://www.manutd.com'>Manchester United</a></br>Old Trafford</br>Capacity 74,994",
        "<a href='https://www.nufc.co.uk'>Newcastle United</a></br>St James' Park</br>Capacity 52,354",
        "<a href='https://www.southamptonfc.com'>Southampton</a></br>St Mary's Stadium</br>Capacity 32,384",
        "<a href='https://www.stokecityfc.com'>Stoke City</a></br>bet365 Stadium</br>Capacity 30,089",
        "<a href='https://www.swanseacity.com'>Swansea City</a></br>Liberty Stadium</br>Capacity 21,088",
        "<a href='https://www.tottenhamhotspur.com'>Tottenham Hotspur</a></br>Wembley Stadium</br>Capacity 90,000",
        "<a href='https://www.watfordfc.com'>Watford</a></br>Vicarage Road</br>Capacity 21,000",
        "<a href='https://www.wba.co.uk'>West Bromwich Albion</a></br>  The Hawthorns</br>Capacity 26,688",
        "<a href='https://www.whufc.com'>West Ham United</a></br>London Stadium</br>Capacity 60,000"
)

Finally we create the leaflet map, add the tiles and the markers including the popup data.

PLstadiums %>%
        leaflet() %>%
        addTiles() %>%
        addMarkers(popup = PLpopups)