#> # A tibble: 5 × 2
#> Visual.acuity n
#> <fct> <int>
#> 1 Very Poor 1
#> 2 Poor 4
#> 3 Average 15
#> 4 Good 53
#> 5 Excellent 67
Quiz 17 Instructions
Please complete the following questions and submit a file named Quiz17.R to Gradescope for autograding.
Remember:
- Do not use global paths in you script. Instead, use setwd() interactively in the console, but do not forget to remove or comment out this part of the code before you submit. The directory structure of your machine is not the same as the one on Gradescope’s virtual machines.
- Do not destroy or overwrite any variables in your program. I check them only after I have run your entire program from start to finish.
- Check to make sure you do not have any syntax errors. Code that doesn’t run will get a very bad grade.
- Make sure to name your submission Quiz17.R
- Don’t forget to use
library(tidyverse)
at the beginning of Quiz17.R.
Tip: before submitting, it might help to clear all the objects from your workspace, and then source your file before you submit it. This will often uncover bugs.
Please download the CSV data survey_visual_device for this quiz.
Question 1
- [2 pts] Use
fct_relevel()
to reorder the levels ofVisual.acuity
toc("Very Poor", "Poor", "Average", "Good", "Excellent")
. Find and save the count summary table ofVisual.acuity
asvisual_acuity_count
. The table should look like:
- [2 pts] Use
fct_rev()
to reverse the order of the levels ofVisual.acuity
from (a). Find and save the count summary table asvisual_acuity_rev_count
.
Question 2
On the Reaction Time Statistics page, it suggests: mobile device “taps” tend to be a bit slower than “clicks”. Is it true according to survey_visual_device
data?
- [2 pts] Use
fct_collapse()
to combine the “Touch screen” and “Trackpad” categories into “tap”, and merge the remaining three categories (“Mouse”, “Keyboard”, “Game controller”) into “click”. Name the new variable astapclick
.
- [2 pts] Use
ggplot
to create a box-plot withtapclick
on the x-axis, andReaction.time
on the y-axis. Label the \(x\)-axis asInput Device
and the \(y\)-axis asReaction Time
. Save the plot astapclick_boxplot.png
usingggsave(..., width = 10, height = 8, dpi = 300)
.
Question 3
- [2 pts] Draw a bar chart of the frequency of different
Device.OS
values, ensuring the bars are arranged in descending order. You may usefct_infreq()
to achieve this. Label the \(x\)-axis asDevice OS
and the \(y\)-axis asCount
. Save the plot asdevice_barchart.png
usingggsave(..., width = 10, height = 8, dpi = 300)
.
- [2 pts] From the bar chart in (a), we can see several small counts. Please use
fct_lump_min()
to lumps levels appear fewer than 10 times as “Other”. Save the new variable asdevice_lump
and count the frequency of each category. Save the summary table asdevice_lump_count
.
- [2 pts] Draw a bar chart of the frequency of different
device_lump
values, ensuring the bars are in descending order. Label the \(x\)-axis asDevice OS
and the \(y\)-axis asCount
. Save the plot asdevice_lump_barchart.png
usingggsave(..., width = 10, height = 8, dpi = 300)