The RStudio layout
Opening RStudio
When opening RStudio, the following window will appear:
.
The screen consists of three panes: the console pane, the environment pane and the output pane.
The R script
You can open a new R Script by clicking the green “+” sign on the top right of your screen. In an R Script, you can write and save your R code. Using an R Script instead of writing your code directly in the console has some important advantages:
You can write and organize your code step by step.
You can run your code in chunks or line by line.
You can save your work and come back to it later or share it with others.
You or anyone else can reproduce your analysis, which is especially important for good scientific practice.
Besides R Scripts, there are other types of files that have even more advanced options, but we will come back to that at a later module!
RStudio layout
Now that you have the R Script open, you see the R Studio console has four panes:
.
The Source pane: Here you can edit and save your R Scripts or other computational documents like Quarto and R Markdown.
The Console pane: This is where your code runs. If you for example run a piece of code from the Source pane, you will see the result or output of that code in the Console pane.
The Environment pane: Here, you find all temporary R objects that you create during your R session. Here, you for example find any datasets that you have loaded and can open them for further inspection.
The Output pane: Here the plots, tables or HTML outputs of executed code are displayed. Here, you can also find any files saved to your disk, install packages from here or access help files.
A useful source is the Get Started page on Posit.