Skip to content

Commit

Permalink
edited documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
realbp committed Feb 28, 2024
1 parent 3d59bcc commit 5adc5ed
Show file tree
Hide file tree
Showing 16 changed files with 171 additions and 74 deletions.
22 changes: 16 additions & 6 deletions R/demo-education.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,34 @@
#' @param areatype Either "county", "hsa" (Health service area), or "state"
#' @param education Either "less than 9th grade", "at least high school", "at least bachelors degree"
#' @param sex Either "both sexes", "male", "female"
#' @param race One of the following values: "All Races (includes Hispanic)", "white (includes hispanic)" = "01",
#' @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)
#'
#' @importFrom httr2 req_url_query req_perform
#' @importFrom cli cli_abort
#' @importFrom stats setNames
#'
#' @returns A data frame with the following columns "County", "FIPS", "Percent", "Households", "Rank"
#' @returns A data frame with the following columns: Area Type, Area Code, "Percent", "Households", "Rank"
#'
#' @export
#'
#' @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")
#' }
demo_education <- function(area, areatype, education, sex=NULL, race=NULL) {

Expand Down
18 changes: 14 additions & 4 deletions R/demo-food-access.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,25 @@
#' @importFrom dplyr mutate
#' @importFrom stats setNames
#'
#' @returns A data frame with the following columns "County", "FIPS", "Value", "People"
#' @returns A data frame with the following columns: Area Type, Area Code, "Value", "People"
#'
#' @export
#'
#' @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)")
#' }
demo_food <- function(area, areatype, food, race=NULL) {

Expand Down
19 changes: 15 additions & 4 deletions R/demo-income.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,26 @@
#' @importFrom dplyr mutate
#' @importFrom stats setNames
#'
#' @returns A data frame with the following columns "County", "FIPS", "Dollars", "Rank"
#' @returns A data frame with the following columns: Area Type, Area Code, "Dollars", "Rank"
#'
#' @export
#'
#' @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)")
#' }
demo_income <- function(area, areatype, income, race) {

Expand Down
28 changes: 19 additions & 9 deletions R/demo-insurance.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,30 @@
#' @importFrom httr2 req_url_query req_perform
#' @importFrom cli cli_abort
#'
#' @returns A data frame with the following columns "County", "FIPS", "Percent", "People", "Rank"
#' @returns A data frame with the following columns: Area Type, Area Code, "Percent", "People", "Rank"
#'
#' @export
#'
#' @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")
#' }
demo_insurance <- function(area, areatype, insurance, sex, age, race=NULL) {

Expand Down
16 changes: 12 additions & 4 deletions R/demo-mobility.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,23 @@
#' @importFrom cli cli_abort
#' @importFrom stats setNames
#'
#' @returns A data frame with the following columns "County", "FIPS", "Percent", "People", "Rank"
#' @returns A data frame with the following columns: Area Type, Area Code, "Percent", "People", "Rank"
#'
#' @export
#'
#' @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)")
#' }
demo_mobility <- function(area, areatype, mobility) {

Expand Down
13 changes: 9 additions & 4 deletions R/demo-non-english-language.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,19 @@
#' @importFrom httr2 req_url_query req_perform
#' @importFrom stats setNames
#'
#' @returns A data frame with the following columns "County", "FIPS", "Percent", "Households", "Rank"
#' @returns A data frame with the following columns: Area Type, Area Code, "Percent", "Households", "Rank"
#'
#' @export
#'
#' @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")
demo_language <- function(area, areatype) {

req <- create_request("demographics")
Expand Down
23 changes: 18 additions & 5 deletions R/demo-population.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,35 @@
#' "american indian/alaska native", "asian/pacific islander", "black", "foreign born", "hispanic",
#' "non-hispanic (origin recode)", "white", "males", "females"
#' @param 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)"
#' @param sex Either "both sexes", "male", "female"
#'
#' @importFrom httr2 req_url_query req_perform
#' @importFrom cli cli_abort
#' @importFrom stats setNames
#'
#' @returns A data frame with the following columns "County", "FIPS", "Percent", "Households", "Rank"
#' @returns A data frame with the following columns: Area Type, Area Code, "Percent", "Households", "Rank"
#'
#' @export
#'
#' @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")
#'
#' }
demo_population <- function(area, areatype, population, race=NULL, sex=NULL) {
Expand Down
18 changes: 14 additions & 4 deletions R/demo-poverty.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,25 @@
#' @importFrom httr2 req_url_query req_perform
#' @importFrom stats setNames
#'
#' @returns A data frame with the following columns "County", "FIPS", "Percent", "Households", "Rank"
#' @returns A data frame with the following columns: Area Type, Area Code, "Percent", "Households", "Rank"
#'
#' @export
#'
#' @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)")
#' }
demo_poverty <- function(area, areatype, poverty, race=NULL, sex=NULL) {

Expand Down
11 changes: 8 additions & 3 deletions R/demo-svi.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,14 @@
#'
#' @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")
#' }
demo_svi <- function(area, svi) {

Expand Down
19 changes: 15 additions & 4 deletions R/demo-workforce.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,26 @@
#' @importFrom httr2 req_url_query req_perform
#' @importFrom stats setNames
#'
#' @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{
#' 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")
#' }
demo_workforce <- function(area, areatype, race, sex) {

Expand Down
4 changes: 3 additions & 1 deletion R/handle-race.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ handle_race <- function(race) {
"black" = "02",
"black (includes hispanic)" = "02",
"amer. indian/alaskan native (includes hispanic)" = "03",
"all ages, asian or pacific islander (includes hispanic)" = "04",
"american indian/alaska native" = "03",
"asian or pacific islander (includes hispanic)" = "04",
"asian/pacific islander" = "04",
"hispanic (any race)" = "05",

#screening and risk factors
Expand Down
16 changes: 9 additions & 7 deletions R/incidence-cancer.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@
#' @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, "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"
#' @returns A data frame with the following columns Areatype, 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"
#'
#' @export
#'
Expand All @@ -45,7 +44,7 @@
#' year = "latest single year (us by state)")
#'
#' incidence_cancer(area = "wa",
#' areatype = "county",
#' areatype = "hsa",
#' cancer = "ovary",
#' race = "all races (includes hispanic)",
#' sex = "females",
Expand Down Expand Up @@ -114,12 +113,15 @@ incidence_cancer <- function(area, areatype, cancer, race, sex, age, stage, year

areatype_map <- c("county" = "County", "hsa" = "Health Service Area", "state" = "State")
areatype_title <- areatype_map[areatype]

areacode_map <- c("county" = "FIPS", "state" = "FIPS", "hsa" = "HSA_Code")
areacode_title <- areacode_map[areatype]

if (stage == "all stages") {
resp %>%
setNames(c(areatype_title, "FIPS", "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"))
setNames(c(areatype_title, areacode_title, "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"))
} else if (stage == "late stage (regional & distant)") {
resp %>%
setNames(c(areatype_title, "FIPS", "Age Adjusted Incidence Rate", "Lower 95% CI", "Upper 95% CI", "CI Rank", "Lower CI Rank", "Upper CI Rank", "Annual Average Count", "Percentage of Cases with Late Stage"))
setNames(c(areatype_title, areacode_title, "Age Adjusted Incidence Rate", "Lower 95% CI", "Upper 95% CI", "CI Rank", "Lower CI Rank", "Upper CI Rank", "Annual Average Count", "Percentage of Cases with Late Stage"))
}
}
6 changes: 3 additions & 3 deletions R/mortality-cancer.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
#' @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 ***?",
#' "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"
#' "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"
#'
#' @export
#'
Expand Down
2 changes: 1 addition & 1 deletion man/incidence_cancer.Rd

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

Loading

0 comments on commit 5adc5ed

Please sign in to comment.