A function to calculate and format a count and percent.
The input data vector or data frame column.
The denominator to use for the percentage. By default, the parameter is NULL, meaning the function will use the number of non-missing values of the data vector as the denominator. Otherwise, supply the denominator as a numeric value.
A formatting string suitable for input into the
This function calculates a percent and appends to the provided count. The input vector is assumed to contain the counts. This function will not perform counting. It will calculate percentages and append to the given counts.
The result is then formatted using
sprintf. By default,
the number of non-missing values in the input data vector is used as the
Alternatively, you may supply the denominator using the denom
You may also control the percent format using the format parameter.
The function will return any NA values in the input data unaltered.
If the calculated percentage is between 0% and 1%, the function will display "(< 1.0%)" as the percentage value. Zero values will be displayed as "( 0.0%)"
A character vector of formatted counts and percents.
1 2 3 4 5 6 7 8
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.