ff_np: Parse a binary variable as 'n' and 'percent'

Description Usage Arguments Examples

Description

Return a list that summarises the count (n) and percentage of a vector

Usage

1
ff_np(var, data = dt, dp = 1)

Arguments

var

a categorical variable

data

a data frame (or data.table)

dp

number of decimal places in formatted response

Examples

1
2
3
4
5
6
7
8
9
# Create data.frame and summarise proportion of A's and B's
set.seed(1)
dt <- data.frame(choice=sample(c("A", "B"), 100, replace=TRUE))
table(dt$choice)
npct <- ff_np(choice, data=dt)
# choice
#    v  n pct
# 1: A 52  52
# 2: B 48  48

datascibc/dsbc documentation built on May 14, 2019, 7:45 p.m.