Thanksgiving Dinner

Survey data, Network graphing

Published

November 20, 2018

Notable topics: Survey data, Network graphing

Recorded on: 2018-11-20

Timestamps by: Alex Cookson

View code

Screencast

Timestamps

Exploratory bar chart of age distribution (and gender) of survey respondents

Using count function on multiple columns to get detailed counts

Parsing numbers from text using parse_number function, then using those numbers to re-level an ordinal factor (income bands)

Exploring relationship between income and using homemade (vs. canned) cranberry sauce

Adding group = 1 argument to the aes function to properly display a line chart

Rotating text for axis labels that overlap

qbeta

Getting confidence intervals for proportions using Jeffreys interval (using beta distribution with an uniformative prior)

Explanation of Clopper-Pearson approach as alternative to Jeffreys interval

geom_ribbon

Using geom_ribbon function add shaded region to line chart that shows confidence intervals

starts_with

Using starts_with function to select fields with names that start with a certain string (e.g., using "pie" selects "pie1" and "pie2")

gather

Using gather function to get wide-format data to tidy (tall) format

str_remove

Using str_remove and regex to remove digits from field values (e.g., "dessert1" and "dessert2" get turned into "dessert")

"What are people eating?" Graphing pies, sides, and desserts

fct_reorder

Using fct_reorder function to reorder foods based on how popular they are

n_distinct

Using n_distinct function count the number of unique respondents

Using facet_wrap function to facet food types into their own graphs

parse_number

Using parse_number function to convert age ranges as character string into a numeric field

Exploring relationship between US region and food types

Using group_by, then mutate, then count to calculate a complicated summary

Exploring relationship between praying at Thanksgiving (yes/no) and food types

add_ebb_estimate
ebbr

Empirical Bayes binomial estimation for calculating binomial confidence intervals (see Dave's book on Empirical Bayes)

Asking, "What sides/desserts/pies are eaten together?"

pairwise_cor
widyr

Calculating pairwise correlation of food types

ggraphigraph

Network graph of pairwise correlation

geom_node_text
ggraphigraph

Adding text labels to nodes using geom_node_text function

theme_void

Getting rid of unnecessary graph elements (e.g., axes, gridlines) with theme_void function

Explanation of network graph relationships

Adding dimension to network graph (node colour) to represent the type of food

geom_node_text
ggraphigraph

Fixing overlapping text labels using the geom_node_text function's repel argument

scales

Tweaking display of percentage legend to be in more readable format (e.g., "40%" instead of "0.4")

Summary of screencast