AndeeKaplan

Assistant Professor at Colorado State University Statistics

Getting Started with R...

Toggle Code Viewing: ON

Installation

Most of the content in this blog will be calculated with the statistical language called R. In order to keep up at home, follow the instructions to install this FREE tool!

  1. Go to http://cran.r-project.org/
  2. Download the version appropriate for your platform (most likely Windows or Mac)
  3. Select "base"
  4. Click on "Download R [version] for Windows" (or whatever OS you have)
  5. Select "Run"
    Run Installer
  6. Follow instructions on the installer.

First Use

Before you get into the nitty-gritty, you might want to set your working directory in R. So, open up R by clicking on the shortcut the Installation Wizard just put on your desktop. Next, run this in your R console:

setwd(choose.dir())
and change your working directory to the folder containing files you want to read!

Packages

In R, you have the ability to make use of user-submitted packages (which is a lot easier than writing them yourself)! Before you can use all this free functionality, you must

  1. Install the package
  2. Load the package

Each time you use R you must reload any packages you want to use, but you only have to install them once.

To install a package,

install.packages()
You will be prompted to select a mirror. Select one close to you, for example USA(IA), and click "OK". Next, select the package you wanted to use and click "OK" again. Your package is now installed!

Before you can use your installed package, you must load it into the workspace. Type the following into your console:

library(package)
That's it!

Further Information

For more information on getting started and the capabilities of R, see An Introduction to R.




blog comments powered by Disqus