0

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" 
10
  • 3
    Where do you have the snakecase package 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. Commented Nov 22 at 13:38
  • Every R packages loaded in this section: # ---- 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 has been installed, Commented Nov 22 at 15:47
  • Ok, what shows when you evaluate .libpaths() inside a quarto document rendering? How does that compare with the same expression on your interactive console? Commented Nov 22 at 17:18
  • 3
    Another request: I think this question has far more code than is necessary: if you have a quarto document that has the first chunk with only the library(..) calls, nothing more. Everything after read.csv(excel_path) is unreproducible since we don't have your file and irrelevant, since if you get past library(snakecase) then your issue is resolved. Please reduce the complexity of your question to a single code chunk with just the library(.) calls (and likely my suggested call to .libPaths() before them). Commented Nov 22 at 17:32
  • 1
    This is likely to be closed. Please try the .libPaths() check to make sure the paths you use on the console are still there in quarto's R environment. Commented Nov 24 at 12:37

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.