Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spring cleaning for 2023 🧼 #68

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion chapters/chapter1.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ The first time you run a code exercise, it may take a little while for your Dock

**Wherever you see `___` in a code exercise, replace it with the correct code as instructed. Run the code (via the button) to see if it will run, and submit it (via the other button) to check if it's correct.**

The `tidyverse` metapackage is loaded for you, so you can use readr and ggplot2.
The tidyverse metapackage is loaded for you, so you can use ggplot2 and other functions for exploratory data analysis. The arrow package is also loaded, so you can read our data stored as a [Parquet](https://parquet.apache.org/) file.

- Take a look at the `cars2018` object using `glimpse()`.
- Use the appropriate column from the data set in the call to `aes()` so you can plot a histogram of fuel efficiency (miles per gallon, `mpg`).
Expand Down
Binary file added data/c1_car_vars.parquet
Binary file not shown.
Binary file removed data/c1_car_vars.rds
Binary file not shown.
Binary file modified data/c1_fit_lm.rds
Binary file not shown.
Binary file modified data/c1_fit_rf.rds
Binary file not shown.
Binary file modified data/c1_lm_res.rds
Binary file not shown.
Binary file modified data/c1_rf_res.rds
Binary file not shown.
Binary file added data/c1_test.parquet
Binary file not shown.
Binary file removed data/c1_test.rds
Binary file not shown.
Binary file added data/c1_train.parquet
Binary file not shown.
Binary file removed data/c1_train.rds
Binary file not shown.
Binary file added data/c1_train_10_percent.parquet
Binary file not shown.
Binary file removed data/c1_train_10_percent.rds
Binary file not shown.
3 changes: 2 additions & 1 deletion exercises/exc_01_03.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
library(tidyverse)
cars2018 <- read_csv("data/cars2018.csv")
library(arrow)
cars2018 <- read_parquet("data/cars2018.parquet")

# Print the cars2018 object
glimpse(___)
Expand Down
3 changes: 2 additions & 1 deletion exercises/exc_01_04.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
library(tidyverse)
cars2018 <- read_csv("data/cars2018.csv")
library(arrow)
cars2018 <- read_parquet("data/cars2018.parquet")

# Deselect the 2 columns to create cars_vars
car_vars <- cars2018 %>%
Expand Down
3 changes: 2 additions & 1 deletion exercises/exc_01_06.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
car_vars <- readRDS("data/c1_car_vars.rds")
library(arrow)
car_vars <- read_parquet("data/c1_car_vars.parquet")

# Load tidymodels
___
Expand Down
5 changes: 3 additions & 2 deletions exercises/exc_01_07_1.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
car_train <- readRDS("data/c1_train.rds")
car_test <- readRDS("data/c1_test.rds")
library(arrow)
car_train <- read_parquet("data/c1_train.parquet")
car_test <- read_parquet("data/c1_test.parquet")

# Load tidymodels
___
Expand Down
6 changes: 3 additions & 3 deletions exercises/exc_01_07_2.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
library(tidymodels)

car_train <- readRDS("data/c1_train.rds")
car_test <- readRDS("data/c1_test.rds")
library(arrow)
car_train <- read_parquet("data/c1_train.parquet")
car_test <- read_parquet("data/c1_test.parquet")

# Build a random forest model specification
rf_mod <- ___ %>%
Expand Down
8 changes: 5 additions & 3 deletions exercises/exc_01_08.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
car_train <- readRDS("data/c1_train.rds")
fit_lm <- readRDS("data/c1_fit_lm.rds")
fit_rf <- readRDS("data/c1_fit_rf.rds")
library(tidyverse)
library(arrow)
car_train <- read_parquet("data/c1_train.parquet")
fit_lm <- read_rds("data/c1_fit_lm.rds")
fit_rf <- read_rds("data/c1_fit_rf.rds")

# Load tidymodels
library(___)
Expand Down
8 changes: 4 additions & 4 deletions exercises/exc_01_09.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
library(tidymodels)

car_test <- readRDS("data/c1_test.rds")
fit_lm <- readRDS("data/c1_fit_lm.rds")
fit_rf <- readRDS("data/c1_fit_rf.rds")
library(tidyverse)
car_test <- read_parquet("data/c1_test.parquet")
fit_lm <- read_rds("data/c1_fit_lm.rds")
fit_rf <- read_rds("data/c1_fit_rf.rds")

# Create the new columns
results <- ___ %>%
Expand Down
4 changes: 2 additions & 2 deletions exercises/exc_01_11.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
library(tidymodels)

car_train <- readRDS("data/c1_train_10_percent.rds")
library(arrow)
car_train <- read_parquet("data/c1_train_10_percent.parquet")

lm_mod <- linear_reg() %>%
set_engine("lm")
Expand Down
5 changes: 3 additions & 2 deletions exercises/exc_01_12_1.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
library(tidyverse)
library(tidymodels)

lm_res <- readRDS("data/c1_lm_res.rds")
rf_res <- readRDS("data/c1_rf_res.rds")
lm_res <- read_rds("data/c1_lm_res.rds")
rf_res <- read_rds("data/c1_rf_res.rds")

results <- bind_rows(___ %>%
collect_predictions() %>%
Expand Down
5 changes: 3 additions & 2 deletions exercises/exc_01_12_2.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
library(tidyverse)
library(tidymodels)

lm_res <- readRDS("data/c1_lm_res.rds")
rf_res <- readRDS("data/c1_rf_res.rds")
lm_res <- read_rds("data/c1_lm_res.rds")
rf_res <- read_rds("data/c1_rf_res.rds")

results <- bind_rows(lm_res %>%
collect_predictions() %>%
Expand Down
3 changes: 2 additions & 1 deletion exercises/solution_01_03.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
library(tidyverse)
cars2018 <- read_csv("data/cars2018.csv")
library(arrow)
cars2018 <- read_parquet("data/cars2018.parquet")

# Print the cars2018 object
glimpse(cars2018)
Expand Down
3 changes: 2 additions & 1 deletion exercises/solution_01_04.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
library(tidyverse)
cars2018 <- read_csv("data/cars2018.csv")
library(arrow)
cars2018 <- read_parquet("data/cars2018.parquet")

# Deselect the 2 columns to create cars_vars
car_vars <- cars2018 %>%
Expand Down
3 changes: 2 additions & 1 deletion exercises/solution_01_06.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
car_vars <- readRDS("data/c1_car_vars.rds")
library(arrow)
car_vars <- read_parquet("data/c1_car_vars.parquet")

# Load tidymodels
library(tidymodels)
Expand Down
5 changes: 3 additions & 2 deletions exercises/solution_01_07_1.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
car_train <- readRDS("data/c1_train.rds")
car_test <- readRDS("data/c1_test.rds")
library(arrow)
car_train <- read_parquet("data/c1_train.parquet")
car_test <- read_parquet("data/c1_test.parquet")

# Load tidymodels
library(tidymodels)
Expand Down
6 changes: 3 additions & 3 deletions exercises/solution_01_07_2.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
library(tidymodels)

car_train <- readRDS("data/c1_train.rds")
car_test <- readRDS("data/c1_test.rds")
library(arrow)
car_train <- read_parquet("data/c1_train.parquet")
car_test <- read_parquet("data/c1_test.parquet")

# Build a random forest model specification
rf_mod <- rand_forest() %>%
Expand Down
8 changes: 5 additions & 3 deletions exercises/solution_01_08.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
car_train <- readRDS("data/c1_train.rds")
fit_lm <- readRDS("data/c1_fit_lm.rds")
fit_rf <- readRDS("data/c1_fit_rf.rds")
library(tidyverse)
library(arrow)
car_train <- read_parquet("data/c1_train.parquet")
fit_lm <- read_rds("data/c1_fit_lm.rds")
fit_rf <- read_rds("data/c1_fit_rf.rds")

# Load tidymodels
library(tidymodels)
Expand Down
8 changes: 4 additions & 4 deletions exercises/solution_01_09.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
library(tidymodels)

car_test <- readRDS("data/c1_test.rds")
fit_lm <- readRDS("data/c1_fit_lm.rds")
fit_rf <- readRDS("data/c1_fit_rf.rds")
library(tidyverse)
car_test <- read_parquet("data/c1_test.parquet")
fit_lm <- read_rds("data/c1_fit_lm.rds")
fit_rf <- read_rds("data/c1_fit_rf.rds")

# Create the new columns
results <- car_test %>%
Expand Down
4 changes: 2 additions & 2 deletions exercises/solution_01_11.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
library(tidymodels)

car_train <- readRDS("data/c1_train_10_percent.rds")
library(arrow)
car_train <- read_parquet("data/c1_train_10_percent.parquet")

lm_mod <- linear_reg() %>%
set_engine("lm")
Expand Down
5 changes: 3 additions & 2 deletions exercises/solution_01_12_1.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
library(tidyverse)
library(tidymodels)

lm_res <- readRDS("data/c1_lm_res.rds")
rf_res <- readRDS("data/c1_rf_res.rds")
lm_res <- read_rds("data/c1_lm_res.rds")
rf_res <- read_rds("data/c1_rf_res.rds")

results <- bind_rows(lm_res %>%
collect_predictions() %>%
Expand Down
5 changes: 3 additions & 2 deletions exercises/solution_01_12_2.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
library(tidyverse)
library(tidymodels)

lm_res <- readRDS("data/c1_lm_res.rds")
rf_res <- readRDS("data/c1_rf_res.rds")
lm_res <- read_rds("data/c1_lm_res.rds")
rf_res <- read_rds("data/c1_rf_res.rds")

results <- bind_rows(lm_res %>%
collect_predictions() %>%
Expand Down