addn: Add number of occurences of a covariate

View source: R/pecc_addn.R

addnR Documentation

Add number of occurences of a covariate

Description

This function is used to modify a column containing a categorical covariate to add the number of occurences. It is mostly used with boxplot (inside plot_boxplot function for instance).

Usage

addn(dataset, col, ...)

Arguments

dataset

dataset to modify

col

a column to modify

...

all columns to used for grouping (ID most of the time)

Author(s)

Thibaud Derippe (Thibaud.Derippe@gmail.com)

Examples

mtcars %>%
 addn(carb) %>%
 ggplot()+
 geom_boxplot(aes(carb, mpg))


 Theoph %>%
   mutate(cov = sample(LETTERS[1:3], size = nrow(Theoph), replace = T)) %>%
   addn(cov, Subject)

Peccary-PMX/PeccAnalysis documentation built on July 7, 2022, 5:27 a.m.