Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to exclude the second element from the vector.
R Programming
vec <- c(10, 20, 30, 40) result <- vec[[1]] print(result)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using positive index includes the element instead of excluding it.
✗ Incorrect
Using -2 excludes the second element from the vector.
2fill in blank
mediumComplete the code to exclude the first and third elements from the vector.
R Programming
vec <- c(5, 15, 25, 35) result <- vec[[1]] print(result)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using positive indices includes those elements instead of excluding them.
✗ Incorrect
Using -c(1, 3) excludes the first and third elements from the vector.
3fill in blank
hardFix the error in the code to exclude the last element from the vector.
R Programming
vec <- c(2, 4, 6, 8) result <- vec[[1]] print(result)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using positive length(vec) includes only the last element instead of excluding it.
✗ Incorrect
Using -length(vec) excludes the last element by negative indexing with the vector length.
4fill in blank
hardFill both blanks to exclude the second and fourth elements from the vector.
R Programming
vec <- c(3, 6, 9, 12, 15) result <- vec[[1]([2])] print(result)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using positive indices includes elements instead of excluding them.
✗ Incorrect
Using -c(2, 4) excludes the second and fourth elements from the vector.
5fill in blank
hardFill all three blanks to exclude the first, third, and fifth elements from the vector.
R Programming
vec <- c(7, 14, 21, 28, 35, 42) result <- vec[[1]([2])] print(result) # The excluded elements are [3].
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using positive indices includes elements instead of excluding them.
✗ Incorrect
Using -c(1, 3, 5) excludes the first, third, and fifth elements, which are 7, 21, and 35.