-
Notifications
You must be signed in to change notification settings - Fork 135
Closed
Description
It is possible to mutilate a tibble and pass it through as_tibble(), even with validate = TRUE, without having the problems called out. Should validate be used even in this case?
library(tibble)
df <- tibble(
x = 1:3,
y = 4:6
)
names(df) <- ""
as_tibble(df)
#> # A tibble: 3 x 2
#> `` `NA`
#> <int> <int>
#> 1 1 4
#> 2 2 5
#> 3 3 6
as_tibble(df, validate = TRUE)
#> # A tibble: 3 x 2
#> `` `NA`
#> <int> <int>
#> 1 1 4
#> 2 2 5
#> 3 3 6
tibble:::check_tibble(df)
#> Error: Columns 1, 2 must be namedHow this came up for me: I'm creating an S3 class that extends tibble. After some operations, my object should no longer bear that class, but should revert to being a plain tibble. Instead of only hand-editing the class, it seems like a good idea to also run it through as_tibble(). But then I found that as_tibble() just passes tibbles straight through, without any validation.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels