x <- 1:4
x * 2
## [1] 2 4 6 8
y <- 6:9
x + y
## [1]  7  9 11 13

something liek this:

x:  1  2  3  4
    +  +  +  +
y:  6  7  8  9
---------------
    7  9 11 13

Challenge 1

http://swcarpentry.github.io/r-novice-gapminder/09-vectorization#challenge-1

comparison operators

x > 2
## [1] FALSE FALSE  TRUE  TRUE

** logical operators**

a <- x > 3  # or, for clarity, a <- (x > 3)
a
## [1] FALSE FALSE FALSE  TRUE

functions

x <- 1:4
log(x)
## [1] 0.0000000 0.6931472 1.0986123 1.3862944
m <- matrix(1:12, nrow=3, ncol=4)
m * -1
##      [,1] [,2] [,3] [,4]
## [1,]   -1   -4   -7  -10
## [2,]   -2   -5   -8  -11
## [3,]   -3   -6   -9  -12

Challenge #3

http://swcarpentry.github.io/r-novice-gapminder/09-vectorization/