A Diamond in the Rough

Lab 1F

Directions: Follow along with the slides, completing the questions in blue on your computer, and answering the questions in red in your journal.

Space, Click, Right Arrow or swipe left to move to the next slide.

Messy data? Get used to it

Messy data?

The American Time Use Survey

Load and go:


Description of ATU Variables

New name, same old data

atu_cleaner <- rename(atu_dirty, age = V1,
                       gender = V2)

Next up: Strings

"Hot Cocoa"

Numbers are words? (Sometimes)

Changing strings into numbers

## [1] 3.14

Mutating in action

atu_cleaner <- mutate(atu_cleaner, 
                 age = as.numeric(age),
                 ___ = as.numeric(___))

Deciphering Categorical Variables

Factors and Levels

tally(~gender, data = atu_cleaner)

A level by any other name…

atu_cleaner <- mutate(atu_cleaner, gender = 
                         "01" = "Male", 
                         "02" = "Female"))

Allow me to explain

atu_cleaner <- mutate(atu_cleaner, gender = 
                         "01" = "Male", 
                         "02" = "Female"))

Finish it off!

The final lines

atu_clean <- atu_cleaner
save(atu_clean, file = "atu_clean.Rda")

Flex your skills

histogram(~calories | healthy_level, data = food)