How fix here function on my setwd

Hello Everyone, I’m working with here package for managing my path datasources, so I have a worry when I use here(“path_file_csv”) I have a message :

cannot open file ‘/Users/m2/Library/Application Support/JetBrains/DataSpell2022.3/projects/workspace/extracts/test.csv’
I tried to fix my working directory in using : setwd("/Users/m2/Documents/R Projects/SECOPE/")
But that’s not run.
Many Thanks

1 Like


Can you verify the the path “/Users/m2/Library/Application Support/JetBrains/DataSpell2022.3/projects/workspace/extracts/test.csv” is incorrect? Generally, I would use the here package in combination with an R project - are you using an R project for this analysis?

All the best,


Hi @hlama26
As Tim mentioned, here() works best within an R project. In this case, there should be no need to have a setwd() command as the root of the project is the working directory, and your data are inside the R project.

See these two chapters of the Epi R Handbook: