Lab: XKCD Color Survey

Author

Your Name Here

You can see the purpose of this assignment as well as the skills and knowledge you should be using and acquiring, in the Transparency in Learning and Teaching (TILT) document in this repository. The TILT document also contains a checklist for self-reflection that will provide some guidance on how the assignment will be graded.

1 A Shiny Color Survey

1.1 Setting Up and a basic Overview

For this lab, we’ll use the XKCD Color survey data. The TidyTuesday documentation is available here.

  1. The responses to the color survey are the basis for the 2010 xkcd blog entry Color Survey Results. Read the blog entry, pick two of the described findings and (try to) reproduce them. Show your code. In case you fail to reproduce the described findings describe the obstacle(s) you ran into.

  2. Colors are often reported in form of hexcodes. Hexcodes are a representation of the RGB (red green blue) color model and follow the format #RRGGBB, where RR stands for the amount of red in the color, coded as a hexadecimal number between 0 (= #00) and 255 (= #FF). Similarly, GG and BB encode the amount of green and blue in the color.

The RGB model allows to encode a total of \(16^2 \times 16^2 \times 16^2 = 2^{24} = 16,777,216\) ‘different’ colors.

Create a data frame rgb_df with variables r, g, and b on a regular grid (i.e. every 10th or every 16th value between 0 and 255). Use the function rgb to create a variable hex of hexcodes created from the r, g, and b values. Describe the resulting chart and remember to fill in the alt-text.

# Your code goes here

rgb_df |> ggplot(aes(x = r, y = g)) + geom_point(aes(colour = hex)) + scale_colour_identity() + facet_wrap(~b)
Error:
! object 'rgb_df' not found
  1. An alternative to the RGB color model is the HCL model. It specifies the dimensions hue, chroma, and luminance. Use the function decode_colour from the farver package to create coordinates h, c, l. Include those coordinates in the data frame rgb_df and explore the HCL space visually, similarly to the previous question. Summarise your findings and write an appropriate figure caption and alt text for ?@fig-hcl.
hcl <- farver::decode_colour(rgb_df$hex, to ="hcl")
Error:
! object 'rgb_df' not found
# Your code goes here
  1. The data set answers includes the hex codes that survey participants (user_id) summarised with one of the five top colors. rank 1 through 5 corresponds to the first five colors in the data set color_ranks, named purple, green, blue, pink, and brown. Include the HCL coordinates in the answers data set and visualize (a sample sample_n) of the answers data set. Describe the outcome. How much variability do you see in the responses for different colors (rank)?

Does excluding users with a high spam score (spam_prob in users) change the result?

# Your code goes here

1.2 Now make it shiny

Create a shiny app in R centered around the xkcd survey. You can pick any aspect you want, but the resulting shiny app should be based on actual data, have at least one chart, and at least two user input widgets that allow the user to interact with the results shown in the chart.

Include the code for the app in the file app.R.