-
Usually the #rstats answer to "I wrote the data.table to disk but I can't find it" is to use RStudio Projects. They help you package your analysis, data, and results into a nice neat folder. r4ds.had.co.nz/workflow-projects.html
-
Of course, you need to learn a little bit about file systems on your computer before you can get the hang of projects. This is a nice discussion about absolute and relative file paths. ubc-dsci.github.io/introduction-to-datascience/reading.html#absolute-and-relative-file-paths
-
Extra credit: the {here} package helps make your .Rmd files portable within a project. Everytime you use
here(), it will pretend the root path is always in the place where your .RProj file lives. here.r-lib.org/ -
I do think that everyone is like "yeah, whatever...", and then they come to me with these problems. Just use projects. They help you organize files. For example, I always have datasets in the "data" folder in my project.
-
My markdown files tend to live in the root folder (where the .Rproj file lives), but if I wrap all of the relative paths in
here(), then I can move them anywhere in the project, such as a folder called "rmarkdown". -
Output (graphs and figures) can live in an "output" folder in the project, which is really helpful in separating incoming data from final figures.
-
I have to admit that I feel a bit like a missionary going door to door about this, saying things like: "Have you heard of the miracle called RStudio Projects? Have you seen the light?"