To HomePage

Introduction to R

History of S and R

Installing R

Invoking R

Some Useful R Commands

Vectors and Atomic Elements

Repetition and Sequences

  1. Use the rep function to repeat a value in a vector:
    > r = rep(45, 5)
    > r
    [1]  45  45  45  45  45
    
  2. m:n creates a sequence from m to n, inclusive:
    > s = 1:6
    > s
    [1]  1  2  3  4  5  6
    > r = 9:6
    [1]  9  8  7  6  
    

  3. Use the seq function to create a more general sequence:
    > q = seq(from=3, to=5.5, by=0.5)
    > q
    [1]  3.0  3.5  4.0  4.5  5.0  5.5
    > p = seq(from=900, to=600, by=-100)
    [1]  900  800  700  600
    

Matrices

Subsetting Vectors and Matrices

Lists and Data Frames

 

File Input

Running R Statements from a Script

Redirecting Graphics Output to Disk

Redirecting Graphics Output to Disk