Skip to content

Commit

Permalink
Add summary() method for difftime objects (Rd \alias already committe…
Browse files Browse the repository at this point in the history
…d in c87594).

git-svn-id: https://svn.r-project.org/R/trunk@87599 00db46b3-68df-0310-9c12-caf00c1e9a41
  • Loading branch information
hornik committed Jan 19, 2025
1 parent 365f032 commit d05f01d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/library/base/R/datetime.R
Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,19 @@ function(..., recursive = FALSE)
function(x, value)
.difftime(NextMethod(), attr(x, "units"), oldClass(x))

## Added in R 4.5.0.
summary.difftime <-
function(object, digits = getOption("digits"), ...)
{
x <- summary.default(unclass(object), digits = digits, ...)
if(m <- match("NA's", names(x), 0L)) {
NAs <- as.integer(x[m])
x <- x[-m]
attr(x, "NAs") <- NAs
}
.difftime(x, attr(object, "units"), oldClass(object))
}

## ----- convenience functions -----

seq.POSIXt <-
Expand Down
1 change: 1 addition & 0 deletions src/library/base/R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,7 @@ matrix(c("!", "hexmode",
"summary", "connection",
"summary", "data.frame",
"summary", "default",
"summary", "difftime",
"summary", "factor",
"summary", "matrix",
"summary", "proc_time",
Expand Down

0 comments on commit d05f01d

Please sign in to comment.