From 32c10e5a80b21c3ccdfda0e2f7ae8a99cfe12a56 Mon Sep 17 00:00:00 2001 From: Jennit07 <67372904+Jennit07@users.noreply.github.com> Date: Wed, 16 Aug 2023 15:18:35 +0100 Subject: [PATCH] Add new function for counting records by sending location (#782) * New function `create_sending_location_test_flags` --- R/create_sending_location_test_flags.R | 48 +++++++++++++++++++++++ man/create_demog_test_flags.Rd | 3 +- man/create_hb_cost_test_flags.Rd | 3 +- man/create_hb_test_flags.Rd | 3 +- man/create_hscp_test_flags.Rd | 3 +- man/create_lca_test_flags.Rd | 3 +- man/create_sending_location_test_flags.Rd | 28 +++++++++++++ 7 files changed, 86 insertions(+), 5 deletions(-) create mode 100644 R/create_sending_location_test_flags.R create mode 100644 man/create_sending_location_test_flags.Rd diff --git a/R/create_sending_location_test_flags.R b/R/create_sending_location_test_flags.R new file mode 100644 index 000000000..373dc2c03 --- /dev/null +++ b/R/create_sending_location_test_flags.R @@ -0,0 +1,48 @@ +#' Create sending location test flags +#' +#' @description Create flags for sending location +#' +#' @param data the data containing the variable sending_location +#' @param sending_location_var sending_location variable +#' @return a dataframe with flag (T or F) for each sending location +#' +#' @family flag functions +create_sending_location_test_flags <- function(data, sending_location_var) { + data <- data %>% + dplyr::mutate( + Aberdeen_City = {{ sending_location_var }} == 100L, + Aberdeenshire = {{ sending_location_var }} == 110L, + Angus = {{ sending_location_var }} == 120L, + Argyll_and_Bute = {{ sending_location_var }} == 130L, + City_of_Edinburgh = {{ sending_location_var }} == 230L, + Clackmannanshire = {{ sending_location_var }} == 150L, + Dumfries_and_Galloway = {{ sending_location_var }} == 170L, + Dundee_City = {{ sending_location_var }} == 180L, + East_Ayrshire = {{ sending_location_var }} == 190L, + East_Dunbartonshire = {{ sending_location_var }} == 200L, + East_Lothian = {{ sending_location_var }} == 210L, + East_Renfrewshire = {{ sending_location_var }} == 220L, + Falkirk = {{ sending_location_var }} == 240L, + Fife = {{ sending_location_var }} == 250L, + Glasgow_City = {{ sending_location_var }} == 260L, + Highland = {{ sending_location_var }} == 270L, + Inverclyde = {{ sending_location_var }} == 280L, + Midlothian = {{ sending_location_var }} == 290L, + Moray = {{ sending_location_var }} == 300L, + Na_h_Eileanan_Siar = {{ sending_location_var }} == 235L, + North_Ayrshire = {{ sending_location_var }} == 310L, + North_Lanarkshire = {{ sending_location_var }} == 320L, + Orkney_Islands = {{ sending_location_var }} == 330L, + Perth_and_Kinross = {{ sending_location_var }} == 340L, + Renfrewshire = {{ sending_location_var }} == 350L, + Scottish_Borders = {{ sending_location_var }} == 355L, + Shetland_Islands = {{ sending_location_var }} == 360L, + South_Ayrshire = {{ sending_location_var }} == 370L, + South_Lanarkshire = {{ sending_location_var }} == 380L, + Stirling = {{ sending_location_var }} == 390L, + West_Dunbartonshire = {{ sending_location_var }} == 395L, + West_Lothian = {{ sending_location_var }} == 400L + ) + + return(data) +} diff --git a/man/create_demog_test_flags.Rd b/man/create_demog_test_flags.Rd index b555b1699..589877738 100644 --- a/man/create_demog_test_flags.Rd +++ b/man/create_demog_test_flags.Rd @@ -21,6 +21,7 @@ Other flag functions: \code{\link{create_hb_cost_test_flags}()}, \code{\link{create_hb_test_flags}()}, \code{\link{create_hscp_test_flags}()}, -\code{\link{create_lca_test_flags}()} +\code{\link{create_lca_test_flags}()}, +\code{\link{create_sending_location_test_flags}()} } \concept{flag functions} diff --git a/man/create_hb_cost_test_flags.Rd b/man/create_hb_cost_test_flags.Rd index 6e2ec141f..1a0c48cf7 100644 --- a/man/create_hb_cost_test_flags.Rd +++ b/man/create_hb_cost_test_flags.Rd @@ -25,6 +25,7 @@ Other flag functions: \code{\link{create_demog_test_flags}()}, \code{\link{create_hb_test_flags}()}, \code{\link{create_hscp_test_flags}()}, -\code{\link{create_lca_test_flags}()} +\code{\link{create_lca_test_flags}()}, +\code{\link{create_sending_location_test_flags}()} } \concept{flag functions} diff --git a/man/create_hb_test_flags.Rd b/man/create_hb_test_flags.Rd index 81e1a38e7..66eb767c0 100644 --- a/man/create_hb_test_flags.Rd +++ b/man/create_hb_test_flags.Rd @@ -22,6 +22,7 @@ Other flag functions: \code{\link{create_demog_test_flags}()}, \code{\link{create_hb_cost_test_flags}()}, \code{\link{create_hscp_test_flags}()}, -\code{\link{create_lca_test_flags}()} +\code{\link{create_lca_test_flags}()}, +\code{\link{create_sending_location_test_flags}()} } \concept{flag functions} diff --git a/man/create_hscp_test_flags.Rd b/man/create_hscp_test_flags.Rd index 9f881e8fc..847eab6a5 100644 --- a/man/create_hscp_test_flags.Rd +++ b/man/create_hscp_test_flags.Rd @@ -22,6 +22,7 @@ Other flag functions: \code{\link{create_demog_test_flags}()}, \code{\link{create_hb_cost_test_flags}()}, \code{\link{create_hb_test_flags}()}, -\code{\link{create_lca_test_flags}()} +\code{\link{create_lca_test_flags}()}, +\code{\link{create_sending_location_test_flags}()} } \concept{flag functions} diff --git a/man/create_lca_test_flags.Rd b/man/create_lca_test_flags.Rd index 6a31477a4..136ffcb78 100644 --- a/man/create_lca_test_flags.Rd +++ b/man/create_lca_test_flags.Rd @@ -22,6 +22,7 @@ Other flag functions: \code{\link{create_demog_test_flags}()}, \code{\link{create_hb_cost_test_flags}()}, \code{\link{create_hb_test_flags}()}, -\code{\link{create_hscp_test_flags}()} +\code{\link{create_hscp_test_flags}()}, +\code{\link{create_sending_location_test_flags}()} } \concept{flag functions} diff --git a/man/create_sending_location_test_flags.Rd b/man/create_sending_location_test_flags.Rd new file mode 100644 index 000000000..5d1ad09f7 --- /dev/null +++ b/man/create_sending_location_test_flags.Rd @@ -0,0 +1,28 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/create_sending_location_test_flags.R +\name{create_sending_location_test_flags} +\alias{create_sending_location_test_flags} +\title{Create sending location test flags} +\usage{ +create_sending_location_test_flags(data, sending_location_var) +} +\arguments{ +\item{data}{the data containing the variable sending_location} + +\item{sending_location_var}{sending_location variable} +} +\value{ +a dataframe with flag (T or F) for each sending location +} +\description{ +Create flags for sending location +} +\seealso{ +Other flag functions: +\code{\link{create_demog_test_flags}()}, +\code{\link{create_hb_cost_test_flags}()}, +\code{\link{create_hb_test_flags}()}, +\code{\link{create_hscp_test_flags}()}, +\code{\link{create_lca_test_flags}()} +} +\concept{flag functions}