Skip to content

Commit

Permalink
rename of some function to add convert_
Browse files Browse the repository at this point in the history
  • Loading branch information
Catherine Holland committed May 31, 2022
1 parent fbc011a commit 1687f92
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 33 deletions.
8 changes: 4 additions & 4 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ export("%>%")
export(calculate_measures)
export(check_year_format)
export(convert_ca_to_lca)
export(convert_date_to_numeric)
export(convert_eng_gpprac_to_dummy)
export(convert_fyyear_to_year)
export(convert_hb_to_hbnames)
export(convert_hscp_to_hscpnames)
export(convert_numeric_to_date)
export(convert_year_to_fyyear)
export(create_day_episode_costs)
export(create_demog_test_flags)
Expand All @@ -14,7 +18,6 @@ export(create_hb_test_flags)
export(create_hscp_test_flags)
export(create_monthly_beddays)
export(create_monthly_costs)
export(date_to_numeric)
export(dd_period)
export(end_fy)
export(find_latest_file)
Expand Down Expand Up @@ -45,13 +48,10 @@ export(get_slf_postcode_path)
export(get_source_extract_path)
export(get_sparra_path)
export(get_year_dir)
export(hb_to_hbnames)
export(hscp_to_hscpnames)
export(is_missing)
export(it_extract_ref)
export(latest_update)
export(midpoint_fy)
export(numeric_to_date)
export(phs_db_connection)
export(previous_update)
export(process_homelessness_extract)
Expand Down
8 changes: 4 additions & 4 deletions R/convert_codes_to_name.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#'
#' @examples
#' hscp <- c("S37000001", "S37000002")
#' hscp_to_hscpnames(hscp)
hscp_to_hscpnames <- function(hscp) {
#' convert_hscp_to_hscpnames(hscp)
convert_hscp_to_hscpnames <- function(hscp) {
hscpnames <- dplyr::case_when(
hscp == "S37000001" ~ "Aberdeen City",
hscp == "S37000002" ~ "Aberdeenshire",
Expand Down Expand Up @@ -55,8 +55,8 @@ hscp_to_hscpnames <- function(hscp) {
#'
#' @examples
#' hb <- c("S08000015", "S08000016")
#' hb_to_hbnames(hb)
hb_to_hbnames <- function(hb) {
#' convert_hb_to_hbnames(hb)
convert_hb_to_hbnames <- function(hb) {
hbnames <- dplyr::case_when(
hb == "S08000015" ~ "Ayrshire and Arran",
hb == "S08000016" ~ "Borders",
Expand Down
8 changes: 4 additions & 4 deletions R/convert_date_types.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#' @export
#'
#' @examples
#' date_to_numeric(as.Date("2021-03-31"))
date_to_numeric <- function(date) {
#' convert_date_to_numeric(as.Date("2021-03-31"))
convert_date_to_numeric <- function(date) {
lubridate::year(date) * 10000 +
lubridate::month(date) * 100 +
lubridate::day(date)
Expand All @@ -21,7 +21,7 @@ date_to_numeric <- function(date) {
#' @export
#'
#' @examples
#' numeric_to_date(c(20210101, 19993112))
numeric_to_date <- function(numeric_date) {
#' convert_numeric_to_date(c(20210101, 19993112))
convert_numeric_to_date <- function(numeric_date) {
as.Date(strptime(as.character(numeric_date), "%Y%m%d", tz = "UTC"))
}
2 changes: 1 addition & 1 deletion R/process_homelessness_extract.R
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ process_homelessness_extract <- function(year, write_to_disk = TRUE) {
# Changes only required for SPSS ------------------------------------------
final_data <- final_data %>%
tidyr::replace_na(list(chi = "")) %>%
dplyr::mutate(dplyr::across(c(.data$record_keydate1, .data$record_keydate2), date_to_numeric)) %>%
dplyr::mutate(dplyr::across(c(.data$record_keydate1, .data$record_keydate2), convert_date_to_numeric)) %>%
dplyr::arrange(.data$chi, .data$record_keydate1, .data$record_keydate2) %>%
dplyr::mutate(
postcode = stringr::str_pad(.data$postcode, width = 8, side = "right"),
Expand Down
8 changes: 4 additions & 4 deletions man/date_to_numeric.Rd → man/convert_date_to_numeric.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions man/hb_to_hbnames.Rd → man/convert_hb_to_hbnames.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions man/hscp_to_hscpnames.Rd → man/convert_hscp_to_hscpnames.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions man/numeric_to_date.Rd → man/convert_numeric_to_date.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions tests/testthat/test-convert_codes_to_names.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ test_that("Can convert HSCP code to HSCP Name", {
)

expect_equal(
hscp_to_hscpnames(hscp),
convert_hscp_to_hscpnames(hscp),
c(
"Aberdeen City",
"Glasgow City",
Expand All @@ -31,7 +31,7 @@ test_that("Can convert Health Board code to HB Name", {
)

expect_equal(
hb_to_hbnames(hb),
convert_hb_to_hbnames(hb),
c(
"Ayrshire and Arran",
"Greater Glasgow and Clyde",
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-convert_date_types.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ test_that("Can convert a date type to numeric", {
))

expect_equal(
date_to_numeric(dates),
convert_date_to_numeric(dates),
c(
20170913,
20180312,
Expand Down Expand Up @@ -44,7 +44,7 @@ test_that("Can convert a numeric 'date' to a proper date type", {
)

expect_equal(
numeric_to_date(numeric_dates),
convert_numeric_to_date(numeric_dates),
as.Date(c(
"2017/09/13",
"2018/03/12",
Expand Down

0 comments on commit 1687f92

Please sign in to comment.