addNCountColumn: Add a column to a tidy data set with the count of...

View source: R/plotting_misc.R

addNCountColumnR Documentation

Add a column to a tidy data set with the count of observations appended

Description

This function returns a tidy data set with one addition column which contains a variable name with the counts appended. As an example, suppose you had 10 observations of category (column named your_category) 'A' and 12 observations of category 'B'. The output will add this additional column: your_category. <chr> A\n(n=10) B\n(n=12)

Usage

addNCountColumn(dataSet, countField, addNewline = T)

Arguments

addNewline

Optional: Add a newline between the category name and the variable count, defaults to true

dataSet:

A tidy data set

countField:

A column to use for counting

Details

This is most useful for making a new categorical variable name to pass to a ggplot bar/box plot.


mbergins/BerginskiRMisc documentation built on Aug. 5, 2022, 4:16 a.m.