# `new_data_frame()` can be used to create custom data frame constructors
new_fancy_df <- function(x = list(), n = NULL, ..., class = NULL) {
new_data_frame(x, n = n, ..., class = c(class, "fancy_df"))
}
# Combine this constructor with `df_list()` to create a safe,
# consistent helper function for your data frame subclass
fancy_df <- function(...) {
data <- df_list(...)
new_fancy_df(data)
}
df <- fancy_df(x = 1)
class(df)
Run the code above in your browser using DataLab