Skip to content

Commit

Permalink
summary(<stl>) gets smaller default digits in line with default sum…
Browse files Browse the repository at this point in the history
…mary() printing

git-svn-id: https://svn.r-project.org/R/trunk@87627 00db46b3-68df-0310-9c12-caf00c1e9a41
  • Loading branch information
maechler committed Jan 24, 2025
1 parent 12e3558 commit 9ecf648
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 25 deletions.
4 changes: 4 additions & 0 deletions doc/NEWS.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,10 @@
\item \code{pwilcox()} and \code{qwilcox()} now check for user
interrupt less frequently.
\item \code{summary(<stl>)} (which prints directly) finally gets the
same \code{digits} default as the formatting printing of default
\code{summary()} method results, and it is documented explicitly.
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/library/stats/R/stl.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# File src/library/stats/R/stl.R
# Part of the R package, https://www.R-project.org
#
# Copyright (C) 1995-2014 The R Core Team
# Copyright (C) 1995-2025 The R Core Team
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -103,7 +103,7 @@ print.stl <- function(x, ...)
invisible(x)
}

summary.stl <- function(object, digits = getOption("digits"), ...)
summary.stl <- function(object, digits = max(3L, getOption("digits") - 3L), ...)
{
cat(" Call:\n ")
dput(object$call, control=NULL)
Expand All @@ -113,14 +113,14 @@ summary.stl <- function(object, digits = getOption("digits"), ...)
iqr <- apply(cbind(STL = object$time.series,
data = object$time.series %*% rep(1,3)),
2L, IQR)
print(rbind(format(iqr, digits = max(2L, digits - 3L)),
" %"= format(round(100 * iqr / iqr["data"], 1))),
print(rbind(format(iqr, digits = max(2L, digits)),
" %" = format(round(100 * iqr / iqr["data"], 1))),
quote = FALSE)
cat("\n Weights:")
if(all(object$weights == 1)) cat(" all == 1\n")
else { cat("\n"); print(summary(object$weights, digits = digits, ...)) }
cat("\n Other components: ")
str(object[-(1L:3)], give.attr = FALSE)
str(object[-seq_len(3L)], give.attr = FALSE)
invisible(object)
}

Expand Down
16 changes: 11 additions & 5 deletions src/library/stats/man/stlmethods.Rd
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
% File src/library/stats/man/stlmethods.Rd
% Part of the R package, https://www.R-project.org
% Copyright 1995-2007 R Core Team
% Copyright 1995-2025 R Core Team
% Distributed under GPL 2 or later

\name{stlmethods}
Expand All @@ -19,20 +19,26 @@
tck = -0.01, mfrow = c(nplot, 1)),
main = NULL, range.bars = TRUE, \dots,
col.range = "light gray")

\method{summary}{stl}(object, digits = max(3L, getOption("digits") - 3L), \dots)
}
\arguments{
\item{x}{\code{\link{stl}} object.}
\item{x, object}{\code{\link{stl}} object.}
\item{labels}{character of length 4 giving the names of the component
time-series.}
\item{set.pars}{settings for \code{\link{par}(.)} when setting up the plot.}
\item{main}{plot main title.}
\item{range.bars}{logical indicating if each plot should have a bar at
its right side which are of equal heights in user coordinates.}
\item{\dots}{further arguments passed to or from other methods.}
\item{col.range}{colour to be used for the range bars, if plotted.
Note this appears after \code{\dots} and so cannot be abbreviated.}
\item{\dots}{further arguments passed to or from other methods; for
\code{summary()}, e.g., \code{zdigits} passed to the default method.}% format.summaryDefault
\item{digits}{passed to the default \code{\link{summary}} method (for
\code{time.series} and \code{weights} components).}
}
\seealso{
\code{\link{plot.ts}} and \code{\link{stl}}, particularly for
examples.}
\code{\link{plot.ts}} and \code{\link{stl}}, particularly for examples;
\code{\link{summary.default}}.
}
\keyword{ts}
30 changes: 15 additions & 15 deletions tests/Examples/stats-Ex.Rout.save
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

R Under development (unstable) (2025-01-22 r87618) -- "Unsuffered Consequences"
R Under development (unstable) (2025-01-24 r87624) -- "Unsuffered Consequences"
Copyright (C) 2025 The R Foundation for Statistical Computing
Platform: aarch64-apple-darwin24.2.0

Expand Down Expand Up @@ -17126,13 +17126,13 @@ f.f1c 1.0 1.00 1 2.00 2.0 2.00 2 4.00 4.0 4.00 4 3.00 3.0
stl(x = log(co2), s.window = 21)

Time.series components:
seasonal trend remainder
Min. :-0.009939103 Min. :5.753541 Min. :-0.0022554051
1st Qu.:-0.004536535 1st Qu.:5.778556 1st Qu.:-0.0004586796
Median : 0.000877761 Median :5.815125 Median :-0.0000088674
Mean :-0.000001304 Mean :5.819267 Mean :-0.0000019655
3rd Qu.: 0.004997747 3rd Qu.:5.859806 3rd Qu.: 0.0004023465
Max. : 0.009114691 Max. :5.898750 Max. : 0.0019396260
seasonal trend remainder
Min. :-9.939e-03 Min. :5.754 Min. :-2.255e-03
1st Qu.:-4.537e-03 1st Qu.:5.779 1st Qu.:-4.587e-04
Median : 8.778e-04 Median :5.815 Median :-8.867e-06
Mean :-1.304e-06 Mean :5.819 Mean :-1.966e-06
3rd Qu.: 4.998e-03 3rd Qu.:5.860 3rd Qu.: 4.023e-04
Max. : 9.115e-03 Max. :5.899 Max. : 1.940e-03
IQR:
STL.seasonal STL.trend STL.remainder data
0.009534 0.081250 0.000861 0.079370
Expand All @@ -17156,13 +17156,13 @@ f.f1c 1.0 1.00 1 2.00 2.0 2.00 2 4.00 4.0 4.00 4 3.00 3.0
stl(x = mdeaths, s.window = "per", robust = TRUE)

Time.series components:
seasonal trend remainder
Min. :-446.8302 Min. :1318.650 Min. :-314.5835
1st Qu.:-301.5726 1st Qu.:1432.208 1st Qu.: -32.5392
Median : -79.0561 Median :1448.891 Median : 5.7943
Mean : 0.0000 Mean :1472.880 Mean : 23.0646
3rd Qu.: 304.5673 3rd Qu.:1548.974 3rd Qu.: 47.5134
Max. : 544.7904 Max. :1615.535 Max. : 872.1992
seasonal trend remainder
Min. :-446.83 Min. :1319 Min. :-314.584
1st Qu.:-301.57 1st Qu.:1432 1st Qu.: -32.539
Median : -79.06 Median :1449 Median : 5.794
Mean : 0.00 Mean :1473 Mean : 23.065
3rd Qu.: 304.57 3rd Qu.:1549 3rd Qu.: 47.513
Max. : 544.79 Max. :1616 Max. : 872.199
IQR:
STL.seasonal STL.trend STL.remainder data
606.14 116.77 80.05 707.75
Expand Down

0 comments on commit 9ecf648

Please sign in to comment.