^

Lion in a what?

Digital Media, Organizational, and Personal Development

twitter linkedin github gtalk

Coursera - R Programming - Week 1 - Vectorized Operations

> x <- 1:4, y <- 6:9
> x + y
[1] 7 9 11 13
> x > 2
[1] FALSE FALSE TRUE TRUE

Vectorized Matrix Operations

> x <- matrix(1:4, 2, 2); y <- matrix(rep(10, 4), 2, 2)

rep creates a 2x2 matrix of 10s

True matrix multiplication is performed using %*%:

> x %*% y
    [ ,1]   [ ,2]
[1, ]   40  40
[2, ]   60  60