diff --git a/DESCRIPTION b/DESCRIPTION index a5590e9..9e09a65 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -19,3 +19,6 @@ Imports: stringr, tibble, utils +Suggests: + testthat (>= 3.0.0) +Config/testthat/edition: 3 diff --git a/R/handle-vaccine.R b/R/handle-vaccine.R index e625589..91230d6 100644 --- a/R/handle-vaccine.R +++ b/R/handle-vaccine.R @@ -16,10 +16,14 @@ handle_vaccine <- function(vaccine) { vaccine <- tolower(vaccine) vaccine_mapping <- c( - "percent who received 2+ doses of hpv vaccine, ages 13-15" = "v90", - "percent who received 2+ doses of hpv vaccine, ages 13-17" = "v91", - "percent who received 3+ doses of hpv vaccine, ages 13-15" = "v70", - "percent who received 3+ doses of hpv vaccine, ages 13-17" = "v71" + # removed from scp + # "percent who received 2+ doses of hpv vaccine, ages 13-15" = "v90", + # "percent who received 2+ doses of hpv vaccine, ages 13-17" = "v91", + # "percent who received 3+ doses of hpv vaccine, ages 13-15" = "v70", + # "percent who received 3+ doses of hpv vaccine, ages 13-17" = "v71" + + "percent with up to date hpv vaccination coverage, ages 13-15" = "v281", + "percent with up to date hpv vaccination coverage, ages 13-15" = "v282" ) vaccine_code <- vaccine_mapping[vaccine] diff --git a/R/handle-whealth.R b/R/handle-whealth.R index 386de20..7fc9fe0 100644 --- a/R/handle-whealth.R +++ b/R/handle-whealth.R @@ -19,7 +19,10 @@ handle_whealth <- function(whealth) { "mammogram in past 2 years, ages 50-74" = "v05", "mammogram in past 2 years, ages 40+" = "v06", "pap smear in past 3 years, no hysterectomy, ages 21-65" = "v17", - "pap smear in past 3 years, no hysterectomy, ages 18+" = "v11" + "pap smear in past 3 years, no hysteroetomy, ages 21-65" = "v17" + + #removed from scp + # "pap smear in past 3 years, no hysterectomy, ages 18+" = "v11" ) whealth_code <- whealth_mapping[whealth] @@ -30,3 +33,6 @@ handle_whealth <- function(whealth) { return(as.character(whealth_code)) } + + +handle_whealth("pap smear in past 3 years, no hysteroetomy, ages 21-65") diff --git a/R/risk-vaccines.R b/R/risk-vaccines.R index 4a5181e..640cd89 100644 --- a/R/risk-vaccines.R +++ b/R/risk-vaccines.R @@ -13,9 +13,9 @@ #' #' @examples #' \dontrun{ -#' risk_vaccine("percent who received 2+ doses of HPV vaccine, ages 13-15", "both sexes") -#' risk_vaccine("percent who received 2+ doses of HPV vaccine, ages 13-17", "both sexes") -#' risk_vaccine("percent who received 3+ doses of HPV vaccine, ages 13-17", "females") +#' risk_vaccine("percent with up to date hpv vaccination coverage, ages 13-15", "both sexes") +#' risk_vaccine("percent with up to date hpv vaccination coverage, ages 13-15", "both sexes") +#' risk_vaccine("percent with up to date hpv vaccination coverage, ages 13-15", "females") #' } risk_vaccine <- function(vaccine, sex) { diff --git a/R/risk-womens-health.R b/R/risk-womens-health.R index e75e421..7f1a4ca 100644 --- a/R/risk-womens-health.R +++ b/R/risk-womens-health.R @@ -20,9 +20,7 @@ #' "all races (includes hispanic)", "direct estimates") #' risk_whealth("pap smear in past 3 years, no hysterectomy, ages 21-65", #' "all races (includes hispanic)", "county level modeled estimates", "wa") -#' risk_whealth("pap smear in past 3 years, no hysterectomy, ages 18+", -#' "all races (includes hispanic)", "county level modeled estimates", "wa") -#' risk_whealth("pap smear in past 3 years, no hysterectomy, ages 18+", "black (non-hispanic)") +#' risk_whealth("pap smear in past 3 years, no hysteroetomy, ages 21-65", "black (non-hispanic)") #' } risk_whealth <- function(whealth, race, datatype="direct estimates", area=NULL) { diff --git a/man/risk_vaccine.Rd b/man/risk_vaccine.Rd index 8dd0a0c..13c8f68 100644 --- a/man/risk_vaccine.Rd +++ b/man/risk_vaccine.Rd @@ -21,8 +21,8 @@ This function returns a data frame from Vaccines in State Cancer Profiles } \examples{ \dontrun{ -risk_vaccine("percent who received 2+ doses of HPV vaccine, ages 13-15", "both sexes") -risk_vaccine("percent who received 2+ doses of HPV vaccine, ages 13-17", "both sexes") -risk_vaccine("percent who received 3+ doses of HPV vaccine, ages 13-17", "females") +risk_vaccine("percent with up to date hpv vaccination coverage, ages 13-15", "both sexes") +risk_vaccine("percent with up to date hpv vaccination coverage, ages 13-15", "both sexes") +risk_vaccine("percent with up to date hpv vaccination coverage, ages 13-15", "females") } } diff --git a/man/risk_whealth.Rd b/man/risk_whealth.Rd index 7996398..3f4f110 100644 --- a/man/risk_whealth.Rd +++ b/man/risk_whealth.Rd @@ -30,8 +30,6 @@ risk_whealth("mammogram in past 2 years, ages 50-74", "all races (includes hispanic)", "direct estimates") risk_whealth("pap smear in past 3 years, no hysterectomy, ages 21-65", "all races (includes hispanic)", "county level modeled estimates", "wa") -risk_whealth("pap smear in past 3 years, no hysterectomy, ages 18+", - "all races (includes hispanic)", "county level modeled estimates", "wa") -risk_whealth("pap smear in past 3 years, no hysterectomy, ages 18+", "black (non-hispanic)") +risk_whealth("pap smear in past 3 years, no hysteroetomy, ages 21-65", "black (non-hispanic)") } } diff --git a/tests/testthat.R b/tests/testthat.R new file mode 100644 index 0000000..79fbadc --- /dev/null +++ b/tests/testthat.R @@ -0,0 +1,12 @@ +# This file is part of the standard setup for testthat. +# It is recommended that you do not modify it. +# +# Where should you do additional test configuration? +# Learn more about the roles of various files in: +# * https://r-pkgs.org/testing-design.html#sec-tests-files-overview +# * https://testthat.r-lib.org/articles/special-files.html + +library(testthat) +library(cancerprof) + +test_check("cancerprof") diff --git a/tests/testthat/test-demo-crowding.R b/tests/testthat/test-demo-crowding.R new file mode 100644 index 0000000..e74790e --- /dev/null +++ b/tests/testthat/test-demo-crowding.R @@ -0,0 +1,13 @@ +test_that("demo-crowding", { + test_crowding1 <- demo_crowding("WA", "hsa", "All Races (includes Hispanic)") + + + # object, length, dimensions, + # ranges -ex: greater than 10 rows + # errors + # + expect_type(test_crowding1, "list") + + + #expect_error() - catches an expected error +}) diff --git a/tests/testthat/test-demo-education.R b/tests/testthat/test-demo-education.R new file mode 100644 index 0000000..3d9b234 --- /dev/null +++ b/tests/testthat/test-demo-education.R @@ -0,0 +1,15 @@ +test_that("demo-education", { + test_education1 <- demo_education("wa", "county", "at least high school", "males") + + expect_type(test_education1, "list") + + + expect_error( + demo_education("wa", "county", "less than 9th grade", "males"), + "For Less than 9th Grade, Race and Sex must be NULL" + ) + expect_error( + demo_education("wa", "county", "at least high school", "all races (includes hispanic", "females"), + "For At Least High School, Race must be NULL and Sex must be NOT NULL" + ) +})