library(tidyverse)
library(rvest) # use to scrape website content
# Check if that data folder exists and creates it if not
dir.create("data", showWarnings = FALSE)
# Read the webpage code
<- read_html("https://www.eatthis.com/iconic-desserts-united-states/")
webpage
# Extract the desserts listing
<- html_elements(webpage, "h2")
dessert_elements<- dessert_elements %>%
dessert_listing html_text2() %>% # extracting the text associated with this type of elements of the webpage
as_tibble() %>% # make it a data frame
rename(dessert = value) %>% # better name for the column
head(.,-3) %>% # 3 last ones were not desserts
rowid_to_column("rank") %>% # adding a column using the row number as proxy for the rank
write_csv("data/iconic_desserts.csv") # save it as csv
GitHub branches using RStudio
Is your fav’ dessert iconic !?!
Write and R script to compare the csv with your favorite desserts you modified previously with the top 42 most iconic American desserts
- Clone the repository you just created about your favorite desserts
- Create a new branch using RStudio and name it
*myinitials*_rstudio
- Start a new script named
desserts_match_*myinitials*.R
- As pair programming, write a script should read a csv file of your favorite dessert (create it if you do not have one yet) and the csv file with the most iconic desserts (see code below) into R and find out if your favorite dessert is part of the most iconic desserts!
- Push your changes to GitHub
- On the GitHub website, create a Pull Request (PR) and assign your teammate as reviewer
- Reviewer – Review the PR. Make comments and/or OK the merge
- Requester – Merge and close the PR
Code to get the iconic desserts listing