Please put your answer in the chat!
Housekeeping
Review of {dplyr} Functions
Common Issues and Your Questions
Next Week
If you submitted a project assignment, you should receive an email notification when I give you feedback
I can answer questions relevant to the topic of the week, but can’t answer everything for you
Instead, I will share resources with you where applicable
Check in with me about a good dataset to use!
select()mutate()filter()summarize()group_by() |> summarize()arrange().by argument in summarize()An observation that I am curious about: The group_by with two variables appears to sort the tibble by the first variable alphabetically (island), while the alternative method David showed (i.e., the .by) sorts it by the year in the tibble. Is this always the case or was this simply by chance that this change in sorting of the summary tibble occured?
Which function would you use to keep only certain rows in your data?
filter()select()mutate()arrange()Which function would you use to keep only certain rows in your data?
filter()select()mutate()arrange()
Install packages once per computer
Load packages once per session
I started this video after I closed and reopened Positron, so there is no folder open. There is a message on the left reminding me that no folder is open and asking me to open a folder. Is opening a folder always the first step?
Positron (and RStudio) projects set your working directory to be the root of the project
Using a project, you only need to use relative file paths, not absolute file paths
This is easier to type and more reproducible
What’s the logic for the “-” (minus) in the second solution below being in its own parenthesis but it’s not in the first solution? That tripped me up.
The code above is parsed as:
c(1, 2, 4, 5, 6, 7, 8). That’s 7 elements.body_mass_g evaluates to position 6.: operator only uses the first element of each side, resulting in select(1:6).A relative path can continue to work when an R project is moved to another computer, provided the project’s internal folder structure stays the same.
TRUE
FALSE
A relative path can continue to work when an R project is moved to another computer, provided the project’s internal folder structure stays the same.
TRUE
FALSE
SPSS has named NA values
In R, a value is only NA if it shows up in red (in the console) or light gray (in the data viewer)
You’ll learn later to use functions from the {tidyr} package to deal with missing values:
replace_na() will replace existing NA values with your chosen values
na_if() will replace values you specify with NA
Is there some way to change the default behavior of summarize so that it ignores NAs without having to specify it specifically? I didn’t know if there was something like a global variable that you can set in the R script file, or something within the RStudio environment or installed package?
I went a step further by wanting to round my average and drop the decimals (I noticed some decimal places in my answer). I used mutate and round to change it, but is there any easier or simpler way to format it?
Course assignment: complete data viz lessons
Project assignment: make three plots from your data