Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a tidy data frame with columns 'name' and 'score'.
R Programming
data <- data.frame(name = c("Alice", "Bob"), score = c(85, [1]))
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a score lower than Alice's by mistake.
✗ Incorrect
The score for Bob should be 90 to complete the data frame correctly.
2fill in blank
mediumComplete the code to select only the 'score' column from the tidy data frame.
R Programming
library(dplyr)
scores <- data %>% select([1]) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Selecting the 'name' column instead of 'score'.
✗ Incorrect
We select the 'score' column to focus on the scores only.
3fill in blank
hardFix the error in the code to filter scores greater than 80.
R Programming
filtered <- data %>% filter(score [1] 80)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' which filters lower scores.
✗ Incorrect
To get scores greater than 80, use the '>' operator.
4fill in blank
hardFill both blanks to create a summary of average scores by name.
R Programming
summary <- data %>% group_by([1]) %>% summarise(avg_score = mean([2]))
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Grouping by wrong column or averaging wrong column.
✗ Incorrect
Group by 'name' and calculate mean of 'score' to summarize average scores.
5fill in blank
hardFill all three blanks to filter scores above 80, select 'name' and 'score', and arrange by score descending.
R Programming
result <- data %>% filter(score [1] 80) %>% select([2], [3]) %>% arrange(desc(score))
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong filter operator or selecting wrong columns.
✗ Incorrect
Filter scores greater than 80, select 'name' and 'score' columns, then arrange by descending score.