diff --git a/NAMESPACE b/NAMESPACE index ca5b032..52c81ed 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -36,6 +36,5 @@ importFrom(rlang,":=") importFrom(rlang,sym) importFrom(stats,setNames) importFrom(stringr,str_pad) -importFrom(tibble,rownames_to_column) importFrom(utils,data) importFrom(utils,read.csv) diff --git a/R/incidence-cancer.R b/R/incidence-cancer.R index 9a118d5..8e9d51e 100644 --- a/R/incidence-cancer.R +++ b/R/incidence-cancer.R @@ -36,18 +36,6 @@ #' incidence_cancer("ca", "hsa", "childhood (ages <20, all sites)", "all races (includes hispanic)", #' "males", "ages <20", "all stages") #' } - - -# incidence_cancer("wa", "county", "all cancer sites", "black (non-hispanic)", "both sexes", "ages 65+", "all stages") -# -# area = "wa" -# areatype = "county" -# cancer = "all cancer sites" -# race = "black (non-hispanic)" -# sex = "both sexes" -# age = "ages 65+" -# stage = "all stages" - incidence_cancer <- function(area, areatype, cancer, race, sex=NULL, age, stage, year="latest 5 year average") { allstage_cancer <- c("all cancer sites", "breast (female in situ)", "childhood (ages <15, all sites)", diff --git a/R/process-incidence.R b/R/process-incidence.R index ac9eea7..553e1e5 100644 --- a/R/process-incidence.R +++ b/R/process-incidence.R @@ -8,7 +8,6 @@ #' @importFrom dplyr mutate_all na_if filter mutate rename #' @importFrom rlang sym := #' @importFrom utils read.csv data -#' @importFrom tibble rownames_to_column #' #' @returns A processed response data frame #' @@ -16,9 +15,6 @@ #' \dontrun{ #' process_incidence(resp) #' } - - -#Health.Service.Area.HSA_Code State.FIPS process_incidence <- function(resp) { nenv <- new.env() @@ -37,27 +33,15 @@ process_incidence <- function(resp) { (\(x) read.csv(textConnection(x), header=TRUE, colClasses = "character"))() - column <- c("Health.Service.Area", "County", "State")[c("Health.Service.Area.HSA_Code", "County.FIPS", "State.FIPS") %in% colnames(resp)] - - old_column2 <- c("Health.Service.Area.HSA_Code", "County.FIPS", "State.FIPS")[c("Health.Service.Area.HSA_Code", "County.FIPS", "State.FIPS") %in% colnames(resp)] - - column2 <- c("HSA Code", "FIPS", "FIPS")[c("Health.Service.Area.HSA_Code", "County.FIPS", "State.FIPS") %in% colnames(resp)] - - # column <- c("Health.Service.Area.HSA_Code", "County.FIPS", "State.FIPS")[c("Health.Service.Area.HSA_Code", "County.FIPS", "State.FIPS") %in% colnames(resp)] - + column <- c("County", "Health.Service.Area", "State")[c("County", "Health.Service.Area", "State") %in% colnames(resp)] resp <- resp %>% - rownames_to_column(column) %>% - rename(!!column2 := !!sym(old_column2)) %>% - filter(!!sym(column) != "US (SEER+NPCR)(1)") %>% - mutate_all(\(x) na_if(x, "N/A")) %>% - mutate_all(\(x) na_if(x, "data not available")) %>% - mutate_all(\(x) na_if(x, "*")) %>% - mutate(!!column := sub("\\(\\d+\\)", "", !!sym(column))) + filter(!!sym(column) != "US (SEER+NPCR)(1)") %>% + mutate(!!sym(column) := str_replace_all(!!sym(column), "\\(\\d+\\)", "")) + if(column %in% c("Health.Service.Area", "County")) { - resp <- resp %>% - filter(!(!!sym(column) %in% state.name)) - } - resp + resp <- resp %>% + filter(!(!!sym(column) %in% state.name)) + } } diff --git a/R/risk-colorectal-screening.R b/R/risk-colorectal-screening.R index 5fd2870..4e2303d 100644 --- a/R/risk-colorectal-screening.R +++ b/R/risk-colorectal-screening.R @@ -21,7 +21,11 @@ #' \dontrun{ #' risk_colorectal_screening("ever had colorectal endoscopy (sigmoidoscopy or colonoscopy), ages 50+", #' "all races (includes hispanic)","both sexes") +#' risk_colorectal_screening("ever had fobt, ages 50-75", area="usa") #' risk_colorectal_screening("ever had fobt, ages 50-75", area="wa") +#' risk_colorectal_screening("fobt (1yr) / flex sig (5yr) / fobt (3yr) / colonoscopy (10yr), ages 50-75", +#' "all races (includes hispanic)", "males" ) + #' } risk_colorectal_screening <- function(screening, race=NULL, sex=NULL, area=NULL) { diff --git a/man/risk_colorectal_screening.Rd b/man/risk_colorectal_screening.Rd index fae86e8..a071dc9 100644 --- a/man/risk_colorectal_screening.Rd +++ b/man/risk_colorectal_screening.Rd @@ -31,6 +31,9 @@ This function returns a data frame from Colorectal Screening in State Cancer Pro \dontrun{ risk_colorectal_screening("ever had colorectal endoscopy (sigmoidoscopy or colonoscopy), ages 50+", "all races (includes hispanic)","both sexes") +risk_colorectal_screening("ever had fobt, ages 50-75", area="usa") risk_colorectal_screening("ever had fobt, ages 50-75", area="wa") +risk_colorectal_screening("fobt (1yr) / flex sig (5yr) / fobt (3yr) / colonoscopy (10yr), ages 50-75", + "all races (includes hispanic)", "males" ) } }