Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Department names #68

Merged
merged 4 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ temp/
*.csv
*.rda
exploratory_scripts/
docs/
4 changes: 3 additions & 1 deletion R/data_cleaning.R
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,15 @@ rename_cols <- function(data) {

clean_departments <- function(data) {

data$department[grepl("forest research", tolower(data$other_department_name))] <- "Forestry Commission"
data$department[data$department == "Foreign, Commonwealth & Development Office (excl. agencies)"] <- "Foreign, Commonwealth and Development Office (excl. agencies)"

data$department[data$workplace == "NHS"] <- "NHS"

defra_orgs <- c(
"Department for Environment, Food and Rural Affairs (excl. agencies)",
"Forestry Commission",
"Forest Research",
"Forestry England",
"Animal and Plant Health Agency",
"Centre for Environment, Fisheries and Aquaculture Science",
"Rural Payments Agency",
Expand Down
3 changes: 3 additions & 0 deletions R/render.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ create_filtered_pages <- function(data, type = c("professions", "departments"),

if (type == "professions") {
prof_cols <- c(
"prof_DE",
"prof_DS",
"prof_DDAT",
"prof_GAD",
Expand All @@ -52,6 +53,7 @@ create_filtered_pages <- function(data, type = c("professions", "departments"),
)

prof_names <- c(
"government data engineers",
"government data scientists",
"digital and data profession (DDAT)",
"government actuary's department (GAD)",
Expand All @@ -63,6 +65,7 @@ create_filtered_pages <- function(data, type = c("professions", "departments"),
)

filenames <- c(
"data-engineers.qmd",
"data-scientists.qmd",
"digital-and-data.qmd",
"government-actuarys-department.qmd",
Expand Down
18 changes: 11 additions & 7 deletions tests/testthat/test-clean_departments.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,36 @@ test_that("clean_departments output is as expected", {

dummy_data <- data.frame(department = c(NA,
"test",
"test",
"Foreign, Commonwealth & Development Office (excl. agencies)",
"Department for Environment, Food and Rural Affairs (excl. agencies)",
"Forestry Commission",
"Forest Research",
"Forestry England",
"Animal and Plant Health Agency",
"Centre for Environment, Fisheries and Aquaculture Science",
"Rural Payments Agency",
"Environment Agency",
"Marine Management Organisation",
"Natural England"),
other_department_name = c(NA, "Forest research", rep("test", 8)),
workplace = c(NA, "test", "NHS", rep("test", 7)))
workplace = c(NA, "NHS", rep("test", 11)))

got <- clean_departments(dummy_data)

expected <- data.frame(department = c(NA,
"Forestry Commission",
"NHS",
"Foreign, Commonwealth and Development Office (excl. agencies)",
"Department for Environment, Food and Rural Affairs (excl. agencies)",
"Forestry Commission",
"Forest Research",
"Forestry England",
"Animal and Plant Health Agency",
"Centre for Environment, Fisheries and Aquaculture Science",
"Rural Payments Agency",
"Environment Agency",
"Marine Management Organisation",
"Natural England"),
other_department_name = c(NA, "Forest research", rep("test", 8)),
workplace = c(NA, "test", "NHS", rep("test", 7)),
defra = c(FALSE, TRUE, FALSE, rep(TRUE, 7)))
workplace = c(NA, "NHS", rep("test", 11)),
defra = c(rep(FALSE, 3), rep(TRUE, 10)))

expect_equal(got, expected)

Expand Down