Skip to content

Unnest deprecated options processing prevents S3 generics extension #1612

@robchallen

Description

@robchallen

I'm having trouble extending tidyr::unnest generic in my package dtrackr which records what is happening to data frames as they go through a dplyr style pipeline to create a flowchart.

The problem is that in tidyr::unnest deprecated options are processed before the call is dispatched with UseMethod("unnest", ...).

The deprecated options processing throws an error if certain types of additional ... parameters are provided - this is because on line 113-114 of unnest.R there is the following call:

    dots <- enquos(cols, ..., .named = TRUE, .ignore_empty = "all")
    data <- dplyr::mutate(data, !!!dots)

This mutate call can fail, for example in my case I want to give the user the option to pass an additional .messages parameter when unnesting a tracked_df dataframe but the call:

dplyr::starwars %>%
    unnest(films, .messages=c("A test message","another test message"))

throws an error before S3 dispatch at line 114.

Would it be possible to move the code processing the deprecated options into a utility function and call it from unnest.data.frame and unnest.rowwise_df so that I can intercept the additional parameters before flow passes back to tidyr::unnest.data.frame ?

Either that or allow the check to fail more gracefully if unexpected input is encountered?

Many thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurea feature request or enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions