Tidying Data by Hadley Wickham
Tidying Data by Hadley Wickham
Tidying Data by Hadley Wickham
Hadley Wickham
Tuesday, October 23, 12
ht
tp
://
vim
eo
.c
om
/3
1. What is tidy data?
3 72
75
55
2. Five common causes of messiness
3. Tidying messy data (x5)
Male 0 5
Female 1 4
no female 4
no male 5
yes female 1
yes male 0
Rows Observations
Columns Variables
library(reshape2)
?melt
?dcast
?col_split
library(stringr)
?str_replace
?str_sub
?str_split_fixed
library(plyr)
?arrange
head(raw)
library(reshape2)
tidy <- melt(raw, "religion")
head(tidy)
# casting syntax:
# row_var1 + row_var2 ~ col_var1 + col_var2
# ... = all variables not otherwise mentioned