Skip to content

Commit

Permalink
Merge pull request #13 from getwilds/bugsquash
Browse files Browse the repository at this point in the history
Bugsquash
  • Loading branch information
realbp authored Feb 7, 2024
2 parents 73b62e2 + 8ab2ede commit 9afe9db
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 17 deletions.
3 changes: 3 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ Imports:
stringr,
tibble,
utils
Suggests:
testthat (>= 3.0.0)
Config/testthat/edition: 3
12 changes: 8 additions & 4 deletions R/handle-vaccine.R
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
8 changes: 7 additions & 1 deletion R/handle-whealth.R
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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")
6 changes: 3 additions & 3 deletions R/risk-vaccines.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Expand Down
4 changes: 1 addition & 3 deletions R/risk-womens-health.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Expand Down
6 changes: 3 additions & 3 deletions man/risk_vaccine.Rd

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

4 changes: 1 addition & 3 deletions man/risk_whealth.Rd

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

12 changes: 12 additions & 0 deletions tests/testthat.R
Original file line number Diff line number Diff line change
@@ -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")
13 changes: 13 additions & 0 deletions tests/testthat/test-demo-crowding.R
Original file line number Diff line number Diff line change
@@ -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
})
15 changes: 15 additions & 0 deletions tests/testthat/test-demo-education.R
Original file line number Diff line number Diff line change
@@ -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"
)
})

0 comments on commit 9afe9db

Please sign in to comment.