class: title-slide, left, bottom <img src="data:image/png;base64,#img/session02/cracked_setwd.PNG" width="40%"/> # Using R Studio Projects ---- ## **Session 2** ### ### .right-column[ .footnote[Artwork by @allison_horst] ] --- # Working Directory If you tell R/R Studio to look for a file, or save a plot, it will (by default) look in a place called the working directory (wd) </br> </br> <img class="center" src="data:image/png;base64,#img/session02/working-directory.PNG"/> </br> You can (usually) see your working directory path at the top of the console panel...</br> </br> ... it often defaults to the "Documents" folder. </br> </br> This example is ~/workshop-r/ and ~ is in Documents --- # Browsing in RStudio If you click the arrow next to the file pathway ~/workshop-r/ </br> <img src="data:image/png;base64,#img/session02/working-directory.PNG"/> it will return you to the working directory and you can see all the files in that folder: </br> <img class="center" src="data:image/png;base64,#img/session02/wd-files.PNG"/> --- class: center, middle # Organisation </br> <img class="center"src="data:image/png;base64,#img/session02/cognitive-load.PNG" width="15%"/> </br> Sooner or later (but probably sooner) you will wish to change where files are saved (and loaded from). </br> </br> Being organised is key:</br> </br> Reduces cognitive load (and frustration). .footnote[Artwork by @allison_horst] --- # RStudio Projects </br> make it *far easier* for you to: </br> </br> 1) .blue[*Organise*] files and workflow </br> </br> 2) .blue[*Switch*] between projects </br> </br> 3) .blue[*Share*] scripts / projects with others </br> </br> .green[(when collaborating or getting assistance)] </br> </br> Recommended for all tasks (large or small). --- # Create a project </br> File <svg viewBox="0 0 448 512" style="height:1em;position:relative;display:inline-block;top:.1em;" xmlns="http://www.w3.org/2000/svg"> <path d="M190.5 66.9l22.2-22.2c9.4-9.4 24.6-9.4 33.9 0L441 239c9.4 9.4 9.4 24.6 0 33.9L246.6 467.3c-9.4 9.4-24.6 9.4-33.9 0l-22.2-22.2c-9.5-9.5-9.3-25 .4-34.3L311.4 296H24c-13.3 0-24-10.7-24-24v-32c0-13.3 10.7-24 24-24h287.4L190.9 101.2c-9.8-9.3-10-24.8-.4-34.3z"></path></svg> New Project <svg viewBox="0 0 448 512" style="height:1em;position:relative;display:inline-block;top:.1em;" xmlns="http://www.w3.org/2000/svg"> <path d="M190.5 66.9l22.2-22.2c9.4-9.4 24.6-9.4 33.9 0L441 239c9.4 9.4 9.4 24.6 0 33.9L246.6 467.3c-9.4 9.4-24.6 9.4-33.9 0l-22.2-22.2c-9.5-9.5-9.3-25 .4-34.3L311.4 296H24c-13.3 0-24-10.7-24-24v-32c0-13.3 10.7-24 24-24h287.4L190.9 101.2c-9.8-9.3-10-24.8-.4-34.3z"></path></svg> New Directory <svg viewBox="0 0 448 512" style="height:1em;position:relative;display:inline-block;top:.1em;" xmlns="http://www.w3.org/2000/svg"> <path d="M190.5 66.9l22.2-22.2c9.4-9.4 24.6-9.4 33.9 0L441 239c9.4 9.4 9.4 24.6 0 33.9L246.6 467.3c-9.4 9.4-24.6 9.4-33.9 0l-22.2-22.2c-9.5-9.5-9.3-25 .4-34.3L311.4 296H24c-13.3 0-24-10.7-24-24v-32c0-13.3 10.7-24 24-24h287.4L190.9 101.2c-9.8-9.3-10-24.8-.4-34.3z"></path></svg> New Project </br> Name the directory "workshop-r" </br> </br> Create as a subdirectory somewhere useful for you </br> </br> Create project! </br> --- # RStudio Projects Now your working directory is your project directory: </br> <img class="center" src="data:image/png;base64,#img/session02/workshop-r-project.PNG"/> </br> R will save and load files from here (by default). </br> </br> If starting another project, repeat this process. --- class: middle, center # R Studio Projects Switching between projects is simple </br> <img class="center" src="data:image/png;base64,#img/session02/project-list.PNG"/> --- # Acknowledgements Artwork by @allison_horst #### This work is licensed as </br> Creative Commons </br> Attribution </br> ShareAlike 4.0 </br> International </br> To view a copy of this license, visit </br> https://creativecommons.org/licenses/by/4.0/