What I am trying to achieve is allocate a new column with a variable that changes over time. It is just one of them that is changing so what I would like to do is After (date) put 40 instead if 22
I currently have this Code that is not working properly
Idea:
if(lst$taskDate <= as.Date("2018-11-18")){
t2$Budget <- case_when(
t2$taskStaffName == "L" ~ 20,
t2$taskStaffName == "J" ~ 22,
TRUE ~ 40
)
}else{
if(lst$taskDate >= as.Date("2018-11-19"))
t2$Budget <- case_when(
t2$taskStaffName == "L" ~ 20,
t2$taskStaffName == "J" ~ 40,
TRUE ~ 40
)
}
This is the Data Sample:
# A tibble: 3,692 x 4
taskStaffName taskDate taskMinutes taskBillable
<chr> <date> <chr> <chr>
1 G 2018-07-02 300 true
2 G 2018-07-02 180 true
3 L 2018-07-02 300 true
4 L 2018-07-02 180 false
5 C 2018-07-02 360 false
6 C 2018-07-02 120 false
7 G 2018-07-03 480 true
8 L 2018-07-03 30 true
9 L 2018-07-03 180 true
10 L 2018-07-02 30 true
# ... with 3,682 more rows
Desired Outcome:
# A tibble: 3,692 x 5
taskStaffName taskDate taskMinutes taskBillable Budget
<chr> <date> <chr> <chr> <dbl>
1 J 2018-07-02 300 true 22
2 J 2018-07-02 180 true 22
3 L 2018-07-02 300 true 20
4 L 2018-07-02 180 false 20
5 C 2018-07-02 360 false 40
6 C 2018-07-02 120 false 40
7 L 2018-07-03 480 true 20
8 L 2018-07-03 30 true 20
9 J 2018-11-19 180 true 40
10 J 2018-11-19 30 true 40
# ... with 3,682 more rows
Aucun commentaire:
Enregistrer un commentaire