RStudio Introduction 0 RStudio is an integrated development environment (IDE) for R Standards of programming in R 0 Keyboard Shortcuts using - Ctrl/Alt (Win, later we use Win as an example), Cmd/Option (macOS), for details see, e.g. Getting to Know RStudio Rstudio-cheatsheet J 0 After starting RStudio create new RSkript a File -> New File -> R Script (Ctrl+Shift+N) Veronika Bendová1, Stanislav Katina1 2 0 Set R Studio appearance • Tools —> Global Options —> Appearance 11nstitute of Mathematics and Statistics, Masaryk University 2Honorary Research Fellow, The University of Glasgow 0 Restart R Session (all manually loaded packages will be unloaded) • Session -> Restart R (Ctrl+Shift+F10) March 5, 2018 0 Clear Workspace (remove all loaded datasets and defined objects) 0 • Session —> Clear Workspace Clear Console (delete all commands and outputs displayed) » Ctrl + L «□►- ■<=►•<=► = 1/6 Veronika Bendová, Stanislav Katina Standards of programming in r 2/6 Veronika Bendovä, Stanislav Katina Standards of programming in r RStudio Introduction RStudio Environment (JRStudic O - I <ŽP - I B t? = A Go to f e/functíon Untitled 1 I Ell - Addins • %■, Project: (None) " i I I H (JSou.ce <\ -\\_ l-*l ,J»Sou,ce • Environment History Connections & S I ffl» Import Dataset- / % Global Environment - Environment \i 1:1 I (Top Level) ; Files Plots Packages Help Viewer ■ Export - Veronika Bendová, Stanislav Katina Standards ot programming in r R Studio environment is divided into four sections: 0 Code editor (top left) » Environment for creating your own code » Click on button Run or press Ctrl + Enter for running (a part of) the code 0 Workspace (top right) • Environment - list of loaded datasets, defined objects (variables) and defined functions j History - list of all commands, which were run in the past 0 Console (bottom left) • Environment, where executed commands and their outputs are displayed 9 Plots (bottom right) • Files - provides a list of files in selected folder o Plots - shows a preview of plotted graphs • Packages - allows installing new packages and displays a list of installed packages, which can also be loaded and unloaded from here • Help - interactive help environment Veronika Bendová, Stanislav Katina Standards ot programming in r RStudio Project Useful Links Note: The above mentioned sections could be rearranged and also their number could be changed from 2 to 4 (based on your preferences). (j) Create new R project j File —> New File a File —> New File j File —> New File R Script (R) R Sweave (pdf) R Markdown (HTML, Word, pdf) 9 Set the folder, where the R Script is located, as working directory j Session —> Set Working Directory —> To Source File Location 0 A good project layout » Integrity of data • Portability of the project j Easier to pick the project back up after a break 0 Directory layout (example) o Folder "Project-name" • Subfolders "R.Scripts", "Data", "Docs", "Figures", "Outputs" Standards of programming in r ■o0.o 9 RStudio project https://support.rstudio.com/hc/en-us/articles/200526207-Using-Projects 0 Designing RStudio projects https://nicercode.github.io/blog/2013-04-05-projects/ (5) Paper about designing projects http://journals.plos.org/ploscompbiol/article?id=10.1371 /journal.pcbi. 1000424 (4) A meaningful structure for RStudio project https://www.inwt- statistics.com/read-blog/a-meaningful-file-structure-for-r-projects.html Veronika Bendová, Stanislav Katina Veronika Bendová, Stanislav Katina Standards of programming in r