R Basics with RStudio
Last updated August 2024
1 Introduction
R is general purpose statistical software and, like all such software, at its core is a programming language. The primary task with such software is to write and run code.
There are several programs we can use to edit and run R commands. The most popular of these is RStudio.
The basics elements of using an interactive interface include:
- Writing and running commands
- Finding the results
- Saving those commands and results
Beyond these software basics, you will also need some understanding of how the programming language works. We will talk about:
- R grammar
- Using Help
- Using Functions and Packages
If you are using the SSCC servers or computer labs, R and RStudio are already installed, but you may choose to also install them on your personal computer. Click here for instructions on installing R and RStudio.
After installing RStudio, we recommend changing a few of the default settings. After opening RStudio, open the Tools menu and select Global Options.
In the General tab, under Workspace, change the option after “Save workspace to .Rdata on exit” to “Never”. This will help you to write reproducible code and also prevent you from filling your computer storage with hidden data files.
In the Code tab, check the option “Soft-wrap R source files”. If you write long lines of R code, this will wrap the files so you do not have to scroll horizontally to see your code.
In the Appearance tab, customize your R font and theme to your liking.
The examples in these materials were run with R version 4.4.1. To ensure that the code runs properly, be sure to update your R to at least this version.