Section 2.10 Key Functions & Commands
The following functions and commands are introduced or reinforced in this chapter.
-
install.packages()(base R)-
Installs packages from CRAN onto your local machine. This only needs to be done once per package.
-
-
library()(base R)-
Loads an installed package into the current R session so its functions can be used.
-
-
|>(magrittr / tidyverse)-
Passes the result of one operation directly into the next, allowing code to be read from left to right.
-
-
select()(dplyr)-
Chooses specific columns from a dataset.
-
-
filter()(dplyr)-
Keeps rows that meet logical conditions.
-
-
arrange()(dplyr)-
Orders rows based on the values of one or more columns.
-
-
mutate()(dplyr)-
Creates new columns or modifies existing ones.
-
-
rename()(dplyr)-
Changes column names using the format
new_name = old_name.
-
-
distinct()(dplyr)-
Returns unique values or unique combinations of values from one or more columns.
-
-
if_else()(dplyr)-
Creates values based on a binary condition, ensuring consistent data types.
-
-
case_when()(dplyr)-
Handles multiple conditional rules when creating or transforming variables.
-
-
is.na()(base R)-
Identifies missing (
NA) values.
-
-
drop_na()(tidyr)-
Removes rows containing missing values in specified columns.
-
-
count()(dplyr)-
Counts the number of observations for each group in a dataset.
-
-
group_by()(dplyr)-
Groups data so that summary statistics can be calculated separately for each group.
-
-
summarise()(dplyr)-
Computes summary statistics (e.g., means, counts) for grouped data.
-
-
n()(dplyr)-
Returns the number of observations within each group when used inside
summarise().
-
-
sessionInfo()(base R)-
Displays information about the current R session, including loaded packages.
-
-
table()(base R)-
Creates frequency tables for categorical data.
-
