Have you ever used setwd("pathtofolder") at the beginning of an R script? Are you pasting folder names and paths into string to read multiple files from your folder? Have you ever wondered if there is a better, more intuitive way?
Wonder no more! There is an amazing package that can help you better organise your R folders and make every dataset and script easier to find. Say hello to the herepackage!
This package has three main functions:
Set_here() creates an empty .here file in the current working directory which will be used by the here package as the root
Dr_here() - explains why here is set to a particular directory
Here() - uses heuristics to navigate your projects file based on the current working directory
For example, if you have a file in the "Root\FolderLevel1\FolderLevel2\FolderLevel3\" you can use the command
Much more intuitive, less typing, less prone to errors and failures!
If you are using the here package together with R projects, your productivity will certainly increase. Every time I start a new data science project, I create an R project in Rstudio, which automatically sets the working directory to the folder I create the project in.
I then use set_here() to create a .here file in the root directory of my project and then use the here() function to navigate complex folder structures. Reading, writing and finding files has never been easier!