Summarize categorical data
Usage
cat_data(
data,
cols,
by = ".total",
panel = by,
summarize_all = TRUE,
all_name = "All",
wide = FALSE,
nby = NULL,
complete = FALSE,
denom = c("group", "total")
)Arguments
- data
the data frame to summarize; the user should filter or subset so that
datacontains exactly the records to be summarized; pmtables will not add or remove rows prior to summarizingdata- cols
the columns to summarize; may be character vector or quosure
- by
a grouping variable; may be character vector or quosure
- panel
data set column name to stratify the summary
- summarize_all
logical indicating whether or not to include a summary of the full data in the output.
- all_name
label for full data summary.
- wide
logical; ifTRUE, data frame will be returned in wide format; ifFALSE, it will be returned inlongformat.- nby
number of unique levels for the
byvariable.- complete
logical; if
TRUE, then data the summary will be completed for missing levels ofbyandpanel.- denom
the denominator to use when calculating percent for each level;
groupuses the total number in the chunk being summarized;totaluses the total number in the data set; historically,grouphas been used as the default.
Examples
cat_data(pmt_first, cols = c(SEX = "SEXf", RF = "RFf"), by = "STUDYf")
#> # A tibble: 6 × 6
#> name level `12-DEMO-001` `12-DEMO-002` `11-DEMO-005` `13-DEMO-001`
#> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 SEX male 10 (33.3) 18 (36.0) 29 (72.5) 23 (57.5)
#> 2 SEX female 20 (66.7) 32 (64.0) 11 (27.5) 17 (42.5)
#> 3 RF normal 30 (100.0) 50 (100.0) 10 (25.0) 40 (100.0)
#> 4 RF mild 0 (0.0) 0 (0.0) 10 (25.0) 0 (0.0)
#> 5 RF moderate 0 (0.0) 0 (0.0) 10 (25.0) 0 (0.0)
#> 6 RF severe 0 (0.0) 0 (0.0) 10 (25.0) 0 (0.0)
