###########
library(lubridate)
library(dplyr)
library(tidyr)
length.out = length(seq(as.Date("2025-03-01"), as.Date("2025-03-31"),by="day"))
date_df <- tibble(
date = rep(seq(as.Date("2025-03-01"), as.Date("2025-03-31"), by = "day"), each = 3),
A3 = rep(1:3, length.out = 93),
day = rep(weekdays(seq(as.Date("2025-03-01"), as.Date("2025-03-31"), by = "day")), each = 3),
A1 = ifelse(rep(weekdays(seq(as.Date("2025-03-01"), as.Date("2025-03-31"), by = "day")), each = 3) == "Sunday", 0, rep(1:3, length.out)),
A2 = ifelse(rep(weekdays(seq(as.Date("2025-03-01"), as.Date("2025-03-31"), by = "day")), each = 3) != "Sunday" & rep(1:3, length.out ) == 1, 1, 0)
) %>%
mutate(day_group = case_when(
day %in% c("Monday", "Tuesday", "Wednesday", "Thursday", "Friday") ~ "Weekdays",
day %in% c("Saturday", "Sunday") ~ "Weekend"
))%>%
mutate(week_group=week(date))%>%
mutate(A2= case_when(week_group==11|week_group==14~ A2*3,
week_group == 9| week_group==12 ~ A2*2,
week_group == 10| week_group==13 ~ A2*1,
TRUE ~ 0
))
head( date_df)
#In column A2 i want to have value 2 Aligned with 2 from column A3 and 3 Aligned with 3 from #column A3 ,and 1 from A2 column Aligned with 1 from column A3