Is there a way in RMarkdown where I can load all packages that I need at once, without having to repeat them in every code chunk?
For example, this is what my code looks like
knitr::opts_chunk$set(warning = FALSE, message = FALSE)
I. Data Import
Importing the csv file and understanding dataset dimensions.
library(readr)
df <- read_csv("df.csv")
dim(df)
II. Data Exploration
How many unique appointments exist in the dataset?
library(dplyr)
df %>%
select(appointment_id) %>%
distinct() %>%
nrow()
How many of those appointments are part of a series?
library(dplyr)
df %>%
select(appointment_id,appointment_set_id) %>%
filter(!is.na(appointment_set_id)) %>%
distinct() %>%
nrow()
Notice that dplyr is repeated twice, and readr once. I'd like to know if all packages can be loaded at once in a single chunk and applied throughout the Markdown?