Skip to content

Instantly share code, notes, and snippets.

@keithmcnulty
Last active July 16, 2020 11:36
Show Gist options
  • Select an option

  • Save keithmcnulty/e76a4be0cda144c997e4d96852234412 to your computer and use it in GitHub Desktop.

Select an option

Save keithmcnulty/e76a4be0cda144c997e4d96852234412 to your computer and use it in GitHub Desktop.
wide_storms %>%
tidyr::pivot_longer(-status, names_to = c("stat", "year"),
names_pattern = "(.*)_of_(.*)",
values_to = "value")
#> # A tibble: 18 x 4
#> status stat year value
#> <chr> <chr> <chr> <dbl>
#> 1 hurricane mean 1975 977.
#> 2 hurricane mean 1976 975.
#> 3 hurricane mean 1977 978.
#> 4 hurricane median 1975 984
#> 5 hurricane median 1976 975
#> 6 hurricane median 1977 987
#> 7 tropical depression mean 1975 1011.
#> 8 tropical depression mean 1976 1007.
#> 9 tropical depression mean 1977 1011.
#> 10 tropical depression median 1975 1012.
#> 11 tropical depression median 1976 1006.
#> 12 tropical depression median 1977 1010
#> 13 tropical storm mean 1975 992.
#> 14 tropical storm mean 1976 995.
#> 15 tropical storm mean 1977 1002.
#> 16 tropical storm median 1975 993
#> 17 tropical storm median 1976 994.
#> 18 tropical storm median 1977 1001
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment