Carolina Velazquez
04/30/2022
The goal of this assignment is to create a web page document that has an interactive map produced through Leaflet. In order to do so, we start by using The Worlds 50 Best Restaurants of 2018 data set from Kaggle. This data was collected by The Word’s 50 Best, and you can learn more about them here.The World’s 50 Best Restaurants list provides an annual snapshot of the opinions and experiences of 1,080 international restaurant industry experts. It is a globally recognized gastronomic reference point which showcases leading trends and highlights great restaurants from all corners of the Earth.
The original dataset provided by the Kaggle is in csv format. The data is available on this site and I was able to download it in order to create a map.
The_Worlds_50_Best_Restaurants_2018 <- read.csv("~/Downloads/The Worlds 50 Best Restaurants 2018.csv")
Here is the structure of the dataset:
str(The_Worlds_50_Best_Restaurants_2018)
## 'data.frame': 50 obs. of 7 variables:
## $ Year : int 2018 2018 2018 2018 2018 2018 2018 2018 2018 2018 ...
## $ Ranking : int 1 2 3 4 5 6 7 8 9 10 ...
## $ Name : chr "Osteria Francescana" "El Celler de Can Roca" "Mirazur" "Eleven Madison Park" ...
## $ City : chr "Modena" "Girona" "Menton" "New York" ...
## $ Country : chr "Italy" "Spain" "France" "USA" ...
## $ Latitude : num 44.6 42 43.8 40.7 13.8 ...
## $ Longitude: num 10.93 2.82 7.5 -74.01 100.52 ...
This data set provides several useful information regarding the restaraunts. For instance, its name, city,country, longitude, and latitude.For this project, all of the variables are being used for out Leaflet map. Since there are only 50 subjects total, we will not be eliminating any restaurant.
library(leaflet)
## Warning: package 'leaflet' was built under R version 4.0.5
library(htmltools)
map <- The_Worlds_50_Best_Restaurants_2018 %>%
leaflet() %>%
addTiles() %>%
addMarkers(popup=paste
("<br>Country: ",
htmlEscape(The_Worlds_50_Best_Restaurants_2018$Country),
"<br>City: ",
htmlEscape(The_Worlds_50_Best_Restaurants_2018$City),
"<br>Restaurant: ",
htmlEscape(The_Worlds_50_Best_Restaurants_2018$Name),
"<br>Ranking: ",
formatC(The_Worlds_50_Best_Restaurants_2018$Ranking, format = "d", big.mark = ",")))
## Assuming "Longitude" and "Latitude" are longitude and latitude, respectively
map
In this project, we successfully mapped out The Worlds 50 Best Restaurants using Leaflet,one of the most popular Javascript libraries for creating interactive maps. This project is a great example to how simple it can be to use Leaflet to create an interactive map in R.