When I ran the following Quarto file
---
title: "Step 2: Data Import and Schema Sanity Check"
author: "Dr. James Daniel"
date: today
format:
html:
toc: true
code-fold: true
execute:
echo: true
warning: false
message: true
---
# Objective
This document performs the **data import and schema inspection** stage of the project *Why Nigerians Left Nigeria – Sentiment Analysis of Public Tweets*.
It ensures the raw dataset is properly read, inspected, documented, and summarized before any cleaning or modeling.
---
## Step 1 – Import the Excel file
```{r}
# ---- Load required libraries ----
library(readxl) # for reading Excel files
library(dplyr) # for data manipulation
library(janitor) # for cleaning column names
library(skimr) # for quick data overview
library(writexl) # for saving data dictionary
library(snakecase) # for checking POSIXt class
library(lubridate) # for checking Date class
```
I get the following error even when all the packages are installed in the right library path:
==> quarto preview 01_data_import_schema_check.qmd --to html --no-watch-inputs --no-browse
processing file: 01_data_import_schema_check.qmd
|................................... | 67% [unnamed-chunk-1]
Error: ! package or namespace load failed for 'janitor' in
loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck =
vI[[j]]): there is no package called 'snakecase' Backtrace:
▆
1. └─base::library(janitor)
2. └─base::tryCatch(...)
3. └─base (local) tryCatchList(expr, classes, parentenv, handlers)
4. └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
5. └─value[[3L]](cond)
Quitting from 01_data_import_schema_check.qmd:23-32 [unnamed-chunk-1]
Execution halted
I created a different Quarto document within the same project as follows:
---
title: "02_data_import_schema_checked"
format: html
---
```{r}
.libPaths()
```
I get the following as a .html file which shows the Quarto file compiles sucessully.
.libPaths()
[1] "C:/Users/USER/OneDrive/Documents/RPACKAGES"
[2] "C:/Program Files/R/R-4.5.2/library"
But when I ran the R chunk of the Quarto document, I got the following:
[1] "C:/Users/USER/Documents/why_nigerians_left_sentiment/renv/library/windows/R-4.5/x86_64-w64-mingw32"
[2] "C:/Users/USER/AppData/Local/R/cache/R/renv/sandbox/windows/R-4.5/x86_64-w64-mingw32/ebc25411"
snakecasepackage installed? If you run this code on the console, does it work without error? If this works on the console but not in quarto, I suggest checking what the apparent paths in.libPaths()are when rendering, and compare that with.libPaths()on your console.# ---- Load required libraries ---- library(readxl) # for reading Excel files library(dplyr) # for data manipulation library(janitor) # for cleaning column names library(skimr) # for quick data overview library(writexl) # for saving data dictionary library(snakecase) # for checking POSIXt class library(lubridate) # for checking Date classhas been installed,.libpaths()inside a quarto document rendering? How does that compare with the same expression on your interactive console?library(..)calls, nothing more. Everything afterread.csv(excel_path)is unreproducible since we don't have your file and irrelevant, since if you get pastlibrary(snakecase)then your issue is resolved. Please reduce the complexity of your question to a single code chunk with just thelibrary(.)calls (and likely my suggested call to.libPaths()before them)..libPaths()check to make sure the paths you use on the console are still there in quarto's R environment.