Learn R Programming

pixiedust (version 0.5.0)

as.data.frame.dust: 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)

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

Details

In its current state, this can be a fairly ineffcient 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).

Examples

Run this code
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)

Run the code above in your browser using DataLab