Skip to content
Open

Dev #13

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
man-roxygen
\.git
^\.github$
^\.travis\.yml$
\.DS_Store
..Rcheck
^src/.*\.(o|so)$
LICENSE\.md
NEWS\.md
^_ignore$
\.sublime\-
sftp-config.json
Expand All @@ -13,3 +14,4 @@ sftp-config.json
.tar.gz
\.Rapp\.history
cran-comments.md
^CRAN-SUBMISSION$
50 changes: 50 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: R-CMD-check

on:
push:
branches:
- main
- master
- dev
pull_request:
branches:
- main
- master
workflow_dispatch:

jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}
name: ${{ matrix.config.os }} (R ${{ matrix.config.r }})

strategy:
fail-fast: false
matrix:
config:
- os: ubuntu-latest
r: release
- os: ubuntu-latest
r: devel
- os: windows-latest
r: release

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
needs: check

- uses: r-lib/actions/check-r-package@v2
with:
args: 'c("--no-manual", "--as-cran")'
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@ _ignore

# Example code in package build process
*-Ex.R

# Local compiled artifacts
src/*.o
src/*.so
src/symbols.rds
src/.DS_Store
10 changes: 5 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
Package: stlplus
Type: Package
Title: Enhanced Seasonal Decomposition of Time Series by Loess
Version: 0.5.1
Date: 2016-01-05
Authors@R: person("Ryan", "Hafen", email = "rhafen@gmail.com", role = c("aut", "cre"))
Version: 0.5.2
Date: 2026-04-06
Authors@R: person("Ryan", "Hafen", email = "rhafen@gmail.com", role = c("aut", "cre"),
comment = c(ORCID = "0000-0002-5516-8367"))
Maintainer: Ryan Hafen <rhafen@gmail.com>
Description: Decompose a time series into seasonal, trend, and remainder
components using an implementation of Seasonal Decomposition of Time
Expand All @@ -13,7 +14,6 @@ Description: Decompose a time series into seasonal, trend, and remainder
parameter choices, frequency component smoothing beyond the seasonal and
trend components, and some basic plot methods for diagnostics.
LazyLoad: yes
LazyData: yes
NeedsCompilation: yes
Imports:
lattice,
Expand All @@ -28,4 +28,4 @@ URL: https://github.com/hafen/stlplus
BugReports: https://github.com/hafen/stlplus/issues
Note: This is experimental software distributed free of charge and
comes with no warranty! Exercise professional caution.
RoxygenNote: 5.0.1
RoxygenNote: 7.3.3
4 changes: 2 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export(remainder)
export(seasonal)
export(stlplus)
export(trend)
importFrom(Rcpp,sourceCpp)
importFrom(Rcpp,evalCpp)
importFrom(lattice,panel.abline)
importFrom(lattice,panel.loess)
importFrom(lattice,panel.segments)
Expand All @@ -43,4 +43,4 @@ importFrom(utils,head)
importFrom(utils,stack)
importFrom(utils,tail)
importFrom(yaImpute,ann)
useDynLib(stlplus)
useDynLib(stlplus, .registration = TRUE)
10 changes: 10 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
Version 0.5.2
----------------------------------------------------------------------

- Fixed Rcpp namespace import so Rcpp symbols are properly loaded at runtime
- Updated testthat comparisons against `stats::stl()` to use explicit matched settings and platform-robust tolerances
- Added periodic-mode regression test coverage
- Corrected centering in `plot_seasonal()` so cycle-subseries are centered by the seasonal component mean
- Enabled explicit native routine registration (`useDynLib` with `.registration = TRUE`)
- Removed stale `LazyData` field from DESCRIPTION

Version 0.5
----------------------------------------------------------------------

Expand Down
6 changes: 3 additions & 3 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

c_interp <- function(m, fits, slopes, at) {
.Call('_stlplus_c_interp', PACKAGE = 'stlplus', m, fits, slopes, at)
.Call(`_stlplus_c_interp`, m, fits, slopes, at)
}

c_loess <- function(xx, yy, degree, span, ww, m, l_idx, max_dist) {
.Call('_stlplus_c_loess', PACKAGE = 'stlplus', xx, yy, degree, span, ww, m, l_idx, max_dist)
.Call(`_stlplus_c_loess`, xx, yy, degree, span, ww, m, l_idx, max_dist)
}

c_ma <- function(x, n_p) {
.Call('_stlplus_c_ma', PACKAGE = 'stlplus', x, n_p)
.Call(`_stlplus_c_ma`, x, n_p)
}

29 changes: 16 additions & 13 deletions R/accessors.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ getraw <- function(object) {
#' @export
#' @rdname accessors
remainder.stlplus <- function(object) {
if(object$pars$fc.number == 0) {
if (object$pars$fc.number == 0) {
object$data$remainder
} else {
object$fc$remainder
Expand All @@ -48,20 +48,20 @@ remainder.stlplus <- function(object) {
#' @export
#' @rdname accessors
fitted.stlplus <- function(object, ...) {
if(object$pars$fc.number == 0) {
if (object$pars$fc.number == 0) {
object$data$seasonal + object$data$trend
} else {
object$data$seasonal + apply(object$fc[,1:object$pars$fc.number], 1, sum)
object$data$seasonal + apply(object$fc[, 1:object$pars$fc.number], 1, sum)
}
}

#' @export
#' @rdname accessors
predict.stlplus <- function(object, ...) {
if(object$pars$fc.number == 0) {
if (object$pars$fc.number == 0) {
object$data$seasonal + object$data$trend
} else {
object$data$seasonal + apply(object$fc[,1:object$pars$fc.number], 1, sum)
object$data$seasonal + apply(object$fc[, 1:object$pars$fc.number], 1, sum)
}
}

Expand All @@ -81,23 +81,26 @@ trend.stlplus <- function(object) {
#' @export
#' @rdname accessors
fc <- function(object, fcnum = 1) {
if(! "stlplus" %in% class(object))
if (!"stlplus" %in% class(object)) {
stop("object not of class stlplus")
}

if(is.null(object$fc))
if (is.null(object$fc)) {
stop("there are no post-trend frequency components")
}

if(fcnum > ncol(object$fc))
if (fcnum > ncol(object$fc)) {
stop("there are not that many frequency components")
}

object$fc[,fcnum]
object$fc[, fcnum]
}

# setGeneric("time")
#' @export
#' @rdname accessors
time.stlplus <- function(x, ...) {
if(length(x$t) == x$n) {
if (length(x$t) == x$n) {
x$t
} else {
c(1:x$n)
Expand All @@ -109,19 +112,19 @@ time.stlplus <- function(x, ...) {
#' @export
#' @rdname accessors
remainder.stl <- function(object) {
as.numeric(object$time.series[,3])
as.numeric(object$time.series[, 3])
}

#' @export
#' @rdname accessors
seasonal.stl <- function(object) {
as.numeric(object$time.series[,1])
as.numeric(object$time.series[, 1])
}

#' @export
#' @rdname accessors
trend.stl <- function(object) {
as.numeric(object$time.series[,2])
as.numeric(object$time.series[, 2])
}

# setGeneric("time")
Expand Down
2 changes: 1 addition & 1 deletion R/cpp_wrappers.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.interp <- function(m, fits, slopes, at) {
if(any(is.nan(fits))) {
if (any(is.nan(fits))) {
ind <- !is.nan(fits)
c_interp(m[ind], fits[ind], slopes[ind], at)
} else {
Expand Down
Loading
Loading