Complete the code to add two vectors element-wise.
result <- c(1, 2, 3) [1] c(4, 5, 6)
- instead of + causes subtraction.In R, the + operator adds vectors element-wise.
Complete the code to multiply two vectors element-wise.
result <- c(2, 4, 6) [1] c(3, 5, 7)
+ adds instead of multiplies.The * operator multiplies vectors element-wise in R.
Fix the error in the code to subtract vectors element-wise.
result <- c(5, 7, 9) [1] c(1, 2, 3)
+ adds instead of subtracts.The - operator subtracts vectors element-wise in R.
Fill both blanks to divide two vectors element-wise and assign to result.
result <- c(10, 20, 30) [1] c(2, 4, 5) [2] 2
+ or - instead of division or multiplication.The / operator divides vectors element-wise. The * operator multiplies the result by 2.
Fill all three blanks to create a vector of squared differences between two vectors.
result <- (c(3, 6, 9) [1] c(1, 2, 3)) [2] [3]
+ instead of subtraction.* instead of exponentiation.Subtract vectors element-wise with -, then raise to the power ^ of 2 to square the differences.
