Learn R Programming

broom (version 0.3.4)

rowwise_df_tidiers: Tidying methods for rowwise_dfs from dplyr, for tidying each row and recombining the results

Description

These tidy, augment and glance methods are for performing tidying on each row of a rowwise data frame created by dplyr's group_by and do operations. They first group a rowwise data frame based on all columns that are not lists, then perform the tidying operation on the specified column. This greatly shortens a common idiom of extracting tidy/augment/glance outputs after a do statement.

Usage

## S3 method for class 'rowwise_df':
tidy(x, data, ...)

## S3 method for class 'rowwise_df': tidy_(x, data, ...)

## S3 method for class 'rowwise_df': augment(x, data, ...)

## S3 method for class 'rowwise_df': augment_(x, data, ...)

## S3 method for class 'rowwise_df': glance(x, data, ...)

## S3 method for class 'rowwise_df': glance_(x, data, ...)

Arguments

x
a rowwise_df
data
the column name of the column containing the models to be tidied. For tidy, augment, and glance it should be the bare name; for _ methods it should be quoted. Note that this argument is named data so as to be consistent with the augment
...
additional arguments to pass on to the respective tidying method

Value

  • A "grouped_df", where the non-list columns of the original are used as grouping columns alongside the tidied outputs.

Details

Note that this functionality is currently implemented for data.tables, since the result of the do operation is difficult to distinguish from a regular data.table.

Examples

Run this code
library(dplyr)
regressions <- mtcars %>% group_by(cyl) %>% do(mod = lm(mpg ~ wt, .))
regressions

regressions %>% tidy(mod)
regressions %>% augment(mod)
regressions %>% glance(mod)

# we can provide additional arguments to the tidying function
regressions %>% tidy(mod, conf.int = TRUE)

Run the code above in your browser using DataLab