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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

x <- 1:5. What does the expression x > 2 return?

A

a logical vector with the values:
FALSE FALSE TRUE TRUE TRUE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do you multiple the elements of two vectors x and y?

A

x * y

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly