Skip to content

Commit

Permalink
don't pass on ...
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr committed Nov 12, 2017
1 parent 69ed140 commit 5cb62d2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 26 deletions.
24 changes: 1 addition & 23 deletions R/new.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,15 @@
#' Creates a subclass of a tibble.
#'
#' @param x A tibble-like object
#' @param ... Passed on to [structure()]
#' @param subclass Subclasses to assign to the new object, default: none
#' @export
new_tibble <- function(x, ..., subclass = NULL) {
new_tibble <- function(x, subclass = NULL) {
stopifnot(is.list(x))

x <- update_tibble_attrs(x, ...)
x <- set_tibble_class(x, subclass = subclass)
x
}

update_tibble_attrs <- function(x, ...) {
# Can't use structure() here because it breaks the row.names attribute
attribs <- list(...)

# reduce2() is not in the purrr compat layer
nested_attribs <- map2(names(attribs), attribs, function(name, value) set_names(list(value), name))
x <- reduce(
.init = x,
nested_attribs,
function(x, attr) {
if (!is.null(attr[[1]])) {
attr(x, names(attr)) <- attr[[1]]
}
x
}
)

x
}

set_tibble_class <- function(x, subclass = NULL) {
class(x) <- c(subclass, "tbl_df", "tbl", "data.frame")
x
Expand Down
4 changes: 1 addition & 3 deletions man/new_tibble.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5cb62d2

Please sign in to comment.