Coursera - R Programming - Week 1 - Basics

Setting Up Your Working Directory (Mac)

    > getwd()
    "/Users/neilthawani"
    

A file must be under your working directory if you want to read data from it.

dir() lists all the files in the working directory.

R Console Input and Evaluation

<-< /span> is the assignment operator

    > x <- 1
    

print explicitly prints an object

    > print(x)
    [1] 1
    

Typing 'x' auto-prints it.

    > x
    [1] 1
    

x is a numeric vector where the first element is 1.

# indicates comments.

To create integer sequences:

    > x <- 1:20
    > x
    [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
    [16] 16 17 18 19 20
    

Published January 18, 2015