-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcleanWipData.R
58 lines (50 loc) · 1.55 KB
/
cleanWipData.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#Clean wip data
library(tidyverse)
rawWipData <- read_csv("wipData.csv")
tempWipData <-
rawWipData %>%
select(`Type of Work`, `Task Status`, `CMS Code`, `Quant Budget`,
`internal deadline`) %>%
drop_na() %>%
distinct() %>%
filter(`Type of Work` != "Tender") %>%
filter(`Task Status` == "Completed") %>%
select(-`Task Status`) %>%
mutate(`Quant Budget` = as.numeric(`Quant Budget`)) %>%
drop_na() %>%
filter(`Quant Budget` > 0) %>%
mutate(`internal deadline` = lubridate::dmy(`internal deadline`)) %>%
mutate(`proj year` = lubridate::year(`internal deadline`)) %>%
filter(`proj year` >= 2014) %>%
mutate(`proj year` = paste0("In ", `proj year`)) %>%
mutate(`proj date` =
paste0(
lubridate::month(`internal deadline`, label = TRUE), " ",
lubridate::year(`internal deadline`))) %>%
select(-`internal deadline`)
workGroupings <-
list(
"ALM" = c("Review", "ALM", "Funnel", "Intro to risk", "Triggers"),
"LDI" = c("LDI"),
"Structure" = c("Structure", "E(r)", "VaR"),
"Cashflows" = c("Cashflows", "cashflows", "cash flows"),
"3DA" = c("3D"),
"Other" = "NA"
)
assignGroup <- function(x) {
checkGroup <-
names(workGroupings) %>%
map(~sum(stringr::str_detect(x, workGroupings[[.x]])) > 0) %>%
simplify()
if (sum(checkGroup) > 0) {
names(workGroupings[checkGroup])
} else {
"Other"
}
}
cleanWipData <-
tempWipData %>%
rowwise() %>%
mutate(`Project Type` = assignGroup(`Type of Work`)) %>%
select(-`Type of Work`)
write_csv(cleanWipData, "cleanWipData.csv")