p_table: Tables variables, with support for piping

View source: R/p_table.r

p_tableR Documentation

Tables variables, with support for piping

Description

A wrapper function for table(), with support for piping.

Usage

p_table(data, x, y = NULL, ...)

Arguments

data

the data

x

one variable

y

another variable

...

additional arguments passed to table().

Value

a table object

Examples

# load the data
data(nhanes)

# define smoking
nhanes<-nhanes |> transform(
  smoking=base_match(smq020,'No'=2,'History of smoking'=1)
)

# define asthma
nhanes<-nhanes |> transform(
  asthma=base_match(mcq010,'Asthma'=1,'No'=2)
)

# table smoking
nhanes |> p_table(smoking)

# table smoking and asthma
nhanes |> p_table(smoking,asthma)

baseverse documentation built on April 29, 2026, 1:08 a.m.