cheapr_c: A cheapr version of 'c()'

c_R Documentation

A cheapr version of c()

Description

cheapr's version of c(). It is quite a bit faster for atomic vectors and combines data frame rows instead of cols.

Usage

c_(..., .args = NULL)

cheapr_c(..., .args = NULL)

Arguments

...

Objects to combine.

.args

An alternative to ... so you can supply arguments directly in a list.
This is equivalent to do.call(f, .args) but much more efficient.

Value

Combined objects.

Examples

library(cheapr)

# Combine just like `c()`
c_(1, 2, 3:5)

# It combines rows by default instead of cols
c_(new_df(x = 1:3), new_df(x = 4:10))

# If you have a list of objects you want to combine
# use `.args` instead of `do.call` as it's more efficient

list_of_objs <- rep_(list(0), 10^4)

bench::mark(
  do.call(c, list_of_objs),
  do.call(c_, list_of_objs),
  c_(.args = list_of_objs) # Fastest
)


cheapr documentation built on Nov. 28, 2025, 5:06 p.m.