Our course material uses R Markdown Notebooks.
Opening and running R Markdown (.Rmd
) files requires RStudio.
RStudio is an integrated development environment or IDE that makes it easier to program in R.
Here, our objective is to provide a brief guide to getting started with RStudio.
Note there is an excellent Take a tour of RStudio’s IDE video from RStudio here.
- When you open an RStudio session for the first time, it will look like this.
- The Console is where you will type commands that will be carried out by
R
.
- You can switch to a Terminal where commands will be carried out by clicking the
Terminal
tab to the right of theConsole
tab. This is a command-line interface. Commands here are for programs on your system other than R.
- The Environment pane displays all of the objects and functions in our global environment.
Here we can see that we have a
data.frame
callediris
in our global environment.
- You can click on
iris
to see what thedata.frame
looks like. This will open aView
in the Source pane.
- The Plots pane will display any plots you make during your session.
Here we've made a scatter plot with the
iris
data.
- The Help pane gives you access to documentation about R packages and functions.
Typing
?plot
into the R Console opens up the information about this function in the Help pane.
- The Packages pane tells you what packages are installed and which version. Clicking on a package name will bring up its documentation in the Help pane.
- The History pane displays all the commands that have been executed in R.
- The Files pane displays files for whatever directory or folder it is currently pointed at.
Whatever the Files pane is pointed at is not automatically set as your working directory.
Try typing
?setwd
and?getwd
to learn more about working directories.
- Clicking an R Markdown file (
.Rmd
) in the Files pane will open it up in the Source pane. Note that the working directory for an R Notebook is automatically wherever that notebook is saved.
Rscript files (.R
) will also open in the Source pane.
- If you want to adjust what is displayed or the pane layout, you can do so by clicking
View
>Panes
>Pane Layout
which will bring up an Options menu.
- Download RStudio Desktop if you're not using our RStudio Server
- RStudio Essentials from the folks at RStudio
- RStudio IDE Cheatsheet