Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to chain the operations using the pipe operator.
R Programming
library(dplyr) data <- data.frame(x = 1:5, y = 6:10) result <- data [1] filter(x > 2)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using other pipe operators like %$% or %T>% which have different purposes.
✗ Incorrect
The pipe operator %>% passes the data to the next function.
2fill in blank
mediumComplete the code to select column 'y' after filtering.
R Programming
library(dplyr) data <- data.frame(x = 1:5, y = 6:10) result <- data %>% filter(x > 2) [1] select(y)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using different pipe operators that do not chain functions properly.
✗ Incorrect
Use %>% again to continue chaining operations.
3fill in blank
hardFix the error in the pipe chain to calculate the mean of column 'y'.
R Programming
library(dplyr) data <- data.frame(x = 1:5, y = 6:10) mean_y <- data %>% filter(x > 2) [1] summarise(mean_y = mean(y))
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using %$% which exposes variables but does not chain properly here.
✗ Incorrect
The pipe operator %>% correctly passes the filtered data to summarise.
4fill in blank
hardFill both blanks to create a pipe chain that filters and then mutates a new column.
R Programming
library(dplyr) data <- data.frame(x = 1:5, y = 6:10) result <- data [1] filter(x >= 3) [2] mutate(z = y * 2)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing different pipe operators in the same chain.
✗ Incorrect
Use %>% to chain both filter and mutate operations.
5fill in blank
hardFill all three blanks to chain filter, mutate, and then select columns.
R Programming
library(dplyr) data <- data.frame(x = 1:5, y = 6:10) result <- data [1] filter(x < 5) [2] mutate(z = y + 1) [3] select(x, z)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using different pipe operators that break the chain.
✗ Incorrect
Use %>% consistently to chain all operations in order.