diff --git a/help.html b/help.html index 7b414f864..a0fe91f80 100644 --- a/help.html +++ b/help.html @@ -347,14 +347,14 @@
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.
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
Load all the libraries we will use in this lab.
-library(readr)
-library(dplyr)
-library(ggplot2)
+library(tidyverse)
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.
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?
Take your function from question 1.1 and have it make a print statement describing what the function is doing.
+OR
+# General format
+data %>%
+ summarize(across(
+ .cols = {vector or tidyselect},
+ .fns = \(x) {some function}(x, {additional arguments})
))
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.
Take your code from question 2.4 and assign it to the variable vacc_dat
.
Take your code from question 2.4 and assign it to the dataset vacc_dat
.
filter()
to drop any rows where “United States” appears in State/Territory/Federal Entity
. Make sure to reassign this to vacc_dat
.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
.