dplyr: pivots, data types, and importing data

Lecture 10?

Dr. Elijah Meyer

NC State University
ST 295 - Spring 2025

2025-02-13

Checklist

– Have you cloned the today’s AE repo?

– Are you keeping up with prepare material?

– Homework-2 is graded!

– No Quiz this week

Announcements

Thank you for providing feedback on Quiz-4!

– basic ML models like regression, classification

– wrangling data in an efficient and reproducible way

– regression analysis and hypothesis testing

– using tidyverse for data analysis

– improve data visualization skills

Announcements

We have an exam soon (Feb-20th)

Exam-1 is worth 20% of your grade, split equally between

– In-class exam

– Take-home exam

In-class exam

– Closed computer

– Bring handwritten 8x11 sheet of paper (front and back)

Types of questions

– Multiple choice; True False; Short answer; Fill in the blank

– Plot critiques

– What would code produce

Questions?

Take-home exam

– Think about this as a more involved homework

– Questions geared towards applying what we have learned

– Extension question that pushes you to explore something new

Questions?

Homework-2

library(palmerpenguins)

mean_bill <- penguins |>
  summarise(mean_bl = mean(bill_length_mm))

mean_bill # this is unnecessary 

Homework-2

penguins |> # short comments to explain code are very helpful
  summarise(mean_bl = mean(bill_length_mm, na.rm = T)) # and a very good habit

# but we want to make sure that we don't put a large amount of text as a comment. The nice thing about Quarto is that is renders together text, code, and output. Any text that isn't a helpful quick code comment should go outside of our code chunk

Warm-up

What are Wide data? What are Long data?

Warm-up

What are Wide data? What are Long data?

Wide data contains values that do not repeat in the first column

Long data contains values that do repeat in the first column

pivot_wider

pivot_wider

– Making tables for quick comparison / display purposes

names_from

values_from

AE