1  The R Environment

R is an environment for statistical modeling and graphics. That it is an environment instead of a package is one of the main reasons why R is distinct from other statistical programs. A package only gives us a fixed set of tools. An environment allows us to modify, combine and even create tools to suit our specific needs.

1.1 Why becoming a useR?

R is gratis and runs on Windows, MacOS, and several Unix platforms. With R you can start with a data set like this:

  treat nitrogen block height weight leafarea shootarea flowers
1   tip   medium     1    7.5   7.62     11.7      31.9       1
2   tip   medium     1   10.7  12.14     14.1      46.0      10
3   tip   medium     1   11.2  12.76      7.1      66.7      10
4   tip   medium     1   10.4   8.78     11.9      20.3       1
5   tip   medium     1   10.4  13.58     14.5      26.9       4

and, in 8 lines of code or less, make a plot like this:

You can also find many powerful tools to fit statistical models (both bayesian and frequentist), including:

  • Generalized linear models (including linear regression)
  • Survival analysis
  • Time series analysis
  • Multilevel models (aka hierarchical models, aka Random and Mixed effects models)
  • Classification and clustering
  • Sample size and power calculations
  • Multivariable analysis (e.g., factor analysis, principal component analysis, and structural equations modeling)

Even better, new tools become available in R all the time because, as with other open source programming languages, everyone can examine and contribute to R’s code. Users constantly publish their own code packages to expand R’s capabilities. As of June 2025, there are over 22 thousand packages to the Comprehensive R Archive Network (CRAN)1. Many of these packages perform complex statistical routines that are not (and may never be) available in other statistical software systems.

In Windows, there are several ways to use R. The standard R graphical unit interface (GUI) allows you to point and click to do many basic tasks. Other graphical unit interfaces are R Commander, developed by John Fox at McMaster University; and Tinn-R, developed by Jose Claudio Faria.

These graphical unit interfaces are friendly and easy to grasp if you’re a beginner. But to use all of R’s capabilities you will need to do more than point and click. A more complete way of using R is through an integrated development environment (IDE), which, in short, helps you code. The most popular IDE for R is RStudio, which organizes the user’s screen into panes that display scripts, objects, graphics, and the R console.

In these notes, we will use RStudio a lot. The goal is for you to start taking full advantage of R’s capabilities.

1.2 Why Isn’t Everyone a UseR?

Many users of statistics don’t use R because they only know how to use one statistical software, often the one taught in their first statistics course. In the past, R rarely was this first language, but nowadays more schools are teaching how to use it.

Some people have used R, but struggled to get comfortable and productive with it, especially if they had little coding experience. Typing commands explicitly is more difficult than pointing and clicking. Also, each package has its own rules to learn. We can find a lot of good help for popular packages written by professional developers, but not so much for smaller packages written by other amateur users. Worst of all, some of the messages R displays if we make a mistake are uninformative, so fixing the problem can be difficult.

Don’t get frustrated! You don’t have to be an expert programmer to use R, and the benefits are worth spending some time up front.

1.3 Suggestions for Learning R

1.4 How to get R

R is already installed on the lab workstations. Follow the steps below if you want to install R in another computer.

  1. Go to the R Project Web Page
  2. Click on the CRAN link located at the left hand side of the screen, under the “Download” heading.
  3. The next page will ask you to choose one of the U.S. mirrors. Any mirror will work, but the download will be faster if you choose one located in a place close to you.
  4. Click on “Download R for [your operating system]” (Linux, macOS, Windows).
  5. If you chose Windows, click on the “base” subdirectory. If you chose macOS, go to the next step.
  6. If you chose Windows, click the “Download R 4.X.X for Windows” link (when we last checked, version 4.5.1 was available). If you chose macOS, check under “Latest release” and click the link that corresponds to the type of mac you have.
  7. A file will start downloading. Make sure you know where it is being saved and wait for the download to finish.
  8. In your computer, double-click on the file you downloaded. An installation window will appear to guide you through installing R in your machine.
  9. Once you finish, an R icon should appear on your desktop. This icon is a shortcut to open R in your computer.

1.4.1 How to get RStudio

RStudio is already installed on the lab workstations. Follow the instructions below if you want to install RStudio in another computer. You must install R before you install RStudio. Otherwise, RStudio will not work.

Visit this website and click on “Download RStudio”. Choose the version for your operating system (Linux, OS X, Windows) and download the installer. Then double click on the installer file and follow the instructions on the screen.


  1. r-pkg.org. (n.d.). Retrieved July 3, 2025, from https://www.r-pkg.org/↩︎