R studio has become a standard tool for R. It provides a user friendly interface to write and execute code by hybridinzing scripts with a point-and-click interface. There are already great resources going going over RStudio that go way beyond what I will discuss here. If you are interested in learning more check out: https://rstudio.com/wp-content/uploads/2016/01/rstudio-IDE-cheatsheet.pdf

Part 1: RStudio orientation

RStudio offers users to customize the interface to create a space that works best for them. However, there are four basic windows to be aware of:

1) The source pane - this is where you can write and edit code, insert text for reports, and generally get work done.


2) The Console - this is your traditional R view. Here you can script just like you would in the original R, code is execulted by pressing enter and stored in your history.



3) Plots, Packages, and Help - This is a viewer pane that provides quick access to viewing plots, installing packages, reading help pages.

View all of the packages you have installed, or install new packages



Pull up help files for functions and packages



4) Environement - This is where you can preview what data you have loaded in to R and manage functions and or history.

View different datasets that you have loaded an check to make sure you know what variables or funcitons you have loaded.



Look back at your history and even move code that you wrote in the “console” back to your official script in the “Source” pain.



The layout of these panes is up to you can can be customized by clicking on the “Workspace Panes” icon with 4 little boxes on the top bar.



Part 2: RStudio secrets

RStudio has a ton of options and tricks that make using R in R studio much easier than it used to be. Here are a few resrouces you might not know about:


2). RSessions - If you have a script running but want to keep working on a new script while the other runs, you can open new session. This allows you to get something else started while your model is running.


3). RMarkdown, Shiny Apps, and presentations - RStudio allows you to create different types of documents and us R code to do a lot more than just statistics. See Alex about getting started with RMarkdown and Shiny.


4). Easy help and cheatsheets - You may know that “?function()” pulls up a help page, but RStudio also makes it easy to access lots of pre-built cheatsheets for different common packages and syntax under the “Help” tab.



5). Use the magnifying glass to search and replace to quickly re-name variables (or correct mistakes).



6). If you are working on a report (Check out Alex Latzka’s talk) you can spell check your work



7). Important files using the “Import Dataset” button in the environment panel:




8). Hotkeys, hotkeys, hotkeys - R has about a million different key strokes you could learn to code more efficiently A whole list is easily accessible under the “Keyboard Shortcuts” in “Help” (which you can access using opt/alt+shift+k).

Press tab when typing a file path to view all files in the present folder.
Press cmd+opt+i to insert a new code chunk
Press cmd+enter to run a line of code
Press command + shift + c to comment blocks of code (or un-comment)
Press opt + - to name a new variable



Press and hold option to enter “column mode”





clean up indents with cmd + i






There is a lot more that RStudio can do to make it easier to learn R. The best way to learn is to spend some exploring the RStudio environment by clicking around on the different tabs and buttons.