diff --git a/R/utils_charts.R b/R/utils_charts.R index 6803b47..05aa976 100644 --- a/R/utils_charts.R +++ b/R/utils_charts.R @@ -115,7 +115,7 @@ gpg_trend <- function(x, gpg_pyramid <- function(x, xvar = "afc_band", yvar, yaxis_title) { out <- tryCatch( - exp = { + expr = { data <- x # Create chart object plt <- data |> @@ -194,7 +194,7 @@ gpg_pyramid <- function(x, xvar = "afc_band", yvar, yaxis_title) { gpg_stack <- function(x, xvar, yvar, groupvar, yaxis_title) { out <- tryCatch( - exp = { + expr = { data <- x # Create chart object plt <- data |> diff --git a/man/gpg_data.Rd b/man/gpg_data.Rd index 3e79d37..4ad3d20 100644 --- a/man/gpg_data.Rd +++ b/man/gpg_data.Rd @@ -27,18 +27,20 @@ least seven columns: period, gender, hourly_rate, quartile, fte, afc_band, directorate. Once initiated, the class has six slots: -\code{df}: raw data frame -\code{df_hdcnt}: data frame contains headcount by period -\code{df_hdcnt_gender}: data frame contains headcount by gender by period -\code{df_hdcnt_afc}: data frame contains headcount by afc band -\code{df_hdcnt_dir}: data frame contains headcount by directorate -\code{df_hrrate}: data frame contains hourly rate by gender for each grade +\code{df}: raw data frame +\code{df_hdcnt}: data frame contains headcount by period +\code{df_hdcnt_gender}: data frame contains headcount by gender by period +\code{df_hdcnt_afc}: data frame contains headcount by afc band +\code{df_hdcnt_dir}: data frame contains headcount by directorate +\code{df_hrrate}: data frame contains hourly rate by gender for each grade \code{ending_fy}: a character vector containing ending reporting period (e.g. 31 March 2023). This uses for introduction paragraph } \examples{ - +\dontrun{ + library(nhsbsaGPG) df <- gpg_data(afc_staff) +} } diff --git a/man/paygap.Rd b/man/paygap.Rd index 2e19a52..1ca4916 100644 --- a/man/paygap.Rd +++ b/man/paygap.Rd @@ -12,14 +12,15 @@ paygap } \description{ A dataset containing NHSBSA employee paygap -Directly pulled from ESR dashboard (NHS National Returns) +Directly pulled from ESR dashboard (NHS National Returns) gender, average hourly rate, median hourly rate and pay gap% } \details{ \itemize{ \item period. 2018/19, 2019/20 etc character \item avg_hr_gpg. Mean gender pay gap % based on male full-pay relevant employees - \item median_hr_gpg. Median gender pay gap % based on male full-pay relevant employees - } + \item median_hr_gpg. Median gender pay gap % based + on male full-pay relevant employees +} } \keyword{datasets} diff --git a/man/quartile.Rd b/man/quartile.Rd index ab21d7b..41e328f 100644 --- a/man/quartile.Rd +++ b/man/quartile.Rd @@ -23,7 +23,7 @@ by quartiles \item male. number of male employees in each quartile \item quartile. split hourly_rate by quartile by gender } - + @docType data @keywords datasets @name quartile diff --git a/tests/testthat/test-utils_charts.R b/tests/testthat/test-utils_charts.R index b031074..1651d4a 100644 --- a/tests/testthat/test-utils_charts.R +++ b/tests/testthat/test-utils_charts.R @@ -1,7 +1,7 @@ library(tidyr) library(dplyr) -df <- gpg_data(afc_staff) +df <- gpg_data(nhsbsaGPG::afc_staff) x <- df$df_hdcnt_gender |> tidyr::pivot_wider( names_from = gender, @@ -11,8 +11,8 @@ x <- df$df_hdcnt_gender |> y <- nhsbsaGPG::paygap -z <- df$df_hdcnt_afc |> - filter(period == "2021/22") |> +z <- df$df_hdcnt_afc |> + filter(period == '2021/22') |> mutate(headcount = headcount * ifelse(gender == "Male", 1, -1)) testthat::test_that("gpg_trend function runs without errors", { @@ -47,8 +47,8 @@ testthat::test_that("gpg_trend takes list as an input", { testthat::test_that("gpg_trend input data frame must contain Female, Male column", { - expect_equal(length(grep("Female|Male", names(x))), 2) - }) + expect_equal(length(grep("Female|Male", names(x))), 2) +}) testthat::test_that("gpg_trend input data frame must contain period column", { @@ -69,14 +69,22 @@ testthat::test_that("gpg_trend function runs with paygap dataframe", { testthat::test_that("gpg_pyramid function runs without error", { - expect_silent(gpg_pyramid(z, xvar = "afc_band", yvar = "headcount", - yaxis_title = "Headcount" + expect_silent(gpg_pyramid(z , + xvar = "afc_band", + yvar = "headcount", + yaxis_title = "Headcount" )) }) testthat::test_that("gpg_stack function runs without error", { - expect_silent(gpg_stack(quartile |> filter(period == "2021/22"), - xvar = "quartile", yvar = "percent", groupvar = "ender", - yaxis_title = "Males and females in pay quartile" + expect_silent(gpg_stack(quartile |> filter(period == "2021/22") , + xvar = "quartile", + yvar = "percent", + groupvar = "gender", + yaxis_title = "Males and females in pay quartile" )) }) + + + +