as.data.frame.dust {pixiedust}R Documentation

Convert dust Object to Data Frame

Description

Sprinkles are applied to the dust object as if it were being prepared for printing to the console. However, instead of printing, the object is returned as a single data frame.

Usage

## S3 method for class 'dust'
as.data.frame(x, ..., sprinkled = TRUE)

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

Arguments

x

A dust object.

...

Arguments to be passed to other methods. Currently unused.

sprinkled

Logical. If TRUE, the sprinkles attached to the dust object are applied before returning the data frame. Sprinkles are applied via the same mechanism that prints to the console, so only sprinkles that are applicable to console output are used. When FALSE, pixiedust attempts to reconstruct the data frame (or tidied output from broom::tidy originally given to dust.

Details

In its current state, this can be a fairly inefficient function as the table, if the longtable option is in use, will be built in a for loop and bound together using rbind. This isn't really intended for large tables, but may be of assistance when there isn't a sprinkle that does what you want to do. (You can at least pull out the object as a data frame and do your own post processing).

Functional Requirements

  1. Accepts an object of class dust or dust_list

  2. Accepts a logical(1) indicating if the sprinkles should be applied to the data.

  3. For a dust object, returns an object of class data.frame

  4. For a dust_list object, returns a list of objects of class data.frame

Author(s)

Benjamin Nutter

Examples

fit <- lm(mpg ~ qsec + factor(am) + wt * factor(gear), data = mtcars)
Dust <- dust(fit) %>%
  sprinkle(cols = 2:4, round = 2) %>%
  sprinkle(cols = 5, fn = quote(pvalString(value))) %>%
  sprinkle(cols = 3, font_color = "#DA70D6") %>%
  sprinkle_print_method("html")
  
as.data.frame(Dust)


[Package pixiedust version 0.9.4 Index]