collect.dtplyr_step: Force computation of a lazy data.table

View source: R/step.R

collect.dtplyr_stepR Documentation

Force computation of a lazy data.table

Description

  • collect() returns a tibble, grouped if needed.

  • compute() generates an intermediate assignment in the translation.

  • as.data.table() returns a data.table.

  • as.data.frame() returns a data frame.

  • as_tibble() returns a tibble.

Usage

## S3 method for class 'dtplyr_step'
collect(x, ...)

## S3 method for class 'dtplyr_step'
compute(x, name = unique_name(), ...)

## S3 method for class 'dtplyr_step'
as.data.table(x, keep.rownames = FALSE, ...)

## S3 method for class 'dtplyr_step'
as.data.frame(x, ...)

## S3 method for class 'dtplyr_step'
as_tibble(x, ..., .name_repair = "check_unique")

Arguments

x

A lazy_dt

...

Arguments used by other methods.

name

Name of intermediate data.table.

keep.rownames

Ignored as dplyr never preserves rownames.

.name_repair

Treatment of problematic column names

Examples

library(dplyr, warn.conflicts = FALSE)

dt <- lazy_dt(mtcars)

# Generate translation
avg_mpg <- dt %>%
  filter(am == 1) %>%
  group_by(cyl) %>%
  summarise(mpg = mean(mpg))

# Show translation and temporarily compute result
avg_mpg

# compute and return tibble
avg_mpg_tb <- as_tibble(avg_mpg)
avg_mpg_tb

# compute and return data.table
avg_mpg_dt <- data.table::as.data.table(avg_mpg)
avg_mpg_dt

# modify translation to use intermediate assignment
compute(avg_mpg)


dtplyr documentation built on March 31, 2023, 9:13 p.m.