Just define a function with the same name, and it will overwrite the base function.
summary <- function(x) {
x
}
Just type the name of the function in the console without parentheses, in the case of summary()
this is a little more complex since it applies a different method depending on the class of object that is being passed to it, but for example, this is what you get for the data.frame method.
summary.data.frame
#> function (object, maxsum = 7L, digits = max(3L, getOption("digits") -
#> 3L), ...)
#> {
#> ncw <- function(x) {
#> z <- nchar(x, type = "w")
#> if (any(na <- is.na(z))) {
#> z[na] <- nchar(encodeString(z[na]), "b")
#> }
#> z
#> }
#> z <- lapply(X = as.list(object), FUN = summary, maxsum = maxsum,
#> digits = 12L, ...)
#> nv <- length(object)
#> nm <- names(object)
#> lw <- numeric(nv)
#> nr <- if (nv)
#> max(vapply(z, function(x) NROW(x) + !is.null(attr(x,
#> "NAs")), integer(1)))
#> else 0
#> for (i in seq_len(nv)) {
#> sms <- z[[i]]
#> if (is.matrix(sms)) {
#> cn <- paste(nm[i], gsub("^ +", "", colnames(sms),
#> useBytes = TRUE), sep = ".")
#> tmp <- format(sms)
#> if (nrow(sms) < nr)
#> tmp <- rbind(tmp, matrix("", nr - nrow(sms),
#> ncol(sms)))
#> sms <- apply(tmp, 1L, function(x) paste(x, collapse = " "))
#> wid <- sapply(tmp[1L, ], nchar, type = "w")
#> blanks <- paste(character(max(wid)), collapse = " ")
#> wcn <- ncw(cn)
#> pad0 <- floor((wid - wcn)/2)
#> pad1 <- wid - wcn - pad0
#> cn <- paste0(substring(blanks, 1L, pad0), cn, substring(blanks,
#> 1L, pad1))
#> nm[i] <- paste(cn, collapse = " ")
#> }
#> else {
#> sms <- format(sms, digits = digits)
#> lbs <- format(names(sms))
#> sms <- paste0(lbs, ":", sms, " ")
#> lw[i] <- ncw(lbs[1L])
#> length(sms) <- nr
#> }
#> z[[i]] <- sms
#> }
#> if (nv) {
#> z <- unlist(z, use.names = TRUE)
#> dim(z) <- c(nr, nv)
#> if (anyNA(lw))
#> warning("probably wrong encoding in names(.) of column ",
#> paste(which(is.na(lw)), collapse = ", "))
#> blanks <- paste(character(max(lw, na.rm = TRUE) + 2L),
#> collapse = " ")
#> pad <- floor(lw - ncw(nm)/2)
#> nm <- paste0(substring(blanks, 1, pad), nm)
#> dimnames(z) <- list(rep.int("", nr), nm)
#> }
#> else {
#> z <- character()
#> dim(z) <- c(nr, nv)
#> }
#> attr(z, "class") <- c("table")
#> z
#> }
#> <bytecode: 0x5644827429c8>
#> <environment: namespace:base>