short introduction to rstudiofelixhaass.de/files/rstudio presentation.pdf · short introduction to...
TRANSCRIPT
![Page 1: Short Introduction to RStudiofelixhaass.de/files/RStudio Presentation.pdf · Short Introduction to RStudio Felix Haass GIGA German Institute of Global and Area Studies University](https://reader033.vdocuments.mx/reader033/viewer/2022052804/604c4c2ccb9bb66e8712214e/html5/thumbnails/1.jpg)
Short Introduction to RStudio
Felix Haass
GIGA German Institute of Global and Area StudiesUniversity of Greifswald
Prepared for the ECPR Summer School 2015Multiple Regression AnalysisProf. Dr. Bernhard Kittel
July 26, 2015
![Page 2: Short Introduction to RStudiofelixhaass.de/files/RStudio Presentation.pdf · Short Introduction to RStudio Felix Haass GIGA German Institute of Global and Area Studies University](https://reader033.vdocuments.mx/reader033/viewer/2022052804/604c4c2ccb9bb66e8712214e/html5/thumbnails/2.jpg)
The RStudio Environment
![Page 3: Short Introduction to RStudiofelixhaass.de/files/RStudio Presentation.pdf · Short Introduction to RStudio Felix Haass GIGA German Institute of Global and Area Studies University](https://reader033.vdocuments.mx/reader033/viewer/2022052804/604c4c2ccb9bb66e8712214e/html5/thumbnails/3.jpg)
The Editor - What it does
This is where you:
1. Write your scripts (but notnecessarily all your code!)
2. View your data (type inconsole: View(data))
3. Write reports or createpresentations (Markdown)
![Page 4: Short Introduction to RStudiofelixhaass.de/files/RStudio Presentation.pdf · Short Introduction to RStudio Felix Haass GIGA German Institute of Global and Area Studies University](https://reader033.vdocuments.mx/reader033/viewer/2022052804/604c4c2ccb9bb66e8712214e/html5/thumbnails/4.jpg)
The Editor - How to use it
Useful tips for using the RStudio editor
1. Execute code: Select code chunk &Ctrl+Enter
I Ctrl+S+Enter executesentire script
2. Shortcut: Ctrl+1
I focuses cursor on editorwindow
I useful if you switch oftenbetween console and editor
3. Code completion: Press Tab
4. Warns if your code has typos:
![Page 5: Short Introduction to RStudiofelixhaass.de/files/RStudio Presentation.pdf · Short Introduction to RStudio Felix Haass GIGA German Institute of Global and Area Studies University](https://reader033.vdocuments.mx/reader033/viewer/2022052804/604c4c2ccb9bb66e8712214e/html5/thumbnails/5.jpg)
The Data Viewer
Usually it’s a good idea toinspect your data visually.This is what the data vieweris for.
1. Filter: toggle filter foreach variable directly inthe data viewer
2. Search: search dataframe for string /number
3. Click on variable nameto sort data framebased on that variable(descending / ascending/ alphabetical)
![Page 6: Short Introduction to RStudiofelixhaass.de/files/RStudio Presentation.pdf · Short Introduction to RStudio Felix Haass GIGA German Institute of Global and Area Studies University](https://reader033.vdocuments.mx/reader033/viewer/2022052804/604c4c2ccb9bb66e8712214e/html5/thumbnails/6.jpg)
The Console
1. Write your step-by-stepcode. If it works →copy it to source editor!
2. Up (Arrow): lastcommand
3. Ctrl+Up: popup codehistory. Tip: starttyping command &Ctrl+Up to see recentinstances of command.Can save lots of time!
4. Focus cursor onconsole: Ctrl+2
![Page 7: Short Introduction to RStudiofelixhaass.de/files/RStudio Presentation.pdf · Short Introduction to RStudio Felix Haass GIGA German Institute of Global and Area Studies University](https://reader033.vdocuments.mx/reader033/viewer/2022052804/604c4c2ccb9bb66e8712214e/html5/thumbnails/7.jpg)
Environment & History
Environment
1. See which objects are inyour workspace (WS canget crowded sometimes;this is where theEnvironment panelbecomes useful)
2. Clear global environmentwith rm(list = ls())
3. Click on object to view itin the data viewer
The History
1. See what you did.(Always good idea)
2. If it worked → copy it tosource or console
![Page 8: Short Introduction to RStudiofelixhaass.de/files/RStudio Presentation.pdf · Short Introduction to RStudio Felix Haass GIGA German Institute of Global and Area Studies University](https://reader033.vdocuments.mx/reader033/viewer/2022052804/604c4c2ccb9bb66e8712214e/html5/thumbnails/8.jpg)
Plot / Help / Files
Plot
1. Look at your plots
2. Export them (better to usecode for this, though!Replication!)
Help
1. help(command) opens thiswindow
Files (no screenshot)
1. Open files / scripts
2. Point+Click to set workingdirectory. Faster:Ctrl+Shift+H
Packages (no screenshot)
1. Manage your packages
2. Update & install packages
![Page 9: Short Introduction to RStudiofelixhaass.de/files/RStudio Presentation.pdf · Short Introduction to RStudio Felix Haass GIGA German Institute of Global and Area Studies University](https://reader033.vdocuments.mx/reader033/viewer/2022052804/604c4c2ccb9bb66e8712214e/html5/thumbnails/9.jpg)
We’ve only scratched the surface...
General advice
I Alt+Shift+K displays keyboard shortcuts
I Trouble? R’s emergency center ishttp://stackoverflow.com
Further functionality
I RStudio Projects: see here
I R Markdown: Write reports & presentation withPDF, .docx, or HTML output directly in R:http://rmarkdown.rstudio.com/
I Diagrams:http://rich-iannone.github.io/DiagrammeR/
I Version control with GitHub, see e.g. here, hereor here
R Markdown
Diagrams in RStudio