Skip to content

Instantly share code, notes, and snippets.

@jthomasmock
Created April 13, 2018 13:32
Show Gist options
  • Save jthomasmock/0e913316aa89dd1033e0caef646b0f88 to your computer and use it in GitHub Desktop.
Save jthomasmock/0e913316aa89dd1033e0caef646b0f88 to your computer and use it in GitHub Desktop.
Tidyr::fill example
# generate dataset with 1x year per every 12 months
df <- data.frame(Month = rep(1:12, 3),
Year = c(2000, rep(NA, 11),
2001, rep(NA, 11),
2002, rep(NA, 11)))
# view the funky dataset
df
# fill the dataset with missing year!
# and bask in the glory of the clean datset!
df %>%
fill(Year)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment