Data Untangled: Transforming and Cleaning Data with dplyr
Participants 167
This quiz tests your knowledge of the concepts of “wide” and “long” data, as well as your ability to use the pivot_longer()
and pivot_wider()
functions from {tidyr}.
Quiz Summary
0 of 4 Questions completed
Questions:
Information
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading…
You must sign in or sign up to start the quiz.
You must first complete the following:
Results
Results
Time has elapsed
You have reached 0 of 0 point(s), (0)
Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)
Average score |
|
Your score |
|
Categories
- Not categorized 0%
-
Daww you didn’t pass. Keep trying. You need to score at least 80% to pass.
-
Good! You scored up to 80%. You have won a bronze medal. This earns you 1 brainpoint! Go for gold (a perfect score) and get 100 brain points!
-
Very good! You scored up to 90%. You have won a silver medal. This earns you 10 brainpoints! Go for gold (a perfect score) and get 100 brain points!
-
Congrats! You scored 100%. You have won a gold medal. This earns you 100 brainpoints!
Pos. | Name | Entered on | Points | Result |
---|---|---|---|---|
Table is loading | ||||
No data available | ||||
- 1
- 2
- 3
- 4
- Current
- Review
- Answered
- Correct
- Incorrect
-
Question 1 of 4
1. Question
Is the statement below TRUE or FALSE?
Wide format data is usually better for making plots with ggplot2 in R.
CorrectIncorrect -
Question 2 of 4
2. Question
Answer TRUE or FALSE
For presenting time series data in a table, a long format is usually better, since it is easy to spot trends in this format.
CorrectIncorrect -
Question 3 of 4
3. Question
Consider the following subset of the
relig_income
dataset fromtidyr
, which shows, in a wide format, the number of respondents who have an income range in column name:relig_income_subset <- tidyr::relig_income %>% select(1:4) %>% head() relig_income_subset
## # A tibble: 6 × 4 ## religion `<$10k` `$10-20k` `$20-30k` ## <chr> <dbl> <dbl> <dbl> ## 1 Agnostic 27 34 60 ## 2 Atheist 12 27 37 ## 3 Buddhist 27 21 30 ## 4 Catholic 418 617 732 ## 5 Don’t know/refused 15 14 15 ## 6 Evangelical Prot 575 869 1064
Which of the following code chunks will successfully pivot the wide data into a long format?
CorrectIncorrect -
Question 4 of 4
4. Question
Consider the following mock dataset showing the number of cases of an unnamed diseases in three countries over time:
mock_long_data <- bind_cols(expand_grid(country = c("Chad", "Iran", "Peru"), year = 2000:2003), num_of_cases = sample(1:20, 12)) mock_long_data
## # A tibble: 12 × 3 ## country year num_of_cases ## <chr> <int> <int> ## 1 Chad 2000 9 ## 2 Chad 2001 8 ## 3 Chad 2002 15 ## 4 Chad 2003 10 ## 5 Iran 2000 2 ## 6 Iran 2001 13 ## 7 Iran 2002 14 ## 8 Iran 2003 5 ## 9 Peru 2000 11 ## 10 Peru 2001 12 ## 11 Peru 2002 3 ## 12 Peru 2003 19
Which of the following code chunks will successfully pivot the long data into an appropriate wide format?
CorrectIncorrect