Hi everyone,
do you know how can i create a new column with the values of another?
this is my dataframe
structure(list(weeks = c(1, 5, 2, 3, 6, 4, 8, 12, 53, 52, 12,
6, 35, 45, 50), time = c(1, 4, 1, 2, 5, 3, 7, 11, 52, 50, 11,
5, 20, 40, 49)), class = "data.frame", row.names = c(NA, 15L))
and this is what i want to get:
structure(list(weeks = c(1, 5, 2, 3, 6, 4, 8, 12, 53, 52, 12,
6, 35, 45, 50), QT = c("Q1", "Q1", "Q1", "Q1", "Q1", "Q1", "Q1",
"Q1", "Q4", "Q4", "Q1", "Q1", "Q3", "Q4", "Q4"), time = c(1,
4, 1, 2, 5, 3, 7, 11, 52, 50, 11, 5, 20, 40, 49)), class = "data.frame", row.names = c(NA,
15L))
and this is my code:
w |>
mutate(QT=case_when (w$weeks(1%in%12)~Q1,
w$weeks(13%in%25)~Q2,
w$weeks(26%in%39)~Q3,
w$weeks(40%in%53)~Q4
))
i get this error:
Error in mutate(w, QT = case_when(w$weeks(1 %in% 12) ~ Q1, w$weeks(13 %in% :
Caused by error:
! attempt to apply non-function
thanks in advance