countpct: Summarize two columns as N (%)

View source: R/countpct.R

countpctR Documentation

Summarize two columns as N (%)

Description

Provided two columns, create a new column representing a number and percentage

Usage

countpct(.data, n, perc, name = "N", accuracy = 0.01, remove = TRUE)

Arguments

.data

A tbl.

n

Column of values.

perc

Column of percentages (as decimals).

name

Name of new column.

accuracy

Number to round to, NULL for automatic guess.

remove

If TRUE, remove input columns from output data frame.

Examples

iris %>%
  dplyr::group_by(Species) %>%
  dplyr::summarise(n = dplyr::n()) %>%
  dplyr::ungroup() %>%
  dplyr::mutate(freq = prop.table(n)) %>%
  countpct(n, freq)

overdodactyl/mRclwhip documentation built on June 30, 2023, 6:24 a.m.