When you call as_tibble() without any arguments, it creates an empty tibble. This is a desired behavior for tibble() but I can't imagine a scenario when someone intentionally wants to create an empty tibble using as_tibble().
as_tibble()
# A tibble: 0 x 0
The analogous function from base R is as.data.frame(), which throws an error when called without parameters.
as.data.frame()
#Error in as.data.frame() : argument "x" is missing, with no default
This isn't really a bug since the problem results from a mistake in writing code. I noticed it when I forgot to add a pipe in a chain of operations. Below is a convoluted example. You shouldn't necessarily try to protect us from ourselves. But I figured it was still worth documenting.
mtcars %>%
select(mpg, hp, wt)
as_tibble() -> mt_tibble
You might consider adding a warning.
as_tibble()
# Warning: as_tibble() called without any arguments. Empty tibble returned. To avoid this warning, call tibble() instead of as_tibble().
When you call as_tibble() without any arguments, it creates an empty tibble. This is a desired behavior for tibble() but I can't imagine a scenario when someone intentionally wants to create an empty tibble using as_tibble().
as_tibble() # A tibble: 0 x 0The analogous function from base R is as.data.frame(), which throws an error when called without parameters.
as.data.frame() #Error in as.data.frame() : argument "x" is missing, with no defaultThis isn't really a bug since the problem results from a mistake in writing code. I noticed it when I forgot to add a pipe in a chain of operations. Below is a convoluted example. You shouldn't necessarily try to protect us from ourselves. But I figured it was still worth documenting.
You might consider adding a warning.
as_tibble() # Warning: as_tibble() called without any arguments. Empty tibble returned. To avoid this warning, call tibble() instead of as_tibble().