Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create tibble with numeric(0) doesn't give same result as NULL column #1569

Open
xtimbeau opened this issue Feb 7, 2024 · 1 comment
Open

Comments

@xtimbeau
Copy link

xtimbeau commented Feb 7, 2024

When creating a tibble with a NULL column no column is created. If the column is a numeric(0) vector, thant the tibble has no line (but the column is created). I may have missed the logic or a previous issue.

library(tibble)
# gives a one line tibble with one column
tibble(a=1, b=NULL)
# gives an empty tibble (surprinsingly and I'd prefer solution 1)
tibble(a=1, b=numeric(0))
@krlmlr
Copy link
Member

krlmlr commented Feb 9, 2024

Thanks, this is expected, and documented (somewhat hidden) in https://vctrs.r-lib.org/reference/theory-faq-recycling.html . Do we need a link from ?tibble to the reference I gave?

I do appreciate that the behavior is different from that of data.frame() . Perhaps this even warrants an explicit mention in ?tibble ?

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

No branches or pull requests

2 participants