dt_uncount: Uncount

View source: R/uncount.R

dt_uncountR Documentation

Uncount

Description

Uncount a counted data table

Usage

dt_uncount(dt_, weights, .remove = TRUE, .id = NULL)

Arguments

dt_

the data table to uncount

weights

the counts for each

.remove

should the weights variable be removed?

.id

an optional new id variable, providing a unique id for each row

Value

A data.table with a row for each uncounted column.

Examples


library(data.table)

dt_count <- data.table(
  x = LETTERS[1:3],
  w = c(2, 1, 4)
)
uncount <- dt_uncount(dt_count, w, .id = "id")
uncount[] # note that `[]` forces the printing

TysonStanley/tidyfast documentation built on Feb. 6, 2024, 3:37 p.m.