Skip to content

combine(NULL) should return logical() instead of error #3365

@zeehio

Description

@zeehio

Given that combine() acts like c() I don't understand why combine() (without args) does not work like c() returning NULL and raises an error instead.

If I am combining a list that may contain all NULL elements, I'd rather get back a NULL than tryCatching or checking for that condition myself in advance. It's not a big deal, but it does not seem consistent with for instance bind_rows() that returns an empty tibble.

If you agreed I'd be happy to provide a pull request.

c(1, NULL, 2)
#> [1] 1 2
dplyr::combine(1, NULL, 2)
#> [1] 1 2
c()
#> NULL
dplyr::combine(NULL)
#> Error in combine_all(args): no data to combine, all elements are NULL
c(NULL, NULL)
#> NULL
dplyr::combine(NULL, NULL)
#> Error in combine_all(args): no data to combine, all elements are NULL

As always, thanks for your time

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