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

  1. [2 pts] Use fct_relevel() to reorder the levels of Visual.acuity to c("Very Poor", "Poor", "Average", "Good", "Excellent"). Find and save the count summary table of Visual.acuity as visual_acuity_count. The table should look like:
#> # 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
  1. [2 pts] Use fct_rev() to reverse the order of the levels of Visual.acuity from (a). Find and save the count summary table as visual_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?

  1. [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 as tapclick.
  1. [2 pts] Use ggplot to create a box-plot with tapclick on the x-axis, and Reaction.time on the y-axis. Label the \(x\)-axis as Input Device and the \(y\)-axis as Reaction Time. Save the plot as tapclick_boxplot.png using ggsave(..., width = 10, height = 8, dpi = 300).

Question 3

  1. [2 pts] Draw a bar chart of the frequency of different Device.OS values, ensuring the bars are arranged in descending order. You may use fct_infreq() to achieve this. Label the \(x\)-axis as Device OS and the \(y\)-axis as Count. Save the plot as device_barchart.png using ggsave(..., width = 10, height = 8, dpi = 300).
  1. [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 as device_lump and count the frequency of each category. Save the summary table as device_lump_count.
  1. [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 as Device OS and the \(y\)-axis as Count. Save the plot as device_lump_barchart.png using ggsave(..., width = 10, height = 8, dpi = 300)