I used the following script to install the missing libraries:
# Set the CRAN mirror (you can choose a different mirror if needed)
options(repos = c(CRAN = "https://cloud.r-project.org"))
# List of required packages
required_packages <- c("tidyverse", "arrow", "dbplyr", "duckdb", "scales",
"ggrepel", "patchwork", "nycflights13", "palmerpenguins",
"ggthemes", "DBI", "tidymodels", "ggridges", "leaflet",
"shiny", "repurrrsive", "jsonlite", "babynames", "readxl",
"writexl", "googlesheets4", "rvest", "dplyr")
# Function to check and install missing packages
install_if_missing <- function(packages) {
installed <- installed.packages()[, "Package"]
for (pkg in packages) {
if (!pkg %in% installed) {
install.packages(pkg, dependencies = TRUE)
}
}
}
# Install missing packages
install_if_missing(required_packages)
As suggested by @Matt-Summersgill, I used to following options in _quarto.yml:
project:
type: book
output-dir: _book
execute:
freeze: true
cache: true
book:
title: "R for Data Science (2e)"
reader-mode: true
# ...