Open christophsax opened 7 years ago
We have now as.data.frame()
for output of seas
and seas.summary
. Would make it also easy to complete the broom
methods, e.g.:
library(broom)
library(seasonal)
tidy.seas <- function (x, ...) {
as.data.frame(summary(x, ...))
}
augment.seas <- function(x) {
as.data.frame(x)
}
glance.seas <- function(x, ...){
sx <- summary(x, ...)
z <- list()
z$adjustment <- if (!is.null(sx$spc$seats)) {
("SEATS")
} else if (!is.null(sx$spc$x11)) {
("X11")
} else {
("none")
}
z$arima <- sx$model$arima$model
z$nobs <- sx$nobs
z$transform <- sx$transform.function
z$AICc <- sx$aicc
z$BIC <- sx$bic
z$qs <- unname(sx$qsv['qs'])
z$qs.p.value <- unname(sx$qsv['p-val'])
if (!is.null(sx$resid)) {
bltest <- Box.test(sx$resid, lag = 24, type = "Ljung")
z$box_ljung <- unname(bltest$statistic)
swtest <- shapiro.test(sx$resid)
z$shapiro <- unname(swtest$statistic)
}
as.data.frame(z)
}
m <- seas(AirPassengers)
tidy(m)
augment(m)
glance(m)
Broom ticket was closed, but it may still be good idea.
Picking up a thread from the broom package.
I can perfectly see why you want the output of a
summary
to be adata.frame
, rather than a complex R object. Because of that I added an experimentaldata.frame
argument tosummary.seas
andudg
in seasonal 1.4, which is now on CRAN.But I think it would be probably nicer to implement an
as.data.frame
method, so we could write:Are other packages doing that?
This seems to me so much simpler than using a huge specialised package to do just that?