14 Mid-semester review
NoteLearning goals
Review the basics of wrangling and visualization
14.1 Warm-up

Recall the major themes of our work thus far:
- Getting to know your data
- key functions:
head(),dim(),nrow(),class(),str()
- key functions:
- Data visualization
- picking an appropriate plot / evaluating the appropriateness of a plot
- interpreting the results of a plot
- building effective plots that are accessible and “professional”
- key functions:
ggplot()geom_bar(),geom_density(),geom_boxplot(),geom_histogram(),geom_point(),geom_line(),geom_smooth()facet_wrap()
- key features:
color,fillfig.alt,fig.caption
- Data preparation: wrangling data
- goals
- wrangle our data
- obtain numerical summaries of our data
- key functions
arrange()our data in a meaningful order- subset the data to only
filter()the rows andselect()the columns of interest mutate()existing variables and define new variablessummarize()various aspects of a variable, both overall and by group (group_by())count()up the number of instances of an outcome or set of outcomes
- goals
- Data preparation: reshaping data
- goal: reshape our data to fit the task at hand
- functions: -
pivot_longer()-pivot_wider()
- Data preparation: joining data
- goal: join different datasets into one
- functions
- mutating joins which combine columns of different datasets:
left_join(),inner_join(),full_join() - filtering joins which filter rows according to membership / non-membership in another dataset:
semi_join(),anti_join()
- mutating joins which combine columns of different datasets:
- Data preparation: working with factor variables
- goals:
- turn character variables into factor variables (when necessary)
- turn factor variables into more meaningful factor variables
- key functions:
- reordering categories / levels:
fct_relevel(),fct_reorder() - change category labels:
fct_recode()
- reordering categories / levels:
- goals:
- Data preparation: working with strings
- goal: detect, replace, or extract certain patterns from character strings
- key functions: - return a modified string:
str_replace(),str_replace_all(),str_to_lower(),str_sub(),str_extract()- return a set of TRUE/FALSE:str_detect()- return a number:str_length()
We’ll practice SOME of these concepts today. Important caveats:
- This activity is NOT an exhaustive review – it doesn’t cover every topic or every type of question you’ll be asked.
- Be kind to yourself! If you haven’t started studying / reviewing yet, this might feel bumpy.
14.2 Part 1: What’s the verb? Game!
Goal: Review some of the functions we’ve learned.
Directions:
- In your table group, take turns writing the answer on the Part 1 activity.
- Switch every question.
- If you are the one writing, you cannot say the answer but could guide others in your group.
- This structure is intended to support your learning and establish equity in the group.
You’ll have 15 minutes to complete this activity, and we’ll review it together afterwards.
14.3 Part 2: Quiz practice
Goal: Practice some problems that are more in the style of the quiz questions. These give you a sense of the structure, vibe, and types of questions that might be asked so that none of that comes as a surprise.
Directions:
- In your table group, take turns writing the answer on the Part 2 activity.
- Switch every question.
- If you are the one writing, you cannot say the answer but could guide others in your group.
- This structure is intended to support your learning and establish equity in the group.
Once you’ve completed your work, work on Homework 6 (or anything else related to this class).
14.4 Wrap-up
Homework 6 is due 4/2.
Quiz 2 is next Tuesday in class.
- All information is available on the Quiz Information page.