Message-ID: <B6FC6FE6-8272-4CE5-AA72-334FEECA7679@neuwirth.priv.at>
Date: 2021-07-22T06:54:18Z
From: Erich Subscriptions
Subject: Assigning categorical values to dates
In-Reply-To: <b5dc3f68-fc47-4f6c-ad3b-aac57020e9ba@Canary>
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 at gmail.com> wrote:
>
>>> tibble(dates = c(rep("2021-07-04", 2), rep("2021-07-25", 3),
>>> rep("2021-07-18", 4)))