Introduction to R

Biochemistry laboratories - 201

Jean-Yves Sgro

Find this document here (short URL) today:


  • check your name on the attendees list
  • choose an iMac
  • login with your UW NetID with
  • Since this is the first time this Mac "sees" you it will go through a quick set-up: simply skip using "Apple ID"

Finding R on the iMac

  • Click on the "Finder" at the bottom right of the "Dock" on the bottom of the screen.
  • This will open a new window.
  • On the left click on "Applications"
  • In the alphabetical list choose "R" or "" with a icon that looks like: R icon
  • double click toopen the R program

R exercises

Hand-outs on the Biochemistry web site. Sh

Class evaluation

After class:

  • fill-in the one page "evaluation" form for this class

The evaluation is anonymous. Evaluation link on Qualtrics or type: the short URL:

(beginning and end of short URL: number ONE and letter L in 1L )

Try R:

Then type R to start the program.

Install R:

R discussion/study groups in Madison

We generally meet every other week (opposite weeks as python). Tuesday at 2pm in MSB 6503. All experience levels are welcome to join us!

How R Works

  • variables, data, functions, results, etc., are stored in the active memory (RAM)

How R Works

  • All the actions of R are done on objects stored in the active memory of the computer (RAM:) no temporary files are used

R Objects

Warning **The name of an object must start with a letter(`A–Z` and `a–z`)**

but can include letters, digits (0–9), dots (.), and underscores (_).

R discriminates between UPPERcase and lowercase letters in the names of the objects, so that x and X can name two distinct objects (even under Windows).

Assign operator: <- and =

Assign values, list, etc. to an R object

Example: place value 15 inside object n

In [12]:
n <- 15

Now n contains value 15:

In [13]:

which is equivallent to:

In [11]:
[1] 15

Where is R Stored?

It depends on your operating system.

  • On Windwows: C:\\Program Files\\R\\R-3.3.3
  • On Mac: /Library/Frameworks/R.framework/Versions/3.3/Resources/library/
In [6]:
# .Library is a character string giving the location of the default library
In [7]:
# On this Mac: .libPaths is used for getting or setting the library trees 
# that R knows about (and hence uses when looking for packages)


Run R from

  • Review R operators
  • Generate data
  • Manipulate R objects
  • Create graphics and plots

Other tutorials

Search engines will list a lot of R tutorials, here is just one:

Video tutorials also exist on YouTube, but at UW we also have access to video courses.

You may need to login with your NetID to see/access these.