Session 7
September 26, 2023
mutate
to convert units of columnssummarize
to calculate group-wise summary statisticspivot_wider
to create cross-tabs# Defining a function
# a_function will be the name of the function
# arguments go within the ()
# code goes in the curly braces
a_function <- function(an_argument) {
# code to execute goes here
# whatever is inside return() comes out of the funciton
return(final_output)
}
# Run the code to create the function
# Then you can use it:
# a_function(<some_input>)
#
if
and ifelse
statements==
for “is equal to”!=
for “not equal to:<
, >
for less than/greater than<=
, >=
for less than or equal to/greater than or equal tois.na()
for is it NA?%in%
for, is this value in a vector of possibilitiesifelse
logic to our data wrangling function