-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhandson_github_website.qmd
More file actions
122 lines (73 loc) · 3.89 KB
/
handson_github_website.qmd
File metadata and controls
122 lines (73 loc) · 3.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
---
title: "Using the GitHub website"
---
In this section, we will be using the GitHub.com website and demonstrate that you do not need to be a programmer to use version control and edit files on GitHub.
::: {.callout-note collapse=true}
### Don't have a GitHub account?
If you have not already created a GitHub username, please do so now:
- GitHub: <https://github.com>
- Follow optional [advice on choosing your username](https://happygitwithr.com/github-acct.html)
:::
::: {.callout-tip}
### Our asks
### As a Team of two
- Help each other, everyone is bringing different skills! Talk it out!
- Listen to each other; avoid judgment and solutioneering.
- Have fun!
### Prompt
We want to log the information about people's favorite desserts using this repository.
:::
## Create a new repository
- Create a repository using the following [instructions](https://docs.github.com/en/github/getting-started-with-github/create-a-repo) steps 1-6

## Edit the README
We want to make the following changes:
- Replace the title (first line starting with `#`) with something better! Maybe `Favorite Desserts`
- Add your name and your favorite dessert below the title: e.g. ` - Julien: crepes`
```{r echo=FALSE}
knitr::include_graphics("img/github-readme_desserts.png")
```
- Ask your partner what is their favorite desserts and add it to the list
- Think of a relative and their potential favorite desserts and add it to the list; e.g. ` - Sophia: chocolate`
## Commit your changes
- Click _Commit changes_
- Add a descriptive commit message, "add my favorite dessert"
```{r echo=FALSE}
knitr::include_graphics("img/github-commit.png")
```
- Click _Commit changes_ to confirm
```{r commit-button, out.width="20%", echo=FALSE}
knitr::include_graphics("img/github-commit-button.png")
```
## Add a csv file
Download this [csv file](https://raw.githubusercontent.com/brunj7/eds214-handson-ghcollab/main/data/iconic_desserts.csv) about the most iconic desserts in America (according to this website <https://www.eatthis.com/iconic-desserts-united-states/>) to your computer. Note: depending on your web browser settings you might have to right-click on the page and select _Save As_.
- Drag and drop it on the Github web page of your repository to upload it
- Add a short message about the file e.g. `Add iconic_desserts.csv` & hit `Commit changes`
- Your file has been uploaded 🪄. Click on the filename to see it!
You should have something similar to this repo: <https://github.com/brunj7/favorite-desserts>
## Add an R script
This is the script we used to scrape the iconic desserts listing:
```{r getting the data, eval=FALSE, message = FALSE, warning = FALSE}
library(tidyverse)
library(rvest) # use to scrape website content
# Check if that data folder exists and create it if not
dir.create("data", showWarnings = FALSE)
# Read the webpage code
webpage <- read_html("https://www.eatthis.com/iconic-desserts-united-states/")
# Extract the desserts listing
dessert_elements<- html_elements(webpage, "h2")
dessert_listing <- dessert_elements %>%
html_text2() %>% # extracting the text associated with this type of element 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
```
How would you add this code as an R Script to your repository?
- Copy-paste the above code to your favorite text editor
- Save the file as `iconic_desserts.R`
- Drag and drop it on the Github web page of your repository
### Bonus
- Try to edit the csv file directly on GitHub to add your favorite dessert to the iconic list!
***No need to be a programmer to contribute to analytical workflows with GitHub!!***