count_fcds: Count FCDS Cases

Description Usage Arguments Value Examples

View source: R/fcds.R

Description

Helper function to count cancer cases in the FCDS data by year and age group, in addition to any groups already present in the data. For convenience, you may additionally filter to include particular values of sex, race, year, county name and hispanic ethnicity. See fcds_const() for more information about possible values for these variables. By default, count_fcds() ensures that age_group, year_group, and year are included in the grouping variables if they are present in the data. If they are not, or if they are not present in the FCDS data, then it would be better to use dplyr::count() directly.

Usage

1
2
3
4
count_fcds(data, ..., sex = NULL, race = NULL, origin = NULL,
  county_name = NULL, default_groups = c("year_group", "year",
  "age_group"), discard_unseen_levels = TRUE,
  moffitt_catchment = FALSE)

Arguments

data

A data frame

...

Unquoted column names to be added to the grouping of the output and subsequent counting.

sex

Character vector of values of sex to be included in count, or TRUE to include all values of sex present in input data

race

Character vector of values of race to be included in count, or TRUE to include all values of race present in input data

origin

Character vector of values of origin to be included in count, or TRUE to include all values of origin present in input data

county_name

Character vector of values of county_name to be included in count, or TRUE to include all values of county_name present in the input data, or "moffitt" to limit to the counties in the catchment area of the Moffitt Cancer Center.

default_groups

Variables that should be included in the grouping, prior to counting cancer cases. Set to NULL to use only the groups already present in the input data.

discard_unseen_levels

If TRUE, drops factor levels that don't appear in the results. If FALSE, then no changes are made to the factor levels. If a character string of column names, then only unobserved levels in those columns are dropped.

moffitt_catchment

Deprecated. Please use county_name = "moffitt" instead to limit counties to those in the catchment area of the Moffitt Cancer Center.

Value

A grouped data frame with counts. The output groups includes the union of the groups of the original input data, the groups specified by the columns indicated in ..., and the default_groups added by count_fcds() (modifyable by the default_groups argument).

All factor levels will be modified to include only those levels that appear in the final output across all groups.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
fcds_example %>%
  dplyr::filter(county_name == "Pinellas") %>%
  count_fcds(cancer_site_group, sex = "Male", county_name = TRUE) %>%
  head()

fcds_example %>%
  filter_age_groups(age_gt = 20, age_lt = 25) %>%
  count_fcds(sex = TRUE, county_name = c("Pinellas", "Hillsborough"))

fcds_example %>%
  count_fcds(county_name = "moffitt") %>%
  head()

GerkeLab/fcds documentation built on July 30, 2020, 7:04 p.m.