I have a df1 with a column called df1$date ( already turned into a date)
I need to create a flag called "net new" for any rows within the df1 that land between "2022-02-01" & "2022-04-30"
Thank you so much for your help!
df1 = df1 %\>%
mutate(Net_New = `Sales Order Line Item SO Line Create Date` %within% (
ymd("2022-02-01"),
ymd("2022-04-30"))
) == TRUE \~ TRUE
)
Tried to create a column called Net New for a TRUE and FALSE but did not get close to it working.
CodePudding user response:
We may use between
library(dplyr)
library(lubridate)
df1 %>%
mutate(New_new = between(date, ymd("2022-02-01"), ymd("2022-04-30")))