 Hi, I'm going to talk about one of my favorite R packages, which is the here package, and I'm going to address one of the most common questions about using the here package, which is why should I use it when I'm already using RStudio projects? This is based on a blog post that I did, which you can find a link to here bit.ly slash why here package PKG. So while back, Jenny Bryan from RStudio had a very controversial stance that was shared in a talk, and then on Twitter, where it was met with some enthusiasm and disagreement, where she said if the first line of your R script is set working directory, and then it's some absolute path that only exists on your computer, doesn't exist on my computer. So I pick up your R script, and I can't actually run this code because this doesn't exist on my computer, she's going to come to your office and set your computer on fire. And secondly, if you survive that, if the first line of your R script is remove list equals ls, she's also going to come to your office and light your computer on fire. So these are two commonly used patterns in R scripts, and they're both problematic. They're problematic because the first one, I simply don't have that that path on my computer, and so your code's not going to run. I have to go manually change it to wherever it's located on my computer. The second is usually intended on restarting your R sessions such that you have a fresh session. The problem with with RM is that it doesn't actually do that. So this will remove many of the objects in your global environment, but it's not going to unload packages, and it's not going to remove global options, it's not going to change your working directory, things like that. So it doesn't actually give you a fresh session. On the other hand, it might aggravate the person who you sent your script to because you just cleared everything out of their environment without their permission. So the advice that Jenny gives in this talk is that you should, first of all, use R studio projects, and second of all, use the here package, and specifically the here function within that package to write file paths. So using R studio projects is very straightforward. It's very easy to create in our studio project in our studio, and it solves the absolute working directory problem immediately because as soon as you open a project, your working directory is wherever that project is. So that solves that problem. You can just write relative paths. If I take your project on my computer, it will still run. You can also set your projects such that they always start with a fresh session, you know, you don't save any of your data or your history or anything like that. And you can set it so that when you restart your R session, it does the same thing. And so it solves actually both of these problems. So the question is, why did Jenny also suggest that we should be using the here function? So this is an example of project directory that I have here. This is an R studio project. It's got three folders in it. I've got some figures of data and our markdown file and some other scripts. You can find a link here on my GitHub. It's under Malcolm Barrett slash here underscore here. So the most important reason why we might want to use the here package is that when we're writing paths with here, it actually operates from the package or the project directory up. So if I am in, for instance, my R markdown file, R markdown, every time you run that script, it actually runs in a fresh session with its own local working directory. So if I run this code, I have this data file, I run this code in my script, I'm going to end up with an error because my directory is not available one up from where my R markdown file is. However, the here package loads the working directory from the project directory up, not wherever the file is. And so now when I say here data mtcars.csv, it has no trouble finding this data because again, it's going back to this root directory for my project. Additionally, here bottles up several best practices so that you don't have to think about them when you're writing file paths. File paths, frankly, are not fun to think about writing. And so here takes care of a lot of that stuff for you. One good example is that it will write paths that operate safely across operating systems, right? Mac, Windows, Linux, they have potentially slightly different ways of writing things and this will handle this for you so that if you give your code to somebody that's operating on a different system, your code is still going to run. So the advice is use R studio projects, avoid set working directories to some absolute path and try restarting your R session in a clean session rather than RM. Both those things will avoid some arsenic and then use the here function from the here package to work from a project directory up. Thank you. My name is Malcolm. You can find my GitHub here and I'm on Twitter and my website is maco.io. This blog post is available to learn much more about this really great function. Thank you.