Complete the code to change the second element of the vector to 10.
vec <- c(1, 2, 3) vec[[1]] <- 10 vec
The second element of the vector is accessed with index 2, so vec[2] <- 10 changes it to 10.
Complete the code to add the number 4 at the end of the vector.
vec <- c(1, 2, 3) vec <- c(vec, [1]) vec
vec + 4 which does not add elements.Using c(vec, 4) adds 4 to the end of the vector.
Fix the error in the code to correctly replace the third element with 7.
vec <- c(1, 2, 3) vec[[1]] <- 7 vec
The third element is at index 3, so vec[3] <- 7 correctly replaces it.
Fill both blanks to create a vector with elements 1, 2, 3, and then add 5 at the end.
vec <- c([1], [2], 3) vec <- c(vec, 5) vec
The vector starts with 1 and 2, then 3 is added. Then 5 is appended at the end.
Fill all three blanks to create a vector with elements 10, 20, 30, then replace the second element with 25.
vec <- c([1], [2], [3]) vec[2] <- 25 vec
The vector is created with 10, 20, 30. Then the second element (20) is replaced with 25.