Can anyone explain what's the problem here?

pw_2020 <- here("data", "panel_wave_2020.xlsx")
panel_wave_2020 <- read_excel("pw_2020")

library("here")
here() starts at C:/Users/SMO/OneDrive/files

library("tidyverse")
── Attaching packages ───────── tidyverse 1.3.2 ──:heavy_check_mark: ggplot2 3.4.0 :heavy_check_mark: purrr 1.0.1
:heavy_check_mark: tibble 3.1.8 :heavy_check_mark: dplyr 1.0.10
:heavy_check_mark: tidyr 1.3.0 :heavy_check_mark: stringr 1.5.0
:heavy_check_mark: readr 2.1.3 :heavy_check_mark: forcats 0.5.2 ── Conflicts ──────────── tidyverse_conflicts() ──
:heavy_multiplication_x: dplyr::filter() masks stats::filter()
:heavy_multiplication_x: dplyr::lag() masks stats::lag()
library("readxl")
library("readr")
library("dplyr")
library("knitr")
knitr::opts_chunk$set(echo = TRUE)
summary(cars)
speed dist
Min. : 4.0 Min. : 2.00
1st Qu.:12.0 1st Qu.: 26.00
Median :15.0 Median : 36.00
Mean :15.4 Mean : 42.98
3rd Qu.:19.0 3rd Qu.: 56.00
Max. :25.0 Max. :120.00
plot(pressure)

library("here")
library("tidyverse")
library("readxl")
library("readr")
library("dplyr")
library("knitr")
pw_2020 <- here("data", "panel_wave_2020.xlsx")
panel_wave_2020 <- read_excel("pw_2020")
Error: path does not exist: ‘pw_2020’

It looks like you need to drop the quotes:   panel_wave_2020 <- read_excel(pw_2020)

What about this?
pw_2020_path <- here("data","panel_wave_2020.xlsx")

panel_wave_2020 <- read_excel(pw_2020_path)
Error: path does not exist: ‘C:/Users/SMO/OneDrive/files/data/panel_wave_2020.xlsx’

I have tried 2 paths to save the excel files:

  1. C:/Users/SMO/OneDrive/files/data/panel_wave_2020.xlsx

or

  1. C:\Program Files\RStudio\wd_uebung5

For both did the same error occur.

Can I change the location where the function here() starts at? Currently it starts at C:/Users/SMO/OneDrive/files, and it has been downloaded to a default folder.

According to the documentation, the project root can be changed using here::i_am(), but it is not recommended.

A couple other things to try/check:

  • Is the file extension .xls and not .xlsx? (this has bitten me before)
  • Try using here::here() to avoid a conflict with another package that may be exporting here()

This topic was automatically closed 21 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.