Skip to content

complete and expand with length zero values #331

Description

@mgirlich

complete() raises an error when a value for a column to expand is of length zero. The reason for this is that expand() returns NULL resp. a 0 x 0 tibble for a length zero value.

In my opinion it would be better for expand() to return a dataframe/tibble with the same column specification as the original one (or raise a more informative error). This would also fix the problem with complete().

tidyr::complete(data.frame(a = character()), a = NULL)
#> Error in UseMethod("left_join"): no applicable method for 'left_join' applied to an object of class "NULL"
tidyr::expand(data.frame(a = character()), a = NULL)
#> NULL
tidyr::expand(tibble::tibble(a = character()), a = NULL)
#> # A tibble: 0 x 0

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behaviorpivoting ♻️pivot rectangular data to different "shapes"

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions