Vectorized Operations Flashcards
1
Q
Why are vectorized operations useful?
A
prevent you from having to write for loops and allow you to operate on elements of a vector in parallel
2
Q
x <- 1:5. What does the expression x > 2 return?
A
a logical vector with the values:
FALSE FALSE TRUE TRUE TRUE
3
Q
How do you multiple the elements of two vectors x and y?
A
x * y
4
Q
Given two vectors, x <- c(1, 2, 3) and y <- c(4, 5, 6), what results from the expression x / y?
A
[1] 0.25 0.40 0.50