dt_uncount: Uncount

Description Usage Arguments Examples

View source: R/uncount.R

Description

Uncount a counted data table

Usage

1
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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
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 if .remove = TRUE or .id is not null
          # this won't print the first time
          # due to a printing behavior in data.table

TysonStanley/tidyfast documentation built on Dec. 8, 2019, 9:46 a.m.