Created
December 31, 2020 11:13
-
-
Save Lextuga007/e5d8c0d6ddd64ec84a6e7e3039a18908 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # create a tibble of month names (generated by copying over from Excel using {datapasta} :) | |
| birthmonth <- tibble::tribble( | |
| ~month_full, ~month_short, | |
| "January", "Jan", | |
| "February", "Feb", | |
| "March", "Mar", | |
| "April", "Apr", | |
| "May", "May", | |
| "June", "Jun", | |
| "July", "Jul", | |
| "August", "Aug", | |
| "September", "Sep", | |
| "October", "Oct", | |
| "November", "Nov", | |
| "December", "Dec" | |
| ) %>% | |
| mutate(month_full = factor(month_full, levels = month.name)) # this orders according to month name | |
| # check levels are correct from last mutate | |
| levels(birthmonth$month_full) | |
| # generate a sample data frame | |
| df <- data.frame( | |
| birthmonth = sample(birthmonth$month_full, 100, replace = TRUE) | |
| ) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment