How to Download R and RStudio
R is a computer language. It’s a tool for doing the computation and number-crunching that set the stage for statistical analysis and decision-making. RStudio is an open source integrated development environment (IDE) for creating and running R code. It’s available in versions for Windows, Mac, and Linux. Although you don’t need an IDE in order to work with R, RStudio makes life a lot easier.
Download R from the Comprehensive R Archive Network (CRAN). In your browser, type this address if you work in Windows:
Type this one if you work on the Mac:
Click the link to download R. This puts the win.exe file in your Windows computer, or the .pkg file in your Mac. In either case, follow the usual installation procedures. When installation is complete, Windows users see an R icon on their desktop, Mac users see it in their Application folder.
Both URLs provides helpful links to FAQs. The Windows-related URL also links to “Installation and other instructions.”
Now for RStudio.
Click the link for the installer for your computer, and again follow the usual installation procedures.
After the RStudio installation is finished, click the RStudio icon to open the window shown.
If you already have an older version of RStudio and you go through this installation procedure, the install updates to the latest version (and you don’t have to uninstall the older version).
The large Console pane on the left runs R code. One way to run R code is to type it directly into the Console pane.
The other two panes provide helpful information as you work with R. The Environment and History pane is in the upper right. The Environment tab keeps track of the things you create (which R calls objects) as you work with R. The History tab tracks R code that you enter.
Get used to the word object. Everything in R is an object.
The Files, Plots, Packages, and Help tabs are in the pane in the lower right. The Files tab shows files you create. The Plots tab holds graphs you create from your data. The Packages tab shows add-ons (called packages) you downloaded as part of the R installation. Bear in mind that “downloaded” doesn’t mean “ready to use.” To use a package’s capabilities, one more step is necessary, and you’ll want to use packages.
This figure shows the Packages tab. The packages are in either the user library (which you can see in the figure) or the system library (which you have to scroll down to).
The Help tab, shown here, provides links to a wealth of information about R and RStudio.
To tap into the full power of RStudio as an IDE, click the larger of the two icons in the upper right corner of the Console pane. That changes the appearance of RStudio so that it looks like this:
The top of the Console pane relocates to the lower left. The new pane in the upper left is the Scripts pane. You type and edit code in the Scripts pane and press Ctrl+R (Command+Enter on the Mac), and then the code executes in the Console pane.
Ctrl+Enter works just like Ctrl+R. You can also select
Code → Run Selected Line(s).