mat_add_perc: Add percentage column

Description Usage Arguments Examples

Description

Add percentage column

Usage

1
mat_add_perc(df, ..., .name = n, warn_grouped = TRUE)

Arguments

df

data

.name

Name of n

warn_grouped

Should warn that already grouped? Default TRUE

...

variables to group for

Examples

1
2
3
4
5
6
7
8
9
 library(tibble)
 library(magrittr)
 library(dplyr)
  df <- tibble(group = rep(letters[1:2], each = 2),
  n = c(3, 2,3, 5))
  df %>% mat_add_perc()
  df %>% mat_add_perc(group)
  df %>% rename(N=n) %>% mat_add_perc(.name = N)
  df %>% rename(N=n) %>% mat_add_perc(group, .name = N)

MatthieuStigler/matPkg documentation built on Aug. 10, 2021, 11:01 a.m.