[R] Assigning categorical values to dates
Erich Subscriptions
er|ch@@ub@ @end|ng |rom neuw|rth@pr|v@@t
Thu Jul 22 08:54:18 CEST 2021
date_df <- tibble(dates = c(rep("2021-07-04", 2), rep("2021-07-25", 3),
rep("2021-07-18", 4)))
cycle_from_date <- function(date,dates){
dates |>
unique() |>
sort() ->
ranks
match(date,ranks)
}
date_df |>
mutate(cycle_new=cycle_from_date(dates,dates))
> On 22.07.2021, at 05:46, N. F. Parsons <nathan.f.parsons using gmail.com> wrote:
>
>>> tibble(dates = c(rep("2021-07-04", 2), rep("2021-07-25", 3),
>>> rep("2021-07-18", 4)))
More information about the R-help
mailing list