Skip to content

Commit

Permalink
Merge branch 'gh-pages' into func_prog_22
Browse files Browse the repository at this point in the history
  • Loading branch information
carriewright11 authored Jul 27, 2022
2 parents f09c1cb + 1546947 commit 78ec2ed
Show file tree
Hide file tree
Showing 15 changed files with 747 additions and 1,399 deletions.
4 changes: 2 additions & 2 deletions index.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ https://github.com/SISBID/Module1/blob/gh-pages/getting_started.md
[61]: labs/functional-program-lab-key.html
[62]: lecture_notes/Bioconductor_intro.html
[63]: lecture_notes/Bioconductor_intro.pdf
[64]: https://docs.google.com/presentation/d/1GQVit8AtSVhzGShtU95wt6uFma3ibFScwCJRQQVFe4w/edit?usp=sharing
[65]: lecture_notes/sisbid_wrap_up_2021.pdf
[64]: https://docs.google.com/presentation/d/11O06195n5LQJPqKQgf1L-zXnk7LwlK66Tc-qQFLNTjU/edit?usp=sharing
[65]: lecture_notes/sisbid_wrap_up_2022.pdf

**Miscellaneous**

Expand Down
6 changes: 4 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -647,8 +647,8 @@ <h2>Data Wrangling with R</h2>
</tr>
<tr class="even">
<td></td>
<td><a href="https://docs.google.com/presentation/d/1GQVit8AtSVhzGShtU95wt6uFma3ibFScwCJRQQVFe4w/edit?usp=sharing">Wrap
Up</a> (<a href="lecture_notes/sisbid_wrap_up_2021.pdf">PDF</a>)</td>
<td><a href="https://docs.google.com/presentation/d/11O06195n5LQJPqKQgf1L-zXnk7LwlK66Tc-qQFLNTjU/edit?usp=sharing">Wrap
Up</a> (<a href="lecture_notes/sisbid_wrap_up_2022.pdf">PDF</a>)</td>
<td></td>
<td></td>
</tr>
Expand All @@ -657,7 +657,9 @@ <h2>Data Wrangling with R</h2>
<p><strong>Miscellaneous</strong></p>
<p>Feel free to submit typos/errors/etc via the github repository
associated with the class: <a href="https://github.com/SISBID/Data-Wrangling" class="uri">https://github.com/SISBID/Data-Wrangling</a></p>

<p>This page was last updated on 2022-07-27 10:51:34 Eastern Time.</p>

</div>


Expand Down
40 changes: 22 additions & 18 deletions labs/advanced-io-lab-key.R
Original file line number Diff line number Diff line change
@@ -1,45 +1,49 @@
## ---- include=FALSE-----------------------------------------------------------
## ---- include=FALSE------------------------------------------------------------------------------------------------------------------
library(tidyverse)
library(httr)
library(jsonlite)
library(googlesheets4)


## -----------------------------------------------------------------------------
sheet_url = "https://docs.google.com/spreadsheets/d/1KIRtcPVn58R3_qr97WNtcOJiY4AaytHzGDzLW_3_R1s/edit?usp=sharing"
## ----eval=FALSE----------------------------------------------------------------------------------------------------------------------
gs4_auth()


## -----------------------------------------------------------------------------
x = googlesheets4::read_sheet(sheet_url)
## ------------------------------------------------------------------------------------------------------------------------------------
sheet_url <- "https://docs.google.com/spreadsheets/d/1KIRtcPVn58R3_qr97WNtcOJiY4AaytHzGDzLW_3_R1s/edit?usp=sharing"


## -----------------------------------------------------------------------------
googlesheets4::sheet_names(sheet_url)
## ------------------------------------------------------------------------------------------------------------------------------------
x <- read_sheet(sheet_url)


## -----------------------------------------------------------------------------
googlesheets4::read_sheet(sheet_url, range = cell_cols(1:2))
googlesheets4::read_sheet(sheet_url, range = cell_cols("A:B"))
## ------------------------------------------------------------------------------------------------------------------------------------
sheet_names(sheet_url)


## -----------------------------------------------------------------------------
jsonData = fromJSON("https://think.cs.vt.edu/corgis/datasets/json/airlines/airlines.json")
## ------------------------------------------------------------------------------------------------------------------------------------
read_sheet(sheet_url, range = cell_cols("A:B"))


## ---- error = TRUE------------------------------------------------------------
## ------------------------------------------------------------------------------------------------------------------------------------
jsonData <- fromJSON("https://think.cs.vt.edu/corgis/datasets/json/airlines/airlines.json")


## ---- error = TRUE-------------------------------------------------------------------------------------------------------------------
str(jsonData)


## -----------------------------------------------------------------------------
lga_ord = jsonData %>%
## ------------------------------------------------------------------------------------------------------------------------------------
lga_ord <- jsonData %>%
filter(Airport$Code %in% c("LGA", "ORD") & Time$Year == 2016)


## -----------------------------------------------------------------------------
airport_compare = as_tibble(list(
## ------------------------------------------------------------------------------------------------------------------------------------
airport_list <- list(
airport_code = lga_ord$Airport$Code,
total_flights = lga_ord$Statistics$Flights$Total,
delayed_proportion = lga_ord$Statistics$Flights$Delayed / lga_ord$Statistics$Flights$Total
))
)
airport_compare <- as_tibble(airport_list)
airport_compare

34 changes: 20 additions & 14 deletions labs/advanced-io-lab-key.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,34 @@ library(googlesheets4)

This is a lab to practice with Google Sheets and the `googlesheets` package.

Make sure you go through the authentication process. You'll see a popup and will need to grant permissions.

```{r eval=FALSE}
gs4_auth()
```

1. We are going to use a sheet from previous years: https://docs.google.com/spreadsheets/d/1KIRtcPVn58R3_qr97WNtcOJiY4AaytHzGDzLW_3_R1s/edit?usp=sharing

```{r}
sheet_url = "https://docs.google.com/spreadsheets/d/1KIRtcPVn58R3_qr97WNtcOJiY4AaytHzGDzLW_3_R1s/edit?usp=sharing"
sheet_url <- "https://docs.google.com/spreadsheets/d/1KIRtcPVn58R3_qr97WNtcOJiY4AaytHzGDzLW_3_R1s/edit?usp=sharing"
```


2. Use the `googlesheets4::read_sheet` function to read in the data like we discussed in class, call this object `x`.
2. Use the `read_sheet()` function to read in the data like we discussed in class, call this object `x`.

```{r}
x = googlesheets4::read_sheet(sheet_url)
x <- read_sheet(sheet_url)
```

3. Using `sheet_names` function to get the sheet names from the `sheet_url`.

```{r}
googlesheets4::sheet_names(sheet_url)
sheet_names(sheet_url)
```


4. Try reading in just the first two columns. See the `range` argument and look at the arguments for `cell_rows`, `cell_limits` and `cell_cols`.
4. Try reading in just the first two columns. Use the `range = cell_cols()` argument.

```{r}
googlesheets4::read_sheet(sheet_url, range = cell_cols(1:2))
googlesheets4::read_sheet(sheet_url, range = cell_cols("A:B"))
read_sheet(sheet_url, range = cell_cols("A:B"))
```

## JSON Lab
Expand All @@ -52,7 +55,7 @@ The following dataset lists airports in the US and details about the number of l
1. Read in data from the following link: https://think.cs.vt.edu/corgis/datasets/json/airlines/airlines.json. Call this `jsonData`.

```{r}
jsonData = fromJSON("https://think.cs.vt.edu/corgis/datasets/json/airlines/airlines.json")
jsonData <- fromJSON("https://think.cs.vt.edu/corgis/datasets/json/airlines/airlines.json")
```

2. Investigate the data. What are the three main items in `jsonData`?
Expand All @@ -64,17 +67,20 @@ str(jsonData)
3. Filter `jsonData` to include only NYC LaGuardia and Chicago O'Hare airports (Code : "LGA", "ORD") and Year : 2016. Call this `lga_ord`.

```{r}
lga_ord = jsonData %>%
lga_ord <- jsonData %>%
filter(Airport$Code %in% c("LGA", "ORD") & Time$Year == 2016)
```

4. Create a new tibble out of Airport Code (`Airport$Code`), Total Flights (`Statistics$Flights$Total`), and create a new column for proportion of delayed flights using (`Statistics$Flights$Delayed`). Call this new tibble `airport_compare`.
**Bonus Practice**

Create a new tibble out of Airport Code (`Airport$Code`), Total Flights (`Statistics$Flights$Total`), and create a new column for proportion of delayed flights using (`Statistics$Flights$Delayed`). Call this new tibble `airport_compare`.

```{r}
airport_compare = as_tibble(list(
airport_list <- list(
airport_code = lga_ord$Airport$Code,
total_flights = lga_ord$Statistics$Flights$Total,
delayed_proportion = lga_ord$Statistics$Flights$Delayed / lga_ord$Statistics$Flights$Total
))
)
airport_compare <- as_tibble(airport_list)
airport_compare
```
200 changes: 97 additions & 103 deletions labs/advanced-io-lab-key.html

Large diffs are not rendered by default.

22 changes: 14 additions & 8 deletions labs/advanced-io-lab.Rmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: "Advanced IO lab key"
title: "Advanced IO lab"
output: html_document
editor_options:
chunk_output_type: console
Expand All @@ -16,14 +16,19 @@ library(googlesheets4)

This is a lab to practice with Google Sheets and the `googlesheets` package.

1. We are going to use a sheet from previous years: https://docs.google.com/spreadsheets/d/1KIRtcPVn58R3_qr97WNtcOJiY4AaytHzGDzLW_3_R1s/edit?usp=sharing
Make sure you go through the authentication process. You'll see a popup and will need to grant permissions.

```{r eval=FALSE}
gs4_auth()
```

1. We are going to use a sheet from previous years: https://docs.google.com/spreadsheets/d/1KIRtcPVn58R3_qr97WNtcOJiY4AaytHzGDzLW_3_R1s/edit?usp=sharing. Save this link string as "sheet_url".

```{r}
```


2. Use the `googlesheets4::read_sheet` function to read in the data like we discussed in class, call this object `x`.
2. Use the `read_sheet()` function to read in the data like we discussed in class, call this object `x`.

```{r}
Expand All @@ -35,8 +40,7 @@ This is a lab to practice with Google Sheets and the `googlesheets` package.
```


4. Try reading in just the first two columns. See the `range` argument and look at the arguments for `cell_rows`, `cell_limits` and `cell_cols`.
4. Try reading in just the first two columns. Use the `range = cell_cols()` argument.

```{r}
Expand All @@ -48,7 +52,7 @@ This is a lab to practice with Google Sheets and the `googlesheets` package.

The following dataset lists airports in the US and details about the number of late flights over time.

1. Read in data from the following link: https://think.cs.vt.edu/corgis/datasets/json/airlines/airlines.json. Call this `jsonData`.
1. Read in data from the following link using the `fromJSON()` function: https://think.cs.vt.edu/corgis/datasets/json/airlines/airlines.json. Call this `jsonData`.

```{r}
Expand All @@ -66,7 +70,9 @@ The following dataset lists airports in the US and details about the number of l
```

4. Create a new tibble out of Airport Code (`Airport$Code`), Total Flights (`Statistics$Flights$Total`), and create a new column for proportion of delayed flights using (`Statistics$Flights$Delayed`). Call this new tibble `airport_compare`.
**Bonus Practice**

Create a new tibble out of Airport Code (`Airport$Code`), Total Flights (`Statistics$Flights$Total`), and create a new column for proportion of delayed flights using (`Statistics$Flights$Delayed`). Call this new tibble `airport_compare`.

```{r}
Expand Down
Loading

0 comments on commit 78ec2ed

Please sign in to comment.