Peer-graded Assignment: R Markdown and Leaflet

Instruction for Assignment

  1. Create a web page using R Markdown that features a map created with Leaflet.

  2. Host your webpage on either GitHub Pages, RPubs, or NeoCities.

  3. Your webpage must contain the date that you created the document, and it must contain a map created with Leaflet. We would love to see you show off your creativity!

Note: This assignment have done on R Studio Cloud.

Using required Packages

library(leaflet)
library(htmltools)

Accessing the data from .csv text file

From Kagle: Dataset about the best restaurants in the world. By Megh Mayur.

Contains the list of The World’s 50 Best Restaurants for 2018

(https://www.kaggle.com/mmayur/the-worlds-50-best-restaurants)

##setwd("/Cloud/project")
datamap <- read.csv(file = "TheWorlds50BestRestaurants2018.csv", header = TRUE, sep = ",")

Creating my data frame in order to manipulate the dataset like a table.

restaurant_lists <- data.frame(Ranking = datamap$Ranking,
                     Name = datamap$Name,
                     City = datamap$City,
                     Country = datamap$Country,
                     Latitude = datamap$Latitude,
                     Longitude = datamap$Longitude
                     )

present lists of 1st - 50th restaurants.

restaurant_lists
##    Ranking                             Name             City      Country
## 1        1              Osteria Francescana           Modena        Italy
## 2        2            El Celler de Can Roca           Girona        Spain
## 3        3                          Mirazur           Menton       France
## 4        4              Eleven Madison Park         New York          USA
## 5        5                           Gaggan          Bangkok     Thailand
## 6        6                          Central             Lima         Peru
## 7        7                            Maido             Lima         Peru
## 8        8                           Arpège            Paris       France
## 9        9                         Mugaritz    San Sebastian        Spain
## 10      10                 Asador Etxebarri             Axpe        Spain
## 11      11                        Quintonil      Mexico City       Mexico
## 12      12         Blue Hill at Stone Barns  Pocantico Hills          USA
## 13      13                            Pujol      Mexico City       Mexico
## 14      14                       Steirereck           Vienna      Austria
## 15      15                     White Rabbit           Moscow       Russia
## 16      16                     Piazza Duomo             Alba        Italy
## 17      17                              Den            Tokyo        Japan
## 18      18                        Disfrutar        Barcelona        Spain
## 19      19                         Geranium       Copenhagen      Denmark
## 20      20                           Attica        Melbourne    Australia
## 21      21   Alain Ducasse au Plaza Athénée            Paris       France
## 22      22                         Narisawa            Tokyo        Japan
## 23      23                      Le Calandre           Rubano        Italy
## 24      24       Ultraviolet by Paul Pairet         Shanghai        China
## 25      25                            Cosme         New York          USA
## 26      26                     Le Bernardin         New York          USA
## 27      27                           Boragó         Santiago        Chile
## 28      28                           Odette        Singapore    Singapore
## 29      29 Alléno Paris au Pavillon Ledoyen            Paris       France
## 30      30                           D.O.M.        São Paulo       Brazil
## 31      31                            Arzak    San Sebastian        Spain
## 32      32                          Tickets        Barcelona        Spain
## 33      33                   The Clove Club           London           UK
## 34      34                           Alinea          Chicago          USA
## 35      35                           Maaemo             Oslo       Norway
## 36      36                            Reale Castel di Sangro        Italy
## 37      37              Restaurant Tim Raue           Berlin      Germany
## 38      38                           Lyle's           London           UK
## 39      39                  Astrid y Gastón             Lima         Peru
## 40      40                          Septime            Paris       France
## 41      41                Nihonryori RyuGin            Tokyo        Japan
## 42      42                      The Ledbury           London           UK
## 43      43                        Azurmendi       Larrabetzu        Spain
## 44      44                            Mikla         Istanbul       Turkey
## 45      45      Dinner by Heston Blumenthal           London           UK
## 46      46                           Saison    San Francisco          USA
## 47      47             Schloss Schauenstein        Fürstenau  Switzerland
## 48      48                      Hiša Franko          Kobarid     Slovenia
## 49      49                             Nahm          Bangkok     Thailand
## 50      50                 The Test Kitchen        Cape Town South Africa
##     Latitude   Longitude
## 1   44.64310   10.934100
## 2   41.98080    2.818700
## 3   43.77470    7.504600
## 4   40.71460  -74.007100
## 5   13.75000  100.516000
## 6  -12.04300  -77.028000
## 7  -12.04300  -77.028000
## 8   48.85690    2.341200
## 9   43.31740   -1.978400
## 10  43.13000   -2.583611
## 11  19.42850  -99.127700
## 12  41.09444  -73.835833
## 13  19.42850  -99.127700
## 14  48.20250   16.368800
## 15  55.75200   37.615000
## 16  44.69610    8.034100
## 17  35.62490  139.585600
## 18  41.38750    2.168400
## 19  55.67500   12.565000
## 20 -37.81400  144.963000
## 21  48.85690    2.341200
## 22  35.62490  139.585600
## 23  45.43333   11.783333
## 24  31.22200  121.458000
## 25  40.71460  -74.007100
## 26  40.71460  -74.007100
## 27 -33.42600  -70.566000
## 28   1.28900  103.850000
## 29  48.85690    2.341200
## 30 -23.54700  -46.636000
## 31  43.31740   -1.978400
## 32  41.38750    2.168400
## 33  51.50640   -0.127200
## 34  41.88430  -87.632400
## 35  59.91200   10.746000
## 36  41.78333   14.100000
## 37  52.51610   13.377000
## 38  51.50640   -0.127200
## 39 -12.04300  -77.028000
## 40  48.85690    2.341200
## 41  35.62490  139.585600
## 42  51.50640   -0.127200
## 43  43.26194   -2.794722
## 44  41.01300   28.949000
## 45  51.50640   -0.127200
## 46  37.77710 -122.419600
## 47  46.71667    9.433333
## 48  46.24644   13.578006
## 49  13.75000  100.516000
## 50 -33.91600   18.416000

Activating the Map

restaurant_on_map <- restaurant_lists %>%
  leaflet() %>%
  addTiles() %>%
  addMarkers(popup=paste
             ("<br>Country: ", 
               htmlEscape(restaurant_lists$Country), 
              "<br>City: ", 
               htmlEscape(restaurant_lists$City), 
              "<br>Restaurant: ", 
               htmlEscape(restaurant_lists$Name),
              "<br>Ranking: ",
               formatC(datamap$Ranking, format = "d", big.mark = ",")
              ) 
            )
## Assuming "Longitude" and "Latitude" are longitude and latitude, respectively

Present the map about The location of The Worlds 50 Best Restaurants in 2018

restaurant_on_map