Skip to content

Commit

Permalink
Merge pull request #38 from getwilds/documentation
Browse files Browse the repository at this point in the history
edited incidence and mortality docs
  • Loading branch information
realbp authored Feb 27, 2024
2 parents b0bbe7a + 3d59bcc commit 13ba3db
Show file tree
Hide file tree
Showing 7 changed files with 170 additions and 87 deletions.
27 changes: 20 additions & 7 deletions R/demo-crowding.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,35 @@
#'
#' @param area A state/territory abbreviation or USA.
#' @param areatype Either "county", "hsa" (Health service area), or "state"
#' @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 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 stats setNames
#'
#' @returns A data frame with the following columns "County", "FIPS", "Percent", "Households", "Rank"
#' @returns A data frame with the following columns Area, Area Code, "Percent", "Households", "Rank"
#'
#' @export
#'
#' @examples
#' \dontrun{
#' demo_crowding("WA", "hsa", "All Races (includes Hispanic)")
#' demo_crowding("usa", "state", "All Races (includes Hispanic)")
#' demo_crowding("pr", "hsa", "black")
#' demo_crowding(area = "WA",
#' areatype = "hsa",
#' race = "All Races (includes Hispanic)")
#'
#' demo_crowding(area = "usa",
#' areatype = "state",
#' race = "All Races (includes Hispanic)")
#'
#' demo_crowding(area = "pr",
#' areatype = "hsa",
#' race = "black")
#' }
demo_crowding <- function(area, areatype, race) {

Expand Down
49 changes: 35 additions & 14 deletions R/incidence-cancer.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,43 @@
#' @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 "State", "FIPS", "Percent", "Lower 95% CI", "Upper 95% CI", "Number of Respondents"
#' @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"
#'
#' @export
#'
#' @examples
#' \dontrun{
#' incidence_cancer("wa", "county", "all cancer sites", "black (non-hispanic)",
#' "both sexes", "ages 65+", "all stages")
#' incidence_cancer("wa", "county", "lung & bronchus", "all races (includes hispanic)", "males",
#' "ages 50+", "late stage (regional & distant)")
#' incidence_cancer("usa", "state", "lung & bronchus", "all races (includes hispanic)", "males",
#' "ages 50+", "late stage (regional & distant)")
#' incidence_cancer(area="wa", areatype="county", cancer="ovary", race="all races (includes hispanic)",
#' sex="females", age="ages 50+", stage="late stage (regional & distant)")
#' incidence_cancer("ca", "hsa", "prostate", "all races (includes hispanic)", "males",
#' "ages 50+", "all stages")
#' incidence_cancer("ca", "hsa", "childhood (ages <20, all sites)", "all races (includes hispanic)",
#' "males", "ages <20", "all stages")
#' incidence_cancer(area = "wa",
#' areatype = "county",
#' cancer = "all cancer sites",
#' race = "black (non-hispanic)",
#' sex = "both sexes",
#' age = "ages 65+",
#' stage = "all stages",
#' year = "latest 5 year average")
#'
#' incidence_cancer(area = "usa",
#' areatype = "state",
#' cancer = "lung & bronchus",
#' race = "all races (includes hispanic)",
#' sex = "males",
#' age = "ages 50+",
#' stage = "late stage (regional & distant)",
#' year = "latest single year (us by state)")
#'
#' incidence_cancer(area = "wa",
#' areatype = "county",
#' cancer = "ovary",
#' race = "all races (includes hispanic)",
#' sex = "females",
#' age = "ages 50+",
#' stage = "late stage (regional & distant)",
#' year = "latest 5 year average")
#' }
incidence_cancer <- function(area, areatype, cancer, race, sex=NULL, age, stage, year="latest 5 year average") {
incidence_cancer <- function(area, areatype, cancer, race, sex, age, stage, year) {

allstage_cancer <- c("all cancer sites", "breast (female in situ)", "childhood (ages <15, all sites)",
"childhood (ages <20, all sites)", "leukemia")
Expand All @@ -45,6 +62,10 @@ incidence_cancer <- function(area, areatype, cancer, race, sex=NULL, age, stage,

childhood_cancer <- c("childhood (ages <15, all sites)", "childhood (ages <20, all sites)")

if ((areatype == "county" || areatype == "hsa") && year == "latest single year (us by state)") {
cli_abort("For year latest single year (us by state), areatype must be state")
}

if ((cancer %in% allstage_cancer) && stage == "late stage (regional & distant)") {
cli_abort("For this cancer type, stage must be all stages")
}
Expand Down
46 changes: 33 additions & 13 deletions R/mortality-cancer.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,52 @@
#' @param 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)"
#' @param sex Either "both sexes", "males", "females"
#' @param sex Defaulted to NULL. Specify either "both sexes", "males", "females" if necessary
#' @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 "State", "FIPS", "Percent", "Lower 95% CI", "Upper 95% CI", "Number of Respondents"
#' @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"
#'
#' @export
#'
#' @examples
#' \dontrun{
#' mortality_cancer("wa", "county", "all cancer sites", "black (non-hispanic)",
#' "both sexes", "ages 65+")
#' mortality_cancer("ca", "hsa", "lung & bronchus", "all races (includes hispanic)",
#' "males", "ages 50+")
#' mortality_cancer("usa", "state", "prostate", "all races (includes hispanic)",
#' "males", "ages 50+")
#' mortality_cancer(area="wa", areatype="county", cancer="ovary", race="all races (includes hispanic)",
#' sex="females", age="ages 50+")
#' mortality_cancer("ca", "hsa", "childhood (ages <20, all sites)", "all races (includes hispanic)",
#' "males", "ages <20")
#' mortality_cancer(area = "wa",
#' areatype = "county",
#' cancer = "all cancer sites",
#' race = "black (non-hispanic)",
#' sex = "both sexes",
#' age = "ages 65+",
#' year = "latest 5 year average")
#'
#' mortality_cancer(area = "usa",
#' areatype = "state",
#' cancer = "prostate",
#' race = "all races (includes hispanic)",
#' sex = "males",
#' age = "ages 50+",
#' year = "latest single year (us by state)")
#'
#' mortality_cancer(area = "wa",
#' areatype = "hsa",
#' cancer = "ovary",
#' race = "all races (includes hispanic)",
#' sex = "females",
#' age = "ages 50+",
#' year = "latest 5 year average")
#' }
mortality_cancer <- function(area, areatype, cancer, race, sex=NULL, age, year="latest 5 year average") {
mortality_cancer <- function(area, areatype, cancer, race, sex, age, year) {
female_cancer <- c("breast (female)", "ovary", "uterus (corpus & uterus, nos)")

childhood_cancer <- c("childhood (ages <15, all sites)", "childhood (ages <20, all sites)")

if ((areatype == "county" || areatype == "hsa") && year == "latest single year (us by state)") {
cli_abort("For year latest single year (us by state), areatype must be state")
}

if ((cancer %in% female_cancer) && (sex == "males" || sex == "both sexes")) {
cli_abort("For this cancer type, sex must be females")
} else if (cancer == "prostate" && (sex == "females" || sex == "both sexes")) {
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ You can install the development version of `rcromwell` from [GitHub](https://git
pak::pak("getwilds/cancerprof")
```

## Support

## Contact
For questions, feedback, or inquiries, please contact Brian Park: [email protected]
For questions, bugs, or feature requests, please reach out to Brian Park at [email protected], or open an issue on our [issue tracker](https://github.com/getwilds/cancerprof/issues)
27 changes: 20 additions & 7 deletions man/demo_crowding.Rd

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

54 changes: 31 additions & 23 deletions man/incidence_cancer.Rd

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

50 changes: 29 additions & 21 deletions man/mortality_cancer.Rd

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

0 comments on commit 13ba3db

Please sign in to comment.