From 09751d316dc8d4d64162d4fa3553c88875f51fdb Mon Sep 17 00:00:00 2001 From: Steve Martin Date: Mon, 18 Mar 2024 16:19:42 -0400 Subject: [PATCH] Fixed broken example with mean splice --- DESCRIPTION | 2 +- R/geks.R | 2 +- man/geks.Rd | 2 +- tests/Examples/gpindex-Ex.Rout.save | 7 ++----- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 9854303..78cf5a5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: gpindex Title: Generalized Price and Quantity Indexes -Version: 0.6.0.9011 +Version: 0.6.0.9012 Authors@R: c( person("Steve", "Martin", role = c("aut", "cre", "cph"), email = "marberts@protonmail.com", diff --git a/R/geks.R b/R/geks.R index edeaed8..a48fe46 100644 --- a/R/geks.R +++ b/R/geks.R @@ -130,7 +130,7 @@ geks_matrix <- function(index, p, q, product, n, nper, window, na.rm) { #' offset <- length(init) #' x <- lapply(x, \(z) rev(cumprod(rev(z)))) #' res <- numeric(offset + length(x)) -#' res[seq_len(init)] <- init +#' res[seq_along(init)] <- init #' for (i in seq_along(x)) { #' res[i + offset] <- geometric_mean( #' x[[i]] * res[seq(to = i + offset - 1, length.out = length(x[[i]]))] diff --git a/man/geks.Rd b/man/geks.Rd index aa70aa7..14c607a 100644 --- a/man/geks.Rd +++ b/man/geks.Rd @@ -118,7 +118,7 @@ mean_splice <- function(x, init) { offset <- length(init) x <- lapply(x, \(z) rev(cumprod(rev(z)))) res <- numeric(offset + length(x)) - res[seq_len(init)] <- init + res[seq_along(init)] <- init for (i in seq_along(x)) { res[i + offset] <- geometric_mean( x[[i]] * res[seq(to = i + offset - 1, length.out = length(x[[i]]))] diff --git a/tests/Examples/gpindex-Ex.Rout.save b/tests/Examples/gpindex-Ex.Rout.save index 0039acc..fa8c143 100644 --- a/tests/Examples/gpindex-Ex.Rout.save +++ b/tests/Examples/gpindex-Ex.Rout.save @@ -507,7 +507,7 @@ Warning in back_period(period) : + offset <- length(init) + x <- lapply(x, \(z) rev(cumprod(rev(z)))) + res <- numeric(offset + length(x)) -+ res[seq_len(init)] <- init ++ res[seq_along(init)] <- init + for (i in seq_along(x)) { + res[i + offset] <- geometric_mean( + x[[i]] * res[seq(to = i + offset - 1, length.out = length(x[[i]]))] @@ -517,10 +517,7 @@ Warning in back_period(period) : + } > > mean_splice(tg[-1], cumprod(tg[[1]])) -Warning in seq_len(init) : first element used of 'length.out' argument -Warning in res[seq_len(init)] <- init : - number of items to replace is not a multiple of replacement length -[1] 1.391443 0.000000 0.000000 0.000000 +[1] 1.391443 1.801142 2.228836 2.688842 > > #---- Missing data ---- >