Exploring RStudio’s basic layout & packages

<< Previous post: Creating a new project in RStudio

In RStudio, you will notice several windows or panes that are open side-by-side. You can edit the layout of these windows in:

View → Panes → Pane Layout… 

and pick which windows you want to display. In the Pane Layout tab you can choose between Source (your data in table form or other files when opened), Console (where you will type the code to execute commands) and the two right panes that can be showing items like the History, Packages, Files, etc. that are in tabs next to each other in each pane. When you generate plots form your data, they will appear on the bottom right pane. The Source pane may not be visible without data initially by the way, but if you click the little icon on the top right in the Console pane, it will reveal itself.

Packages are add-on functions generated by users to make certain calculations or visualizations easier or better. When you find out you need to install a package, type in the Console:

install.packages("package name")

You only have to install packages once, but every time you open your project in RStudio, you need to load them. You can do this by clicking on the checkbox next to the package file name in the bottom right pane (in the Packages tab). Notice that this leads to the following being executed in the Console:

library(package name)

Since you would have to remember which packages you use for each type of analysis, it is easier to store the line commands that load your packages somewhere, and run them before you start your analysis. For example you can create an R Markdown file where you can take notes, run your previous code, and export it to a pretty looking file:

File → New File  → R Markdown…

When you click the knit button in the example .rmd file that is created by RStudio, you can get a feel for how headers, plots, and code chunks are created in the final file. This cheat sheet offers a more detailed explanation of the functionality of R Markdown files.

Next: Converting & opening data files for use with R >>

Leave a Reply

Your email address will not be published. Required fields are marked *