Skip to content

extract fails on empty data.frame #313

@antoine-sachet

Description

@antoine-sachet

Reproducible example using tidyr 0.6.3.9000:

df <- data.frame(col1=character(0))
tidyr::extract(df, col1, into="col2", regex="(whatever)")

Expected behaviour: should return an empty data.frame with a new empty column "col2".

Actual behaviour: fails with error:
Error in names(l) <- enc2utf8(into) : 'names' attribute [1] must be the same length as the vector [0]

Why it should be fixed: this makes an otherwise valid pipeline fail when the result of a filter happens to be empty. This requires boiler-plate to guard against empty data when programming with extract.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions