From 33e016c332da73e7bd267ea5cca23aa21074e900 Mon Sep 17 00:00:00 2001 From: realbp Date: Thu, 29 Feb 2024 11:15:50 -0800 Subject: [PATCH] modified documentation --- NAMESPACE | 4 +- R/demo-crowding.R | 6 +++ R/handle-screening.R | 2 +- R/{handle-whealth.R => handle-women_health.R} | 11 ++--- R/incidence-cancer.R | 2 +- R/mortality-cancer.R | 2 +- R/process-response.R | 1 - R/risk-alcohol.R | 9 ++-- R/risk-colorectal-screening.R | 27 ++++++----- R/risk-diet-exercise.R | 8 ++-- R/risk-smoking.R | 31 ++++++++----- R/risk-vaccines.R | 9 ++-- R/risk-womens-health.R | 26 +++++++---- man/{demo_crowding.Rd => area.Rd} | 12 +++-- man/demo_education.Rd | 22 ++++++--- man/demo_food.Rd | 18 ++++++-- man/demo_income.Rd | 19 ++++++-- man/demo_insurance.Rd | 28 +++++++---- man/demo_language.Rd | 13 ++++-- man/demo_mobility.Rd | 16 +++++-- man/demo_population.Rd | 23 ++++++++-- man/demo_poverty.Rd | 18 ++++++-- man/demo_svi.Rd | 11 +++-- man/demo_workforce.Rd | 19 ++++++-- man/incidence_cancer.Rd | 7 ++- man/mortality_cancer.Rd | 2 +- man/risk_alcohol.Rd | 9 ++-- man/risk_colorectal_screening.Rd | 23 ++++++---- man/risk_diet_exercise.Rd | 8 ++-- man/risk_smoking.Rd | 32 ++++++++----- man/risk_vaccines.Rd | 9 ++-- man/risk_whealth.Rd | 35 -------------- man/risk_women_health.Rd | 46 +++++++++++++++++++ tests/testthat/test-risk-womens-health.R | 10 ++-- 34 files changed, 336 insertions(+), 182 deletions(-) rename R/{handle-whealth.R => handle-women_health.R} (78%) rename man/{demo_crowding.Rd => area.Rd} (89%) delete mode 100644 man/risk_whealth.Rd create mode 100644 man/risk_women_health.Rd diff --git a/NAMESPACE b/NAMESPACE index 964b4ae..df9d855 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,7 +1,7 @@ # Generated by roxygen2: do not edit by hand export("%>%") -export(demo_crowding) +export(area) export(demo_education) export(demo_food) export(demo_income) @@ -19,7 +19,7 @@ export(risk_colorectal_screening) export(risk_diet_exercise) export(risk_smoking) export(risk_vaccines) -export(risk_whealth) +export(risk_women_health) importFrom(cdlTools,fips) importFrom(cli,cli_abort) importFrom(dplyr,filter) diff --git a/R/demo-crowding.R b/R/demo-crowding.R index 4eb3a8a..6ee98d5 100644 --- a/R/demo-crowding.R +++ b/R/demo-crowding.R @@ -34,6 +34,12 @@ #' areatype = "hsa", #' race = "black") #' } +#' + +area = "wa" +areatype = "county" +race = "all races (includes hispanic)" + demo_crowding <- function(area, areatype, race) { crowding = "00027" diff --git a/R/handle-screening.R b/R/handle-screening.R index c0ce0db..1fdb721 100644 --- a/R/handle-screening.R +++ b/R/handle-screening.R @@ -27,7 +27,7 @@ handle_screening <- function(screening) { "had colonoscopy in past 10 years, ages 50-75" = "v302", "home blood stool test in the past year, ages 45-75" = "v520", - "receieved at least one recommended crc test, ages 45-75" = "v521" + "received at least one recommended crc test, ages 45-75" = "v521" #removed from scp # "ever had colorectal endoscopy (sigmoidoscopy or colonoscopy), ages 50+" = "v09", diff --git a/R/handle-whealth.R b/R/handle-women_health.R similarity index 78% rename from R/handle-whealth.R rename to R/handle-women_health.R index d99fb00..f48ede8 100644 --- a/R/handle-whealth.R +++ b/R/handle-women_health.R @@ -2,7 +2,7 @@ #' #' This function returns a matching code value for a Women's Health for the api to use to get data from State Cancer Profiles #' -#' @param whealth Either "mammogram in past 2 years, ages 50-74", "mammogram in past 2 years, ages 40+", +#' @param women_health Either "mammogram in past 2 years, ages 50-74", "mammogram in past 2 years, ages 40+", #' "pap smear in past 3 years, no hysterectomy, ages 21-65", #' "pap smear in past 3 years, no hysterectomy, ages 18+" #' @@ -16,8 +16,8 @@ #' \dontrun{ #' handle_whealth("mammogram in past 2 years, ages 50-74") #' } -handle_whealth <- function(whealth) { - whealth <- tolower(whealth) +handle_women_health <- function(women_health) { + women_health <- tolower(women_health) whealth_mapping <- c( "mammogram in past 2 years, ages 50-74" = "v05", @@ -29,7 +29,7 @@ handle_whealth <- function(whealth) { # "pap smear in past 3 years, no hysterectomy, ages 18+" = "v11" ) - whealth_code <- whealth_mapping[whealth] + whealth_code <- whealth_mapping[women_health] if (is.na(whealth_code)) { stop("Invalid womens health input, please check the documentation for valid inputs") @@ -37,6 +37,3 @@ 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/incidence-cancer.R b/R/incidence-cancer.R index 457b3a9..5c95249 100644 --- a/R/incidence-cancer.R +++ b/R/incidence-cancer.R @@ -17,7 +17,7 @@ #' @param stage Either "all stages" or "late stage (regional & distant)" #' @param year Either "latest 5 year average", "latest single year (us by state)" #' -#' @returns A data frame with the following columns Areatype, Area Code, "Age Adjusted Incidence Rate", "Lower 95% CI", +#' @returns A data frame with the following columns: Area Type, Area Code, "Age Adjusted Incidence Rate", "Lower 95% CI", #' "Upper 95% CI", "CI Rank", "Lower CI Rank", "Upper CI Rank", "Annual Average Count", "Recent Trend", #' "Recent 5 Year Trend", "Trend Lower 95% CI", "Trend Upper 95% CI" #' diff --git a/R/mortality-cancer.R b/R/mortality-cancer.R index a32c5ad..a8448e4 100644 --- a/R/mortality-cancer.R +++ b/R/mortality-cancer.R @@ -18,7 +18,7 @@ #' @param age Either "all ages", "ages <50", "ages 50+", "ages <65", "ages 65+", ages <15, ages <20 #' @param year Either "latest 5 year average", "latest single year (us by state)" #' -#' @returns A data frame with the following columns Areatype, Area Code, "Met Healthy People Objective of ***?", +#' @returns A data frame with the following columns: Area Type, Area Code, "Met Healthy People Objective of ***?", #' "Age Adjusted Death Rate", "Lower 95% CI Rate", "Upper 95% CI Rate", #' "CI Rank", "Lower CI Rank", "Upper CI Rank", "Annual Average Count", #' "Recent Trend", "Recent 5 Year Trend", "Lower 95% CI Trend", "Upper 95% CI Trend" diff --git a/R/process-response.R b/R/process-response.R index 21e4c8a..ab44444 100644 --- a/R/process-response.R +++ b/R/process-response.R @@ -34,7 +34,6 @@ process_response <- function(resp) { paste(collapse = "\n") %>% (\(x) read.csv(textConnection(x), header=TRUE, colClasses = "character"))() - column <- c("Health.Service.Area", "County", "State")[c("Health.Service.Area", "County", "State") %in% colnames(resp)] resp <- resp %>% diff --git a/R/risk-alcohol.R b/R/risk-alcohol.R index ff0a1c7..803e146 100644 --- a/R/risk-alcohol.R +++ b/R/risk-alcohol.R @@ -8,15 +8,16 @@ #' "asian or pacific islander (includes hispanic)","hispanic (any race) #' @param sex Either "both sexes", "male", "female" #' -#' @returns A data frame with the following columns "State", "FIPS", "Percent", "Lower 95% CI", "Upper 95% CI", "Number of Respondents" +#' @returns A data frame with the following columns: Area Type, Area Code, "Percent", "Lower 95% CI", "Upper 95% CI", "Number of Respondents" #' #' @export #' #' @examples #' \dontrun{ -#' risk_alcohol(paste("binge drinking (4+ drinks on one occasion for women,", -#' "5+ drinks for one occasion for men), ages 21+"), -#' "all races (includes hispanic)", "both sexes") +#' risk_alcohol(alcohol = paste("binge drinking (4+ drinks on one occasion for women,", +#' "5+ drinks for one occasion for men), ages 21+"), +#' race = "all races (includes hispanic)", +#' sex = "both sexes") #' } risk_alcohol <- function(alcohol, race, sex) { diff --git a/R/risk-colorectal-screening.R b/R/risk-colorectal-screening.R index 4992cb0..b2a7db6 100644 --- a/R/risk-colorectal-screening.R +++ b/R/risk-colorectal-screening.R @@ -2,41 +2,46 @@ #' #' This function returns a data frame from Colorectal Screening in State Cancer Profiles #' -#' @param screening One of the following values: "home blood stool test in the past year, ages 45-75", -#' "receieved at least one recommended crc test, ages 45-75", -#' "ever had fobt, ages 50-75", +#' @param screening One of the following values: "ever had fobt, ages 50-75", #' "guidance sufficient crc, ages 50-75", #' "had colonoscopy in past 10 years, ages 50-75" +#' "home blood stool test in the past year, ages 45-75" +#' "received at least one recommended crc test, ages 45-75" #' @param race One of the following values: "All Races (includes Hispanic)", "white (includes hispanic)", #' "white non-hispanic","black","amer. indian/alaskan native (includes hispanic)", #' "asian or pacific islander (includes hispanic)","hispanic (any race) #' @param sex Either "both sexes", "male", "female" #' @param area A state/territory abbreviation or USA. #' -#' @returns A data frame with the following columns "County", "FIPS", "Percent", "People Unemployed", "Rank" +#' @returns A data frame with the following columns: Area Type, Area Code, "Percent", "People Unemployed", "Rank" #' #' @export #' #' @examples #' \dontrun{ -#' risk_colorectal_screening("home blood stool test in the past year, ages 45-75", -#' "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(screening = "home blood stool test in the past year, ages 45-75", +#' race = "all races (includes hispanic)", +#' sex = "both sexes") +#' +#' risk_colorectal_screening(screening = "ever had fobt, ages 50-75", +#' area="usa") +#' risk_colorectal_screening(screening = "received at least one recommended crc test, ages 45-75", +#' race = "all races (includes hispanic)", +#' sex = "both sexes") #' } risk_colorectal_screening <- function(screening, race=NULL, sex=NULL, area=NULL) { req <- create_request("risk") screening_type_1 = c("home blood stool test in the past year, ages 45-75", - "receieved at least one recommended crc test, ages 45-75") + "received at least one recommended crc test, ages 45-75") screening_type_2 = c("ever had fobt, ages 50-75", "guidance sufficient crc, ages 50-75", "had colonoscopy in past 10 years, ages 50-75") - if (screening %in% screening_type_1 && (is.null(race) || is.null(sex))) { - cli_abort("For this screening type, Race and Sex must not be NULL") + if (screening %in% screening_type_1 && ((is.null(race) || is.null(sex)) || !is.null(area))) { + cli_abort("For this screening type, Race and Sex must not be NULL, and Area must be NULL") } else if (screening %in% screening_type_2 && (is.null(area) || (!is.null(race) || !is.null(sex)))) { cli_abort("for this screening type, area must NOT be NULL and Race and Sex must be NULL") } diff --git a/R/risk-diet-exercise.R b/R/risk-diet-exercise.R index e41d969..1bcba43 100644 --- a/R/risk-diet-exercise.R +++ b/R/risk-diet-exercise.R @@ -11,14 +11,16 @@ #' "asian or pacific islander (includes hispanic)","hispanic (any race) #' @param sex Either "both sexes", "male", "female" #' -#' @returns A data frame with the following columns "State", "FIPS", "Percent", "Lower 95% CI", "Upper 95% CI", "Number of Respondents" +#' @returns A data frame with the following columns: Area Type, Area Code, "Percent", "Lower 95% CI", "Upper 95% CI", "Number of Respondents" #' #' @export #' #' @examples #' \dontrun{ -#' risk_diet_exercise("bmi is healthy, ages 20+", "all races (includes hispanic)", "both sexes") -#' risk_diet_exercise("bmi is obese, high school survey", "all races (includes hispanic)", "males") +#' risk_diet_exercise(diet_exercise = "bmi is healthy, ages 20+", +#' race = "all races (includes hispanic)", +#' sex = "both sexes") +#' risk_diet_exercise(diet_exer"bmi is obese, high school survey", "all races (includes hispanic)", "males") #' } risk_diet_exercise <- function(diet_exercise, race, sex) { diff --git a/R/risk-smoking.R b/R/risk-smoking.R index a727a42..474efad 100644 --- a/R/risk-smoking.R +++ b/R/risk-smoking.R @@ -1,6 +1,8 @@ #' Access to Smoking Data #' #' This function returns a data frame from Smoking in State Cancer Profiles +#' +#' Please note that this function requires very specific arguments for each smoking type #' #' @param smoking Either "smoking laws (any)", "smoking laws (bars)", "smoking laws (restaurants)", #' "smoking laws (workplace)", "smoking laws (workplace; restaurant; & bar)", @@ -21,23 +23,28 @@ #' @importFrom cli cli_abort #' @importFrom stats setNames #' -#' @returns A data frame with the following columns #"State", "FIPS", "Percent", "Lower CI 95%", "Upper CI 95%", "Number of Respondents" +#' @returns A data frame with the following columns: Area Type, Area Code, "Percent", "Lower CI 95%", "Upper CI 95%", "Number of Respondents" #' #' @export #' #' @examples #' \dontrun{ -#' risk_smoking("smoking laws (any)") -#' risk_smoking("smokers (stopped for 1 day or longer)", sex="both sexes", -#' datatype="county level modeled estimates", area="wa") -#' risk_smoking("smoking not allowed at work (current smokers)", sex="both sexes", -#' datatype="direct estimates") -#' risk_smoking("former smoker; ages 18+", sex="both sexes", -#' datatype="county level modeled estimates", area="ca") -#' risk_smoking("smokers (ever); ages 18+", race="hispanic (any race)", sex="both sexes", -#' datatype="direct estimates") -#' risk_smoking("smokers (current); ages 18+", race="all races (includes hispanic)", -#' sex="both sexes", datatype="county level modeled estimates", area="wa") +#' risk_smoking(smoking = "smoking laws (any)") +#' +#' risk_smoking(smoking = "smokers (stopped for 1 day or longer)", +#' sex = "both sexes", +#' datatype = "county level modeled estimates", +#' area = "wa") +#' +#' risk_smoking(smoking = "smoking not allowed at work (current smokers)", +#' sex = "both sexes", +#' datatype = "direct estimates") +#' +#' risk_smoking(smoking = "smokers (current); ages 18+", +#' race = "all races (includes hispanic)", +#' sex = "both sexes", +#' datatype = "county level modeled estimates", +#' area="wa") #' } risk_smoking <- function(smoking, race=NULL, sex=NULL, datatype=NULL, area=NULL) { diff --git a/R/risk-vaccines.R b/R/risk-vaccines.R index cc71b51..3e47357 100644 --- a/R/risk-vaccines.R +++ b/R/risk-vaccines.R @@ -6,14 +6,17 @@ #' "percent with up to date hpv vaccination coverage, ages 13-17" #' @param sex Either "both sexes", "males", "females" #' -#' @returns A data frame with the following columns "State", "FIPS", "Percent", "Lower 95% CI", "Upper 95% CI", "Number of Respondents" +#' @returns A data frame with the following columns: Area Type, Area Code, "Percent", "Lower 95% CI", "Upper 95% CI", "Number of Respondents" #' #' @export #' #' @examples #' \dontrun{ -#' risk_vaccines("percent with up to date hpv vaccination coverage, ages 13-15", "both sexes") -#' risk_vaccines("percent with up to date hpv vaccination coverage, ages 13-17", "females") +#' risk_vaccines(vaccine = "percent with up to date hpv vaccination coverage, ages 13-15", +#' sex = "both sexes") +#' +#' risk_vaccines(vaccine = "percent with up to date hpv vaccination coverage, ages 13-17", +#' sex = "females") #' } risk_vaccines <- function(vaccine, sex) { diff --git a/R/risk-womens-health.R b/R/risk-womens-health.R index ceede7b..f436167 100644 --- a/R/risk-womens-health.R +++ b/R/risk-womens-health.R @@ -2,7 +2,7 @@ #' #' This function returns a data frame from Women's Health in State Cancer Profiles #' -#' @param whealth Either "mammogram in past 2 years, ages 50-74", "mammogram in past 2 years, ages 40+", +#' @param women_health Either "mammogram in past 2 years, ages 50-74", "mammogram in past 2 years, ages 40+", #' "pap smear in past 3 years, no hysterectomy, ages 21-65" #' @param race One of the following values: "all races (includes hispanic)", "white (non-hispanic)", #' "black (non-hispanic)", "amer. indian / ak native (non-hispanic)", @@ -10,19 +10,25 @@ #' @param datatype Either "direct estimates" or "county level modeled estimates" #' @param area A state/territory abbreviation or USA. #' -#' @returns A data frame with the following columns "County", "FIPS", "Percent", "People Unemployed", "Rank" +#' @returns A data frame with the following columns: Area Type, Area Code, "Percent", "People Unemployed", "Rank" #' #' @export #' #' @examples #' \dontrun{ -#' 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 hysteroetomy, ages 21-65", "black (non-hispanic)") +#' risk_women_health(women_health = "mammogram in past 2 years, ages 50-74", +#' race = "all races (includes hispanic)", +#' datatype = "direct estimates") +#' +#' risk_women_health(women_health = "pap smear in past 3 years, no hysterectomy, ages 21-65", +#' race = "all races (includes hispanic)", +#' datatype = "county level modeled estimates", +#' area = "wa") +#' +#' risk_women_health(women_health = "pap smear in past 3 years, no hysteroetomy, ages 21-65", +#' race = "black (non-hispanic)") #' } -risk_whealth <- function(whealth, race, datatype="direct estimates", area=NULL) { +risk_women_health <- function(women_health, race, datatype="direct estimates", area=NULL) { req <- create_request("risk") @@ -41,7 +47,7 @@ risk_whealth <- function(whealth, race, datatype="direct estimates", area=NULL) resp <- req %>% req_url_query( topic="women", - risk=handle_whealth(whealth), + risk=handle_women_health(women_health), race=handle_race(race), type="risk", sortVariableName="percent", @@ -65,7 +71,7 @@ risk_whealth <- function(whealth, race, datatype="direct estimates", area=NULL) resp <- process_screening(resp) if (datatype == "county level modeled estimates") { - if(whealth == "pap smear in past 3 years, no hysterectomy, ages 21-65") { + if(women_health == "pap smear in past 3 years, no hysterectomy, ages 21-65") { resp %>% setNames(c("State", "FIPS", "Percent", "Lower_95%_CI", "Upper_95%_CI", "Number_of_Respondents")) } else { diff --git a/man/demo_crowding.Rd b/man/area.Rd similarity index 89% rename from man/demo_crowding.Rd rename to man/area.Rd index 0fdc87e..0f8e7e0 100644 --- a/man/demo_crowding.Rd +++ b/man/area.Rd @@ -1,10 +1,14 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/demo-crowding.R -\name{demo_crowding} -\alias{demo_crowding} +\docType{data} +\name{area} +\alias{area} \title{Access to Crowding Data} +\format{ +An object of class \code{character} of length 1. +} \usage{ -demo_crowding(area, areatype, race) +area } \arguments{ \item{area}{A state/territory abbreviation or USA.} @@ -40,4 +44,6 @@ demo_crowding(area = "pr", areatype = "hsa", race = "black") } + } +\keyword{datasets} diff --git a/man/demo_education.Rd b/man/demo_education.Rd index 01bb5e0..1ee41cd 100644 --- a/man/demo_education.Rd +++ b/man/demo_education.Rd @@ -15,21 +15,31 @@ demo_education(area, areatype, education, sex = NULL, race = NULL) \item{sex}{Either "both sexes", "male", "female"} -\item{race}{One of the following values: "All Races (includes Hispanic)", "white (includes hispanic)" = "01", +\item{race}{One of the following values: "All Races (includes Hispanic)", "white (includes hispanic)", "white non-hispanic","black","amer. indian/alaskan native (includes hispanic)", "asian or pacific islander (includes hispanic)","hispanic (any race)} } \value{ -A data frame with the following columns "County", "FIPS", "Percent", "Households", "Rank" +A data frame with the following columns: Area Type, Area Code, "Percent", "Households", "Rank" } \description{ This function returns a data frame from Education in State Cancer Profiles } \examples{ \dontrun{ -demo_education("wa", "county", "at least high school", "males") -demo_education("usa", "state", "at least bachelors degree", "both sexes", - "all races (includes hispanic)") -demo_education("pr", "hsa", "less than 9th grade") +demo_education(area = "wa", + areatype = "county", + education = "at least high school", + sex = "males") + +demo_education(area = "usa", + areatype = "state", + education = "at least bachelors degree", + sex = "both sexes", + race = "all races (includes hispanic)") + +demo_education(area = "pr", + areatype = "hsa", + education = "less than 9th grade") } } diff --git a/man/demo_food.Rd b/man/demo_food.Rd index d4329a7..ff063f2 100644 --- a/man/demo_food.Rd +++ b/man/demo_food.Rd @@ -17,15 +17,25 @@ demo_food(area, areatype, food, race = NULL) "black (includes hispanic)","hispanic (any race)} } \value{ -A data frame with the following columns "County", "FIPS", "Value", "People" +A data frame with the following columns: Area Type, Area Code, "Value", "People" } \description{ This function returns a data frame from Food Insecurity in State Cancer Profiles } \examples{ \dontrun{ -demo_food("wa", "county", "food insecurity", "black") -demo_food("usa", "state", "limited access to healthy food") -demo_food("pr", "county", "food insecurity", "all races (includes hispanic)") +demo_food(area = "wa", + areatype = "county", + food = "food insecurity", + race = "black") + +demo_food(area = "usa", + areatype = "state", + food = "limited access to healthy food") + +demo_food(area = "pr", + areatype = "county", + food = "food insecurity", + race = "all races (includes hispanic)") } } diff --git a/man/demo_income.Rd b/man/demo_income.Rd index bdd7bd6..e513cd5 100644 --- a/man/demo_income.Rd +++ b/man/demo_income.Rd @@ -18,15 +18,26 @@ demo_income(area, areatype, income, race) "asian or pacific islander (includes hispanic)","hispanic (any race)} } \value{ -A data frame with the following columns "County", "FIPS", "Dollars", "Rank" +A data frame with the following columns: Area Type, Area Code, "Dollars", "Rank" } \description{ This function returns a data frame from Income in State Cancer Profiles } \examples{ \dontrun{ -demo_income("wa", "county", "median family income", "all races (includes hispanic)") -demo_income("usa", "state", "median family income", "all races (includes hispanic)") -demo_income("pr", "county", "median family income", "all races (includes hispanic)") +demo_income(area = "wa", + areatype = "county", + income = "median family income", + race = "all races (includes hispanic)") + +demo_income(area = "usa", + areatype = "state", + income = "median family income", + race = "all races (includes hispanic)") + +demo_income(area = "pr", + areatype = "county", + income = "median family income", + race = "all races (includes hispanic)") } } diff --git a/man/demo_insurance.Rd b/man/demo_insurance.Rd index f406d43..c8019ed 100644 --- a/man/demo_insurance.Rd +++ b/man/demo_insurance.Rd @@ -28,20 +28,30 @@ demo_insurance(area, areatype, insurance, sex, age, race = NULL) "asian non-hispanic", "hispanic (any race)"} } \value{ -A data frame with the following columns "County", "FIPS", "Percent", "People", "Rank" +A data frame with the following columns: Area Type, Area Code, "Percent", "People", "Rank" } \description{ This function returns a data frame from Insurance in State Cancer Profiles } \examples{ \dontrun{ -demo_insurance("usa", "state", "\% Insured in demographic group, all income levels", - "both sexes", "under 19 years", "all races (includes hispanic)") -demo_insurance("wa", "hsa", "\% Insured in demographic group, all income levels", - "males", "18 to 64 years") -demo_insurance("dc", "county", "\% Insured in demographic group, all income levels", - "males", "18 to 64 years") -demo_insurance("usa", "state", "\% Insured in demographic group, all income levels", - "both sexes", "18 to 64 years", "hispanic (any race)") +demo_insurance(area = "usa", + areatype = "state", + insurance = "\% Insured in demographic group, all income levels", + sex = "both sexes", + age = "under 19 years", + race = "all races (includes hispanic)") + +demo_insurance(area = "wa", + areatype = "hsa", + insurance = "\% Insured in demographic group, all income levels", + sex = "males", + age = "18 to 64 years") + +demo_insurance(area = "dc", + areatype = "county", + insurance = "\% Insured in demographic group, all income levels", + sex = "males", + age = "18 to 64 years") } } diff --git a/man/demo_language.Rd b/man/demo_language.Rd index 51d95cf..cfefbf8 100644 --- a/man/demo_language.Rd +++ b/man/demo_language.Rd @@ -12,13 +12,18 @@ demo_language(area, areatype) \item{areatype}{Either "county", "hsa" (Health service area), or "state"} } \value{ -A data frame with the following columns "County", "FIPS", "Percent", "Households", "Rank" +A data frame with the following columns: Area Type, Area Code, "Percent", "Households", "Rank" } \description{ This function returns a data frame from Crowding in State Cancer Profiles } \examples{ -demo_language("WA", "county") -demo_language("dc", "hsa") -demo_language("usa", "state") +demo_language(area = "WA", + areatype = "county") + +demo_language(area = "dc", + areatype = "hsa") + +demo_language(area = "usa", + areatype = "state") } diff --git a/man/demo_mobility.Rd b/man/demo_mobility.Rd index 19a4ed6..4ab25e3 100644 --- a/man/demo_mobility.Rd +++ b/man/demo_mobility.Rd @@ -16,15 +16,23 @@ demo_mobility(area, areatype, mobility) "moved, same county (in past year)"} } \value{ -A data frame with the following columns "County", "FIPS", "Percent", "People", "Rank" +A data frame with the following columns: Area Type, Area Code, "Percent", "People", "Rank" } \description{ This function returns a data frame from mobility in State Cancer Profiles } \examples{ \dontrun{ -demo_mobility("WA", "county", "moved, different county, same state (in past year)") -demo_mobility("usa", "state", "moved, same county (in past year)") -demo_mobility("dc", "hsa", "moved, same county (in past year)") +demo_mobility(area = "WA", + areatype = "county", + mobility = "moved, different county, same state (in past year)") + +demo_mobility(area = "usa", + areatype = "state", + mobility = "moved, same county (in past year)") + +demo_mobility(area = "dc", + areatype = "hsa", + mobility = "moved, same county (in past year)") } } diff --git a/man/demo_population.Rd b/man/demo_population.Rd index b00e6af..2c3fc53 100644 --- a/man/demo_population.Rd +++ b/man/demo_population.Rd @@ -16,21 +16,34 @@ demo_population(area, areatype, population, race = NULL, sex = NULL) "non-hispanic (origin recode)", "white", "males", "females"} \item{race}{One of the following values: "american indian/alaska native", "asian/pacific islander", -"black", "foreign born", "hispanic", "non-hispanic (origin recode)", "white"} +"black", "hispanic", "white (includes hispanic)", "white non-hispanic", "hispanic (any race)"} \item{sex}{Either "both sexes", "male", "female"} } \value{ -A data frame with the following columns "County", "FIPS", "Percent", "Households", "Rank" +A data frame with the following columns: Area Type, Area Code, "Percent", "Households", "Rank" } \description{ This function returns a data frame from population in State Cancer Profiles } \examples{ \dontrun{ -demo_population("WA", "county", "asian/pacific islander", sex="females") -demo_population("dc", "hsa", "foreign born", "black", "females") -demo_population("usa", "state", "foreign born", "black", "females") +demo_population(area = "WA", + areatype = "county", + population = "asian/pacific islander", + sex="females") + +demo_population(area = "dc", + areatype = "hsa", + population = "foreign born", + race = "black", + sex = "females") + +demo_population(area = "usa", + areatype = "state", + population = "foreign born", + race = "hispanic (any race)", + sex = "females") } } diff --git a/man/demo_poverty.Rd b/man/demo_poverty.Rd index 0439cf1..c7bf63d 100644 --- a/man/demo_poverty.Rd +++ b/man/demo_poverty.Rd @@ -20,15 +20,25 @@ demo_poverty(area, areatype, poverty, race = NULL, sex = NULL) \item{sex}{Either "both sexes", "male", "female"} } \value{ -A data frame with the following columns "County", "FIPS", "Percent", "Households", "Rank" +A data frame with the following columns: Area Type, Area Code, "Percent", "Households", "Rank" } \description{ This function returns a data frame from Poverty in State Cancer Profiles } \examples{ \dontrun{ -demo_poverty("WA", "county", "persistent poverty") -demo_poverty("usa", "state", "families below poverty", "black") -demo_poverty("dc", "hsa", "families below poverty", "All Races (includes Hispanic)") +demo_poverty(area = "WA", + areatype = "county", + poverty = "persistent poverty") + +demo_poverty(area = "usa", + areatype = "state", + poverty = "families below poverty", + race = "black") + +demo_poverty(area = "dc", + areatype = "hsa", + poverty = "families below poverty", + race = "All Races (includes Hispanic)") } } diff --git a/man/demo_svi.Rd b/man/demo_svi.Rd index f61141d..42c58e4 100644 --- a/man/demo_svi.Rd +++ b/man/demo_svi.Rd @@ -19,8 +19,13 @@ This function returns a data frame from Social Vulnerability Index (SVI) in Stat } \examples{ \dontrun{ -demo_svi("WA", "overall") -demo_svi("usa", "overall") -demo_svi("dc", "socioeconomic status") +demo_svi(area = "WA", + svi = "overall") + +demo_svi(area = "usa", + svi = "overall") + +demo_svi(area = "dc", + svi = "socioeconomic status") } } diff --git a/man/demo_workforce.Rd b/man/demo_workforce.Rd index 3e85250..a10a194 100644 --- a/man/demo_workforce.Rd +++ b/man/demo_workforce.Rd @@ -18,15 +18,26 @@ demo_workforce(area, areatype, race, sex) \item{sex}{Either "both sexes", "male", "female"} } \value{ -A data frame with the following columns "County", "FIPS", "Percent", "People Unemployed", "Rank" +A data frame with the following columns: Area Type, Area Code, "Percent", "People Unemployed", "Rank" } \description{ This function returns a data frame from Workforce in State Cancer Profiles } \examples{ \dontrun{ -demo_workforce("WA", "county", "all races (includes hispanic)", "both sexes") -demo_workforce("usa", "state", "all races (includes hispanic)", "females") -demo_workforce("pr", "hsa", "all races (includes hispanic)", "both sexes") +demo_workforce(area = "WA", + areatype = "county", + race = "all races (includes hispanic)", + sex = "both sexes") + +demo_workforce(area = "usa", + areatype = "state", + race = "all races (includes hispanic)", + sex = "females") + +demo_workforce(area = "pr", + areatype = "hsa", + race = "all races (includes hispanic)", + sex = "both sexes") } } diff --git a/man/incidence_cancer.Rd b/man/incidence_cancer.Rd index 83aac18..1a3dcae 100644 --- a/man/incidence_cancer.Rd +++ b/man/incidence_cancer.Rd @@ -30,10 +30,9 @@ incidence_cancer(area, areatype, cancer, race, sex, age, stage, year) \item{year}{Either "latest 5 year average", "latest single year (us by state)"} } \value{ -A data frame with the following columns Areatype, Area Code, "Met Healthy People Objective of ***?", -"Age Adjusted Death Rate", "Lower 95\% CI Rate", "Upper 95\% CI Rate", -"CI Rank", "Lower CI Rank", "Upper CI Rank", "Annual Average Count", -"Recent Trend", "Recent 5 Year Trend", "Lower 95\% CI Trend", "Upper 95\% CI Trend" +A data frame with the following columns: Area Type, Area Code, "Age Adjusted Incidence Rate", "Lower 95\% CI", +"Upper 95\% CI", "CI Rank", "Lower CI Rank", "Upper CI Rank", "Annual Average Count", "Recent Trend", +"Recent 5 Year Trend", "Trend Lower 95\% CI", "Trend Upper 95\% CI" } \description{ This function returns a data frame from Cancer Incident in State Cancer Profiles diff --git a/man/mortality_cancer.Rd b/man/mortality_cancer.Rd index cb7d9ed..70e4986 100644 --- a/man/mortality_cancer.Rd +++ b/man/mortality_cancer.Rd @@ -28,7 +28,7 @@ mortality_cancer(area, areatype, cancer, race, sex, age, year) \item{year}{Either "latest 5 year average", "latest single year (us by state)"} } \value{ -A data frame with the following columns Areatype, Area Code, "Met Healthy People Objective of ***?", +A data frame with the following columns: Area Type, Area Code, "Met Healthy People Objective of ***?", "Age Adjusted Death Rate", "Lower 95\% CI Rate", "Upper 95\% CI Rate", "CI Rank", "Lower CI Rank", "Upper CI Rank", "Annual Average Count", "Recent Trend", "Recent 5 Year Trend", "Lower 95\% CI Trend", "Upper 95\% CI Trend" diff --git a/man/risk_alcohol.Rd b/man/risk_alcohol.Rd index b7031ad..22fb985 100644 --- a/man/risk_alcohol.Rd +++ b/man/risk_alcohol.Rd @@ -16,15 +16,16 @@ risk_alcohol(alcohol, race, sex) \item{sex}{Either "both sexes", "male", "female"} } \value{ -A data frame with the following columns "State", "FIPS", "Percent", "Lower 95\% CI", "Upper 95\% CI", "Number of Respondents" +A data frame with the following columns: Area Type, Area Code, "Percent", "Lower 95\% CI", "Upper 95\% CI", "Number of Respondents" } \description{ This function returns a data frame from Alcohol in State Cancer Profiles } \examples{ \dontrun{ -risk_alcohol(paste("binge drinking (4+ drinks on one occasion for women,", - "5+ drinks for one occasion for men), ages 21+"), - "all races (includes hispanic)", "both sexes") +risk_alcohol(alcohol = paste("binge drinking (4+ drinks on one occasion for women,", + "5+ drinks for one occasion for men), ages 21+"), + race = "all races (includes hispanic)", + sex = "both sexes") } } diff --git a/man/risk_colorectal_screening.Rd b/man/risk_colorectal_screening.Rd index 3f562b7..43c59f8 100644 --- a/man/risk_colorectal_screening.Rd +++ b/man/risk_colorectal_screening.Rd @@ -7,11 +7,11 @@ risk_colorectal_screening(screening, race = NULL, sex = NULL, area = NULL) } \arguments{ -\item{screening}{One of the following values: "home blood stool test in the past year, ages 45-75", -"receieved at least one recommended crc test, ages 45-75", -"ever had fobt, ages 50-75", +\item{screening}{One of the following values: "ever had fobt, ages 50-75", "guidance sufficient crc, ages 50-75", -"had colonoscopy in past 10 years, ages 50-75"} +"had colonoscopy in past 10 years, ages 50-75" +"home blood stool test in the past year, ages 45-75" +"received at least one recommended crc test, ages 45-75"} \item{race}{One of the following values: "All Races (includes Hispanic)", "white (includes hispanic)", "white non-hispanic","black","amer. indian/alaskan native (includes hispanic)", @@ -22,16 +22,21 @@ risk_colorectal_screening(screening, race = NULL, sex = NULL, area = NULL) \item{area}{A state/territory abbreviation or USA.} } \value{ -A data frame with the following columns "County", "FIPS", "Percent", "People Unemployed", "Rank" +A data frame with the following columns: Area Type, Area Code, "Percent", "People Unemployed", "Rank" } \description{ This function returns a data frame from Colorectal Screening in State Cancer Profiles } \examples{ \dontrun{ -risk_colorectal_screening("home blood stool test in the past year, ages 45-75", - "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(screening = "home blood stool test in the past year, ages 45-75", + race = "all races (includes hispanic)", + sex = "both sexes") + +risk_colorectal_screening(screening = "ever had fobt, ages 50-75", + area="usa") +risk_colorectal_screening(screening = "received at least one recommended crc test, ages 45-75", + race = "all races (includes hispanic)", + sex = "both sexes") } } diff --git a/man/risk_diet_exercise.Rd b/man/risk_diet_exercise.Rd index e07d122..5caad02 100644 --- a/man/risk_diet_exercise.Rd +++ b/man/risk_diet_exercise.Rd @@ -19,14 +19,16 @@ risk_diet_exercise(diet_exercise, race, sex) \item{sex}{Either "both sexes", "male", "female"} } \value{ -A data frame with the following columns "State", "FIPS", "Percent", "Lower 95\% CI", "Upper 95\% CI", "Number of Respondents" +A data frame with the following columns: Area Type, Area Code, "Percent", "Lower 95\% CI", "Upper 95\% CI", "Number of Respondents" } \description{ This function returns a data frame from Diet & Exercise in State Cancer Profiles } \examples{ \dontrun{ -risk_diet_exercise("bmi is healthy, ages 20+", "all races (includes hispanic)", "both sexes") -risk_diet_exercise("bmi is obese, high school survey", "all races (includes hispanic)", "males") +risk_diet_exercise(diet_exercise = "bmi is healthy, ages 20+", + race = "all races (includes hispanic)", + sex = "both sexes") +risk_diet_exercise(diet_exer"bmi is obese, high school survey", "all races (includes hispanic)", "males") } } diff --git a/man/risk_smoking.Rd b/man/risk_smoking.Rd index f4e3295..ef69be5 100644 --- a/man/risk_smoking.Rd +++ b/man/risk_smoking.Rd @@ -27,23 +27,31 @@ risk_smoking(smoking, race = NULL, sex = NULL, datatype = NULL, area = NULL) \item{area}{A state/territory abbreviation or USA.} } \value{ -A data frame with the following columns #"State", "FIPS", "Percent", "Lower CI 95\%", "Upper CI 95\%", "Number of Respondents" +A data frame with the following columns: Area Type, Area Code, "Percent", "Lower CI 95\%", "Upper CI 95\%", "Number of Respondents" } \description{ This function returns a data frame from Smoking in State Cancer Profiles } +\details{ +Please note that this function requires very specific arguments for each smoking type +} \examples{ \dontrun{ -risk_smoking("smoking laws (any)") -risk_smoking("smokers (stopped for 1 day or longer)", sex="both sexes", - datatype="county level modeled estimates", area="wa") -risk_smoking("smoking not allowed at work (current smokers)", sex="both sexes", - datatype="direct estimates") -risk_smoking("former smoker; ages 18+", sex="both sexes", - datatype="county level modeled estimates", area="ca") -risk_smoking("smokers (ever); ages 18+", race="hispanic (any race)", sex="both sexes", - datatype="direct estimates") -risk_smoking("smokers (current); ages 18+", race="all races (includes hispanic)", - sex="both sexes", datatype="county level modeled estimates", area="wa") +risk_smoking(smoking = "smoking laws (any)") + +risk_smoking(smoking = "smokers (stopped for 1 day or longer)", + sex = "both sexes", + datatype = "county level modeled estimates", + area = "wa") + +risk_smoking(smoking = "smoking not allowed at work (current smokers)", + sex = "both sexes", + datatype = "direct estimates") + +risk_smoking(smoking = "smokers (current); ages 18+", + race = "all races (includes hispanic)", + sex = "both sexes", + datatype = "county level modeled estimates", + area="wa") } } diff --git a/man/risk_vaccines.Rd b/man/risk_vaccines.Rd index 762d628..4f18141 100644 --- a/man/risk_vaccines.Rd +++ b/man/risk_vaccines.Rd @@ -13,14 +13,17 @@ risk_vaccines(vaccine, sex) \item{sex}{Either "both sexes", "males", "females"} } \value{ -A data frame with the following columns "State", "FIPS", "Percent", "Lower 95\% CI", "Upper 95\% CI", "Number of Respondents" +A data frame with the following columns: Area Type, Area Code, "Percent", "Lower 95\% CI", "Upper 95\% CI", "Number of Respondents" } \description{ This function returns a data frame from Vaccines in State Cancer Profiles } \examples{ \dontrun{ -risk_vaccines("percent with up to date hpv vaccination coverage, ages 13-15", "both sexes") -risk_vaccines("percent with up to date hpv vaccination coverage, ages 13-17", "females") +risk_vaccines(vaccine = "percent with up to date hpv vaccination coverage, ages 13-15", + sex = "both sexes") + +risk_vaccines(vaccine = "percent with up to date hpv vaccination coverage, ages 13-17", + sex = "females") } } diff --git a/man/risk_whealth.Rd b/man/risk_whealth.Rd deleted file mode 100644 index 356ce75..0000000 --- a/man/risk_whealth.Rd +++ /dev/null @@ -1,35 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/risk-womens-health.R -\name{risk_whealth} -\alias{risk_whealth} -\title{Access to Women's Health Data} -\usage{ -risk_whealth(whealth, race, datatype = "direct estimates", area = NULL) -} -\arguments{ -\item{whealth}{Either "mammogram in past 2 years, ages 50-74", "mammogram in past 2 years, ages 40+", -"pap smear in past 3 years, no hysterectomy, ages 21-65"} - -\item{race}{One of the following values: "all races (includes hispanic)", "white (non-hispanic)", -"black (non-hispanic)", "amer. indian / ak native (non-hispanic)", -"asian / pacific islander (non-hispanic)","hispanic (any race)"} - -\item{datatype}{Either "direct estimates" or "county level modeled estimates"} - -\item{area}{A state/territory abbreviation or USA.} -} -\value{ -A data frame with the following columns "County", "FIPS", "Percent", "People Unemployed", "Rank" -} -\description{ -This function returns a data frame from Women's Health in State Cancer Profiles -} -\examples{ -\dontrun{ -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 hysteroetomy, ages 21-65", "black (non-hispanic)") -} -} diff --git a/man/risk_women_health.Rd b/man/risk_women_health.Rd new file mode 100644 index 0000000..086cc88 --- /dev/null +++ b/man/risk_women_health.Rd @@ -0,0 +1,46 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/risk-womens-health.R +\name{risk_women_health} +\alias{risk_women_health} +\title{Access to Women's Health Data} +\usage{ +risk_women_health( + women_health, + race, + datatype = "direct estimates", + area = NULL +) +} +\arguments{ +\item{women_health}{Either "mammogram in past 2 years, ages 50-74", "mammogram in past 2 years, ages 40+", +"pap smear in past 3 years, no hysterectomy, ages 21-65"} + +\item{race}{One of the following values: "all races (includes hispanic)", "white (non-hispanic)", +"black (non-hispanic)", "amer. indian / ak native (non-hispanic)", +"asian / pacific islander (non-hispanic)","hispanic (any race)"} + +\item{datatype}{Either "direct estimates" or "county level modeled estimates"} + +\item{area}{A state/territory abbreviation or USA.} +} +\value{ +A data frame with the following columns: Area Type, Area Code, "Percent", "People Unemployed", "Rank" +} +\description{ +This function returns a data frame from Women's Health in State Cancer Profiles +} +\examples{ +\dontrun{ +risk_women_health(women_health = "mammogram in past 2 years, ages 50-74", + race = "all races (includes hispanic)", + datatype = "direct estimates") + +risk_women_health(women_health = "pap smear in past 3 years, no hysterectomy, ages 21-65", + race = "all races (includes hispanic)", + datatype = "county level modeled estimates", + area = "wa") + +risk_women_health(women_health = "pap smear in past 3 years, no hysteroetomy, ages 21-65", + race = "black (non-hispanic)") +} +} diff --git a/tests/testthat/test-risk-womens-health.R b/tests/testthat/test-risk-womens-health.R index d158f1b..508cfac 100644 --- a/tests/testthat/test-risk-womens-health.R +++ b/tests/testthat/test-risk-womens-health.R @@ -4,7 +4,7 @@ #' # tests class and typeof output test_that("Output data type is correct", { - output <- risk_whealth("mammogram in past 2 years, ages 50-74", + output <- risk_women_health("mammogram in past 2 years, ages 50-74", "all races (includes hispanic)", "direct estimates") expect_true(inherits(output, "data.frame")) @@ -17,16 +17,16 @@ womens_health_options <- c("mammogram in past 2 years, ages 50-74", for (option in womens_health_options) { test_that("risk_womens_health returns non-empty data frame", { - result <- risk_whealth(option, "all races (includes hispanic)", "direct estimates") + result <- risk_women_health(option, "all races (includes hispanic)", "direct estimates") expect_true(is.data.frame(result)) }) } #risk-womens health must have 5 columns test_that("risk-womens health has correct number of columns", { - df1 <- risk_whealth("mammogram in past 2 years, ages 50-74", + df1 <- risk_women_health("mammogram in past 2 years, ages 50-74", "all races (includes hispanic)", "direct estimates") - df2 <- risk_whealth("mammogram in past 2 years, ages 50-74", + df2 <- risk_women_health("mammogram in past 2 years, ages 50-74", "all races (includes hispanic)", "county level modeled estimates", "wa") expected_columns1 <- 6 @@ -38,5 +38,5 @@ test_that("risk-womens health has correct number of columns", { #parameter test_that("risk-womens health has correct parameters", { - expect_error(risk_whealth()) + expect_error(risk_women_health()) }) \ No newline at end of file