R and RStudio

R is a free programming language for data analysis. RStudio is a free program that makes R easier to use. You need to install both, and R must be installed first.

R

You can install R from the R homepage. Click download R, then select the closest mirror. If you are not sure, select 0-Cloud. Then you will need to select the operating system of your computer whether it is Linux, Mac or Windows.

RStudio

RStudio is an Integrated Development Environment that provides free and open-source tools for R. You can run your data analysis in the basic R environment. However, RStudio does have a more intuitive interface and more tools to help you write your R code.

You can install RStudio from the Posit website.

You will not need to open R directly. RStudio runs it for you.

The RStudio interface has many windows. You will find the name of each window in the top-left corner of that window. On the left-hand side, you have the console window where you can type and submit R code. The results of your code will also appear in this window.

You can also type your code in the R script window. To open a new R script file, go to the File menu, then go to New File and select R Script. You can also click the white page icon on the toolbar, then select R Script to open a new R script page.

You can interact with RStudio by typing your code in the console window or in the R script page. The advantage of the R script is that you can save your code, edit it later and share it with others.

Running code

To submit R code from the console window, simply type your code and hit enter.

To submit R code from the R script window, make sure your cursor is on the line of code you want to submit and either click on the Run icon on the toolbar or use the shortcut CTRL-ENTER (CMD-Return for Mac).

Search and help

Use ?? to search functions and packages that are related to a topic. Use the help() function to open the official help file for a specific function.

??csv
help(read.table)

Technique: Converting data formats, Cleaning data, Extracting data
Tools: R
Data Format: Statistics