count: Count and percentage of a factor level.

Description Usage Arguments Value Examples

Description

Returns a string with the count and/or percentage of a particular level of a factor for easy reporting in general but specifically for sweaved/knitted documents.

Usage

1
2
3
4
5
count(var, value, data = NULL, operator = c("match", "equal", "less",
  "greater", "lesseq", "greatereq", "is.na", "isnot.na"), na.rm = FALSE,
  show.n = TRUE, show.percent = TRUE,
  digits = getOption("qwraps.percent.digits", 1), big.mark = ",",
  latex = getOption("qwraps.latex", TRUE))

Arguments

var

name of a factor in a data frame.

val

value(s)/level(s) of interest to count

data

data.frame with var included, default to NULL. Function is intended to be used with data in data frames.

operator

The boolean operator to use. Default is the match, i.e., %in% operator.

na.rm

a logical indicating whether missing values should be removed.

show.n

Boolean, default to TRUE, to show the raw counts.

show.percent

Boolean, default to TRUE, for reporting the percentage with the count.

digits

Number of decimal places to report a percentage with. This includes trailing zeros.

latex

Not currently implemented.

Value

A sting of the form n, (%).

Examples

1
2
3
4
## Load example data set diamonds from the ggplot2 package
data(diamonds, package = "ggplot2")

## find a report the number and percentage of "Fair", and/or "Good" cut diamonds

dewittpe/qwraps documentation built on May 15, 2019, 5:07 a.m.