diff --git a/help.html b/help.html index 7b414f864..a0fe91f80 100644 --- a/help.html +++ b/help.html @@ -347,14 +347,14 @@

Why are my changes not taking effect? It’s making my results look

Here we are creating a new object from an existing one:

new_rivers <- sample(rivers, 5)
 new_rivers
-
## [1]  605  268  800  425 2315
+
## [1]  465 1459  380  390  360

Using just this will only print the result and not actually change new_rivers:

new_rivers + 1
-
## [1]  606  269  801  426 2316
+
## [1]  466 1460  381  391  361

If we want to modify new_rivers and save that modified version, then we need to reassign new_rivers like so:

new_rivers <- new_rivers + 1
 new_rivers
-
## [1]  606  269  801  426 2316
+
## [1]  466 1460  381  391  361

If we forget to reassign this can cause subsequent steps to not work as expected because we will not be working with the data that has been modified.


@@ -403,7 +403,7 @@

Error: object ‘X’ not found

Make sure you run something like this, with the <- operator:

rivers2 <- new_rivers + 1
 rivers2
-
## [1]  607  270  802  427 2317
+
## [1]  467 1461  382  392  362

diff --git a/modules/Functions/lab/Functions_Lab.html b/modules/Functions/lab/Functions_Lab.html index 500223fd9..5efcebac5 100644 --- a/modules/Functions/lab/Functions_Lab.html +++ b/modules/Functions/lab/Functions_Lab.html @@ -168,9 +168,7 @@

Functions Lab

Part 1

Load all the libraries we will use in this lab.

-
library(readr)
-library(dplyr)
-library(ggplot2)
+
library(tidyverse)

1.1

Create a function that takes one argument, a vector, and returns the sum of the vector and squares the result. Call it “sum_squared”. Test your function on the vector c(2,7,21,30,90) - you should get the answer 22500.

@@ -196,6 +194,13 @@

1.4

Create a new number b_num that is not contained with nums. Use your updated has_n function with the default value and add b_num as the n argument when calling the function. What is the outcome?

+
+

Practice on Your Own!

+
+

P.1

+

Take your function from question 1.1 and have it make a print statement describing what the function is doing.

+
+

Part 2

@@ -209,8 +214,14 @@

2.2

data %>% summarize(across( .cols = {vector or tidyselect}, - .fns = {some function}, - {additional arguments} + .fns = {some function}) + )) +

OR

+
# General format
+data %>%
+  summarize(across(
+    .cols = {vector or tidyselect},
+    .fns = \(x) {some function}(x, {additional arguments})
   ))
@@ -222,11 +233,11 @@

2.4

Use across and mutate to convert all columns starting with the word “Total” into a binary variable: TRUE if the value is greater than 10,000,000 and FALSE if less than or equal to 10,000,000. Hint: use starts_with() to select the columns starting with “Total”. Use a “function on the fly” to do a logical test if the value is greater than 10,000,000.

-
+

Practice on Your Own!

-
-

P.1

-

Take your code from question 2.4 and assign it to the variable vacc_dat.

+
+

P.2

+

Take your code from question 2.4 and assign it to the dataset vacc_dat.

  • use filter() to drop any rows where “United States” appears in State/Territory/Federal Entity. Make sure to reassign this to vacc_dat.
  • Create a ggplot boxplot (geom_boxplot()) where (1) the x-axis is Total Doses Delivered and (2) the y-axis is Percent of fully vaccinated people with booster doses.