Failure to Render using here function with read_csv function

Hello,

I am trying to generate an html output using qmd but I am getting an error when using the here to direct to the proper location to read a csv file here function.

df <- read_csv(here("folder1", "folder2", "folder3", "folder4", "fileofinterest.csv"))

This code works to generate df but when I render/knit it generates the following error:

processing file: Homework-1.rmarkdown
|....... | 13% [unnamed-chunk-1]
Quitting from lines at lines 57-71 [unnamed-chunk-1] (Homework-1.rmarkdown)
Error:
! 'C:/Users/self/Documents/folder1/folder2/folder3/folder4/folder1/folder2/folder3/folder4/fileofinterest.csv' does not exist.
Backtrace:

  1. readr::read_csv(...)
  2. vroom (local) <fn>("C:/Users/self/Documents/folder1/folder2/folder3/folder4/folder1/folder2/folder3/folder4/fileofinterest.csv")
  3. vroom:::check_path(path)

I do not know why when rendering/knitting it generates the folder 1 through 4 twice. I am sure it is the read_csv function but do not know how to fix it.

The correct path should be

C:/Users/self/Documents/folder1/folder2/folder3/folder4/fileofinterest.csv

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.

You need to understand what is here::here() returning when you are rendering you document.

It seems the here::here() is already C:/Users/self/Documents/folder1/folder2/folder3/folder4/

This could be of help: Using here with rmarkdown • here