p_t.test: Conducts t-tests, with support for piping

View source: R/p_t.test.r

p_t.testR Documentation

Conducts t-tests, with support for piping

Description

A wrapper function for t.test(), with the data argument listed first to support piping.

Usage

p_t.test(data, x = NULL, y = NULL, formula = NULL, ...)

Arguments

data

the data

x

one of two variables

y

one of two variables

formula

a formula

...

additional arguments passed to stats::t.test().

Value

an htest object

Examples

# load the data
data(nhanes)

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

# conduct a one-sample t-test
nhanes |> p_t.test(bpxosy1)

# conduct a two-sample t-test, using formula notation
nhanes |> p_t.test(bpxosy1~smoking)

# conduct a two-sample t-test, using formula notation
nhanes |> p_t.test(formula=bpxosy1~smoking)

# conduct a paired t-test, using x and y
nhanes |> p_t.test(bpxosy1,bpxosy2,paired=TRUE)

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