data_frame: Cheap data frame utilities

new_dfR Documentation

Cheap data frame utilities

Description

Cheap data frame utilities

Usage

new_df(..., .nrows = NULL, .recycle = TRUE, .name_repair = TRUE, .args = NULL)

as_df(x)

fast_df(..., .args = NULL)

df_modify(x, cols)

list_as_df(x)

name_repair(x, dup_sep = "_", empty_sep = "col_")

unique_name_repair(x, dup_sep = "_", empty_sep = "col_")

col_c(..., .recycle = TRUE, .name_repair = TRUE, .args = NULL)

row_c(..., .args = NULL)

Arguments

...

Key-value pairs.

.nrows

⁠[integer(1)]⁠ - (Optional) number of rows.
Commonly used to initialise a 0-column data frame with rows.

.recycle

⁠[logical(1)]⁠ - Should arguments be recycled? Default is TRUE.

.name_repair

⁠[logical(1)]⁠ - Should duplicate and empty names repaired and made unique? Default is TRUE.

.args

An alternative to ... for easier programming with lists.

x

An object to coerce to a data.frame or a character vector for unique_name_repair().

cols

A list of values to add or modify data frame x.

dup_sep

⁠[character(1)]⁠ A separator to use between duplicate column names and their locations. Default is '_'

empty_sep

⁠[character(1)]⁠ A separator to use between the empty column names and their locations. Default is 'col_'

Details

fast_df() is a very fast bare-bones version of new_df() that performs no checks and no recycling or name tidying, making it appropriate for very tight loops.

Value

A data.frame.
name_repair takes a character vector and returns unique strings by appending duplicate string locations to the duplicates. This is mostly used to create unique col names.


cheapr documentation built on June 8, 2025, 11:35 a.m.