Creates a subclass of a tibble. This function is mostly useful for package authors that implement subclasses of a tibble, like sf or tibbletime.

new_tibble(x, ..., nrow = NULL, subclass = NULL)

A tibble-like object


Passed on to structure()


The number of rows, guessed from the data by default


Subclasses to assign to the new object, default: none


x must be a named (or empty) list, but the names are not currently checked for correctness.

The ... argument allows adding more attributes to the subclass.

The row.names attribute will be computed from the nrow argument, overriding any existing attribute of this name in x or in the ... arguments. If nrow is NULL, the number of rows will be guessed from the data. The new_tibble() constructor makes sure that the row.names attribute is consistent with the data before returning.

The class attribute of the returned object always consists of c("tbl_df", "tbl", "data.frame"). If the subclass argument is set, it will be prepended to that list of classes.

  • new_tibble
library(tibble) # NOT RUN { new_tibble(list(a = 1:3, b = 4:6)) # One particular situation where the nrow argument is essential: new_tibble(list(), nrow = 150, subclass = "my_tibble") # It's safest to always pass it along: new_tibble(list(a = 1:3, b = 4:6), nrow = 3) # } # NOT RUN { # All columns must be the same length: new_tibble(list(a = 1:3, b = 4.6)) # The length must be consistent with the nrow argument if available: new_tibble(list(a = 1:3, b = 4:6), nrow = 2) # }
Documentation reproduced from package tibble, version 1.4.2, License: MIT + file LICENSE

Community examples

Looks like there are no examples yet.