Notes on the here package –
The here package is pretty simple ( only 3 functions), but I cannot remember how to use it to navigate folders, so this is my aide-memoire.
It might be useful for others too.
Here finds the root of your current folder / working directory.
If you use Projects in RStudio, that will usually be the root of your project folder.
If not, you can use set_here() to create a small file which will set the root location.
# where am I in my computer? here() "C:/Users/some/path/or/other" # # create a folder dir.create(here("img")) "C:/Users/some/path/or/other/img" dir.create(here("img","png")) "C:/Users/some/path/or/other/img/png" #move to the outputs folder using setwd() setwd(here("img")) # check this worked - get the current working directory with getwd() getwd() "C:/Users/some/path/or/other/img" # go back to the root of the project setwd(here()) #check you are back where you started getwd() "C:/Users/some/path/or/other"
Now the next time I am like this:
I can just read this post, and hope no-one sees me reading my own blog.