short introduction to rstudio
play

Short Introduction to RStudio Felix Haass GIGA German Institute of - PowerPoint PPT Presentation

Short Introduction to RStudio Felix Haass GIGA German Institute of Global and Area Studies University of Greifswald Prepared for the ECPR Summer School 2015 Multiple Regression Analysis Prof. Dr. Bernhard Kittel July 26, 2015 The RStudio


  1. Short Introduction to RStudio Felix Haass GIGA German Institute of Global and Area Studies University of Greifswald Prepared for the ECPR Summer School 2015 Multiple Regression Analysis Prof. Dr. Bernhard Kittel July 26, 2015

  2. The RStudio Environment

  3. The Editor - What it does This is where you: 1. Write your scripts (but not necessarily all your code!) 2. View your data (type in console: View(data) ) 3. Write reports or create presentations (Markdown)

  4. The Editor - How to use it Useful tips for using the RStudio editor 1. Execute code: Select code chunk & Ctrl+Enter ◮ Ctrl+S+Enter executes entire script 2. Shortcut: Ctrl+1 ◮ focuses cursor on editor window ◮ useful if you switch often between console and editor 3. Code completion: Press Tab 4. Warns if your code has typos:

  5. The Data Viewer Usually it’s a good idea to inspect your data visually. This is what the data viewer is for. 1. Filter : toggle filter for each variable directly in the data viewer 2. Search : search data frame for string / number 3. Click on variable name to sort data frame based on that variable (descending / ascending / alphabetical)

  6. The Console 1. Write your step-by-step code. If it works → copy it to source editor! 2. Up (Arrow): last command 3. Ctrl+Up : popup code history. Tip: start typing command & Ctrl+Up to see recent instances of command. Can save lots of time! 4. Focus cursor on console: Ctrl+2

  7. Environment & History Environment 1. See which objects are in your workspace (WS can get crowded sometimes; this is where the Environment panel becomes useful) 2. Clear global environment with rm(list = ls()) 3. Click on object to view it in the data viewer The History 1. See what you did. (Always good idea) 2. If it worked → copy it to source or console

  8. Plot / Help / Files Plot 1. Look at your plots 2. Export them (better to use code for this, though! Replication!) Help 1. help(command) opens this window Files (no screenshot) 1. Open files / scripts 2. Point+Click to set working directory. Faster: Ctrl+Shift+H Packages (no screenshot) 1. Manage your packages 2. Update & install packages

  9. We’ve only scratched the surface... General advice R Markdown ◮ Alt+Shift+K displays keyboard shortcuts ◮ Trouble? R’s emergency center is http://stackoverflow.com Further functionality ◮ RStudio Projects: see here ◮ R Markdown: Write reports & presentation with PDF, .docx, or HTML output directly in R: http://rmarkdown.rstudio.com/ Diagrams in RStudio ◮ Diagrams: http://rich-iannone.github.io/DiagrammeR/ ◮ Version control with GitHub, see e.g. here, here or here

Recommend


More recommend