Overview

baseverse is intended to be a relatively minimal suite of packages, supporting the use of base R with native piping.

Several functions are wrapper functions for existing base-R functions, adding support for native piping:

Other functions are wrapper functions for existing base-R features:

Other functions mimic tidyverse functions:

Loading the package

Load the package:

library(baseverse)

Load the data

This vignette will draw from the built-in nhanes data:

data(nhanes)

Country of birth

Table the dmdborn4 variable:

nhanes |> p_table(dmdborn4)

Create a new, labelled version of dmdborn4:

nhanes<-nhanes |> transform(
  country=base_match(dmdborn4,'USA'=1,'Other'=2)
)

Table the new variable using p_table():

nhanes |> p_table(country)

Or, table the new variable using et():

nhanes |> et(country)

Notice that the USA group is listed first. This is, deliberately, hugely different behavior from case_match().

Total cholesterol

Summarize the lbxtc variable:

nhanes$lbxtc |> summary()

Or, using dollar():

nhanes |> dollar(lbxtc) |> summary()

Create a categorical variable for total cholesterol:

nhanes<-nhanes |>
  transform(
    cholesterol=base_when(
      'Desirable' = (lbxtc<200),
      'Borderline high' = (lbxtc>=200)&(lbxtc<240),
      'High' = (lbxtc>=240)
    )
  )

Table the new variable using p_table():

nhanes |> p_table(cholesterol)

Or, table the new variable using et():

nhanes |> et(cholesterol)

Notice that the Desirable group is listed first. This is, deliberately, hugely different behavior from case_when().

Linear regression

Fit a linear model for systolic blood pressure (bpxosy1):

model_1<-nhanes |> 
  p_lm(bpxosy1~ridageyr+country+lbxtc) 

Summarize the model:

model_1 |>
  summary()

Obtain 95% confidence intervals for the coefficients:

model_1 |>
  confint()


Try the baseverse package in your browser

Any scripts or data that you put into this service are public.

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