R Under development (unstable) (2022-05-02 r82297) -- "Unsuffered Consequences" Copyright (C) 2022 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > pkgname <- "fts" > source(file.path(R.home("share"), "R", "examples-header.R")) > options(warn = 1) > library('fts') Loading required package: zoo Attaching package: ‘zoo’ The following objects are masked from ‘package:base’: as.Date, as.Date.numeric > > base::assign(".oldSearch", base::search(), pos = 'CheckExEnv') > base::assign(".old_wd", base::getwd(), pos = 'CheckExEnv') > cleanEx() > nameEx("any.all.fts") > ### * any.all.fts > > flush(stderr()); flush(stdout()) > > ### Name: fts.logical > ### Title: Logical subsets of objects > ### Aliases: fts.logical col.any col.all row.any row.all > ### Keywords: ts > > ### ** Examples > > x <- fts(seq(from=Sys.Date(),by="months",length.out=50),matrix(rnorm(100),nrow=50)) > jj <- x > 0 > row.all(jj) 2022-05-03 2022-06-03 2022-07-03 2022-08-03 2022-09-03 2022-10-03 2022-11-03 FALSE FALSE FALSE FALSE TRUE FALSE FALSE 2022-12-03 2023-01-03 2023-02-03 2023-03-03 2023-04-03 2023-05-03 2023-06-03 FALSE TRUE FALSE TRUE FALSE FALSE FALSE 2023-07-03 2023-08-03 2023-09-03 2023-10-03 2023-11-03 2023-12-03 2024-01-03 FALSE FALSE FALSE TRUE TRUE TRUE TRUE 2024-02-03 2024-03-03 2024-04-03 2024-05-03 2024-06-03 2024-07-03 2024-08-03 FALSE TRUE FALSE FALSE FALSE FALSE FALSE 2024-09-03 2024-10-03 2024-11-03 2024-12-03 2025-01-03 2025-02-03 2025-03-03 FALSE FALSE FALSE FALSE TRUE FALSE FALSE 2025-04-03 2025-05-03 2025-06-03 2025-07-03 2025-08-03 2025-09-03 2025-10-03 FALSE FALSE FALSE TRUE TRUE FALSE FALSE 2025-11-03 2025-12-03 2026-01-03 2026-02-03 2026-03-03 2026-04-03 2026-05-03 TRUE TRUE FALSE FALSE FALSE FALSE FALSE 2026-06-03 FALSE > row.any(jj) 2022-05-03 2022-06-03 2022-07-03 2022-08-03 2022-09-03 2022-10-03 2022-11-03 TRUE TRUE TRUE TRUE TRUE TRUE TRUE 2022-12-03 2023-01-03 2023-02-03 2023-03-03 2023-04-03 2023-05-03 2023-06-03 TRUE TRUE FALSE TRUE TRUE TRUE TRUE 2023-07-03 2023-08-03 2023-09-03 2023-10-03 2023-11-03 2023-12-03 2024-01-03 TRUE TRUE FALSE TRUE TRUE TRUE TRUE 2024-02-03 2024-03-03 2024-04-03 2024-05-03 2024-06-03 2024-07-03 2024-08-03 TRUE TRUE FALSE TRUE TRUE FALSE TRUE 2024-09-03 2024-10-03 2024-11-03 2024-12-03 2025-01-03 2025-02-03 2025-03-03 TRUE TRUE TRUE FALSE TRUE FALSE TRUE 2025-04-03 2025-05-03 2025-06-03 2025-07-03 2025-08-03 2025-09-03 2025-10-03 TRUE TRUE FALSE TRUE TRUE FALSE TRUE 2025-11-03 2025-12-03 2026-01-03 2026-02-03 2026-03-03 2026-04-03 2026-05-03 TRUE TRUE TRUE TRUE TRUE TRUE FALSE 2026-06-03 TRUE > > col.any(x > 0) [1] TRUE TRUE > col.all(x > -3) [1] TRUE TRUE > > > > cleanEx() > nameEx("apply") > ### * apply > > flush(stderr()); flush(stdout()) > > ### Name: apply > ### Title: Apply Function > ### Aliases: apply row.apply column.apply > ### Keywords: ts > > ### ** Examples > > x <- fts(index=seq(from=Sys.Date(),by="months",length.out=24),data=1:24) > y <- fts(index=seq(from=Sys.Date(),by="months",length.out=24),data=1:24) > > z <- cbind(x,y) > > ## returns vector > z.col.sum <- column.apply(z,sum) > > ## returns fts > z.row.sum <- row.apply(z,sum) > > > > > cleanEx() > nameEx("as.fts") > ### * as.fts > > flush(stderr()); flush(stdout()) > > ### Name: as.fts > ### Title: Convert from/to fts > ### Aliases: as.fts as.fts.default as.fts.data.frame as.fts.matrix > ### as.fts.zoo as.data.frame.fts as.matrix.fts > ### Keywords: ts > > ### ** Examples > > N <- 100 > xm <- matrix(rnorm(N)) > dts <- format(seq(from=Sys.Date(),length.out=N,by="days"),"%Y-%m-%d") > rownames(xm) <- dts > x.from.m <- as.fts(xm) > x.from.df <- as.fts(data.frame(asofdate=dts,my.data=xm)) > > > > cleanEx() > nameEx("event.dates") > ### * event.dates > > flush(stderr()); flush(stdout()) > > ### Name: event.dates > ### Title: Extract Dates > ### Aliases: event.dates > ### Keywords: ts > > ### ** Examples > > x <- fts(index=seq(from=Sys.Date(),by="days",length.out=100),data=rnorm(100)) > x.bool <- x > 10 > event.dates(x.bool) Date of length 0 > > ## ignores NA's > x.bool[10:20] <- NA > event.dates(x.bool) Date of length 0 > > > > > cleanEx() > nameEx("expanding") > ### * expanding > > flush(stderr()); flush(stdout()) > > ### Name: expanding > ### Title: Expanding Window Functions > ### Aliases: expanding expanding.mean expanding.sum expanding.product > ### expanding.max expanding.min expanding.sd expanding.rank expanding.cor > ### expanding.cov > ### Keywords: ts > > ### ** Examples > > x <- fts(index=seq(from=Sys.Date(),by="days",length.out=100),data=rnorm(100)) > > x.emax <- expanding.max(x) > x.emin <- expanding.min(x) > > > > cleanEx() > nameEx("fill") > ### * fill > > flush(stderr()); flush(stdout()) > > ### Name: fill > ### Title: Fill Missing Values > ### Aliases: fill fill.fwd fill.bwd fill.value > ### Keywords: ts > > ### ** Examples > > x <- fts(index=seq(from=Sys.Date(),by="days",length.out=50),rnorm(50)) > x[x > 0,] <- NA > fill.fwd(x) [,1] 2022-05-03 -0.62645381 2022-05-04 -0.62645381 2022-05-05 -0.83562861 2022-05-06 -0.83562861 2022-05-07 -0.83562861 2022-05-08 -0.82046838 2022-05-09 -0.82046838 2022-05-10 -0.82046838 2022-05-11 -0.82046838 2022-05-12 -0.30538839 2022-05-13 -0.30538839 2022-05-14 -0.30538839 2022-05-15 -0.62124058 2022-05-16 -2.21469989 2022-05-17 -2.21469989 2022-05-18 -0.04493361 2022-05-19 -0.01619026 2022-05-20 -0.01619026 2022-05-21 -0.01619026 2022-05-22 -0.01619026 2022-05-23 -0.01619026 2022-05-24 -0.01619026 2022-05-25 -0.01619026 2022-05-26 -1.98935170 2022-05-27 -1.98935170 2022-05-28 -0.05612874 2022-05-29 -0.15579551 2022-05-30 -1.47075238 2022-05-31 -0.47815006 2022-06-01 -0.47815006 2022-06-02 -0.47815006 2022-06-03 -0.10278773 2022-06-04 -0.10278773 2022-06-05 -0.05380504 2022-06-06 -1.37705956 2022-06-07 -0.41499456 2022-06-08 -0.39428995 2022-06-09 -0.05931340 2022-06-10 -0.05931340 2022-06-11 -0.05931340 2022-06-12 -0.16452360 2022-06-13 -0.25336168 2022-06-14 -0.25336168 2022-06-15 -0.25336168 2022-06-16 -0.68875569 2022-06-17 -0.70749516 2022-06-18 -0.70749516 2022-06-19 -0.70749516 2022-06-20 -0.11234621 2022-06-21 -0.11234621 > > x <- fts(index=seq(from=Sys.Date(),by="days",length.out=50),rnorm(50)) > x[x > 0,] <- NA > fill.bwd(x) [,1] 2022-05-03 -0.6120264 2022-05-04 -0.6120264 2022-05-05 -1.1293631 2022-05-06 -1.1293631 2022-05-07 -0.3672215 2022-05-08 -0.3672215 2022-05-09 -0.3672215 2022-05-10 -1.0441346 2022-05-11 -0.1350546 2022-05-12 -0.1350546 2022-05-13 -0.0392400 2022-05-14 -0.0392400 2022-05-15 -0.7432732 2022-05-16 -0.7432732 2022-05-17 -0.7432732 2022-05-18 -1.8049586 2022-05-19 -1.8049586 2022-05-20 -0.7099464 2022-05-21 -0.7099464 2022-05-22 -0.7099464 2022-05-23 -0.7099464 2022-05-24 -0.7099464 2022-05-25 -0.9340976 2022-05-26 -0.9340976 2022-05-27 -1.2536334 2022-05-28 -0.4432919 2022-05-29 -0.4432919 2022-05-30 -0.5895209 2022-05-31 -0.5895209 2022-06-01 -0.5895209 2022-06-02 -0.5686687 2022-06-03 -0.1351786 2022-06-04 -1.5235668 2022-06-05 -1.5235668 2022-06-06 -0.3041839 2022-06-07 -0.3041839 2022-06-08 -0.3041839 2022-06-09 -0.3041839 2022-06-10 -0.5425200 2022-06-11 -0.5425200 2022-06-12 -0.5425200 2022-06-13 -1.2765922 2022-06-14 -1.2765922 2022-06-15 -1.2765922 2022-06-16 -1.2765922 2022-06-17 -1.2765922 2022-06-18 -1.2765922 2022-06-19 -0.5732654 2022-06-20 -1.2246126 2022-06-21 -0.4734006 > > x <- fts(index=seq(from=Sys.Date(),by="days",length.out=50),rnorm(50)) > x[x > 0,] <- NA > fill.value(x,100.0) [,1] 2022-05-03 -0.62036668 2022-05-04 100.00000000 2022-05-05 -0.91092165 2022-05-06 100.00000000 2022-05-07 -0.65458464 2022-05-08 100.00000000 2022-05-09 100.00000000 2022-05-10 100.00000000 2022-05-11 100.00000000 2022-05-12 100.00000000 2022-05-13 -0.63573645 2022-05-14 -0.46164473 2022-05-15 100.00000000 2022-05-16 -0.65069635 2022-05-17 -0.20738074 2022-05-18 -0.39280793 2022-05-19 -0.31999287 2022-05-20 -0.27911330 2022-05-21 100.00000000 2022-05-22 -0.17733048 2022-05-23 -0.50595746 2022-05-24 100.00000000 2022-05-25 -0.21457941 2022-05-26 -0.17955653 2022-05-27 -0.10019074 2022-05-28 100.00000000 2022-05-29 -0.07356440 2022-05-30 -0.03763417 2022-05-31 -0.68166048 2022-06-01 -0.32427027 2022-06-02 100.00000000 2022-06-03 -0.58889449 2022-06-04 100.00000000 2022-06-05 -1.51839408 2022-06-06 100.00000000 2022-06-07 -1.53644982 2022-06-08 -0.30097613 2022-06-09 -0.52827990 2022-06-10 -0.65209478 2022-06-11 -0.05689678 2022-06-12 -1.91435943 2022-06-13 100.00000000 2022-06-14 -1.66497244 2022-06-15 -0.46353040 2022-06-16 -1.11592011 2022-06-17 -0.75081900 2022-06-18 100.00000000 2022-06-19 100.00000000 2022-06-20 -1.28630053 2022-06-21 -1.64060553 > > > > cleanEx() > nameEx("frequency.convert") > ### * frequency.convert > > flush(stderr()); flush(stdout()) > > ### Name: frequency.convert > ### Title: Change Frequencies > ### Aliases: frequency.convert to.weekly to.day.of.week to.monthly > ### to.quarterly to.daily to.hourly to.minute to.second to.yearly > ### Keywords: ts > > ### ** Examples > > x <- fts(index=seq(from=Sys.Date(),by="days",length.out=500),data=1:500) > > to.weekly(x) [,1] 2022-05-07 5 2022-05-14 12 2022-05-21 19 2022-05-28 26 2022-06-04 33 2022-06-11 40 2022-06-18 47 2022-06-25 54 2022-07-02 61 2022-07-09 68 2022-07-16 75 2022-07-23 82 2022-07-30 89 2022-08-06 96 2022-08-13 103 2022-08-20 110 2022-08-27 117 2022-09-03 124 2022-09-10 131 2022-09-17 138 2022-09-24 145 2022-10-01 152 2022-10-08 159 2022-10-15 166 2022-10-22 173 2022-10-29 180 2022-11-05 187 2022-11-12 194 2022-11-19 201 2022-11-26 208 2022-12-03 215 2022-12-10 222 2022-12-17 229 2022-12-24 236 2022-12-31 243 2023-01-07 250 2023-01-14 257 2023-01-21 264 2023-01-28 271 2023-02-04 278 2023-02-11 285 2023-02-18 292 2023-02-25 299 2023-03-04 306 2023-03-11 313 2023-03-18 320 2023-03-25 327 2023-04-01 334 2023-04-08 341 2023-04-15 348 2023-04-22 355 2023-04-29 362 2023-05-06 369 2023-05-13 376 2023-05-20 383 2023-05-27 390 2023-06-03 397 2023-06-10 404 2023-06-17 411 2023-06-24 418 2023-07-01 425 2023-07-08 432 2023-07-15 439 2023-07-22 446 2023-07-29 453 2023-08-05 460 2023-08-12 467 2023-08-19 474 2023-08-26 481 2023-09-02 488 2023-09-09 495 2023-09-14 500 > to.monthly(x) [,1] 2022-05-31 29 2022-06-30 59 2022-07-31 90 2022-08-31 121 2022-09-30 151 2022-10-31 182 2022-11-30 212 2022-12-31 243 2023-01-31 274 2023-02-28 302 2023-03-31 333 2023-04-30 363 2023-05-31 394 2023-06-30 424 2023-07-31 455 2023-08-31 486 2023-09-14 500 > to.quarterly(x) [,1] 2022-06-30 59 2022-09-30 151 2022-12-31 243 2023-03-31 333 2023-06-30 424 2023-09-14 500 > > > > cleanEx() > nameEx("fts") > ### * fts > > flush(stderr()); flush(stdout()) > > ### Name: fts > ### Title: Fts: a fast timeseries library > ### Aliases: fts Ops.fts [.fts [<-.fts cbind.fts rbind.fts print.fts > ### plot.fts > ### Keywords: ts > > ### ** Examples > > x <- fts(index=seq(from=Sys.Date(),by="months",length.out=24),data=1:24) > y <- fts(index=seq(from=Sys.Date(),by="months",length.out=12),data=13:24) > xx <- x[1:10,] > > ## intersection of dates is taken for Arith methods > xyp <- x + y > xys <- x - y > xym <- x * y > xyd <- x / y > xyg <- x > y > xyl <- x < y > > cxy <- cbind(x,y) > rxy <- rbind(x,y) > print(x) [,1] 2022-05-03 1 2022-06-03 2 2022-07-03 3 2022-08-03 4 2022-09-03 5 2022-10-03 6 2022-11-03 7 2022-12-03 8 2023-01-03 9 2023-02-03 10 2023-03-03 11 2023-04-03 12 2023-05-03 13 2023-06-03 14 2023-07-03 15 2023-08-03 16 2023-09-03 17 2023-10-03 18 2023-11-03 19 2023-12-03 20 2024-01-03 21 2024-02-03 22 2024-03-03 23 2024-04-03 24 > plot(x) > > > > cleanEx() > nameEx("indicators") > ### * indicators > > flush(stderr()); flush(stdout()) > > ### Name: indicators > ### Title: Trading indicators > ### Aliases: indicators above.ma analog below.ma wday mday diff.fts up down > ### ema gap.continue gap.direction gap.down gap.down.continue > ### gap.down.reverse gap.reverse gap.up gap.up.continue gap.up.reverse > ### higher.high higher.low hl.oc.ratio inside.day inside.day.direction > ### inside.day.down inside.day.up lower.high lower.low ma.crossover > ### ma.crossover.down ma.crossover.up ma.d ma.distance month year > ### monthly.sum new.high new.low outside.day outside.day.direction > ### outside.day.down outside.day.up pct.chg repeated rsi rsi.crossover > ### rsi.crossover.down rsi.crossover.up template.fts trend.day > ### trend.day.down trend.day.up > ### Keywords: ts > > ### ** Examples > > x <- fts(index=seq(from=Sys.Date(),by="months",length.out=5),rnorm(5)) > print(x) [,1] 2022-05-03 -0.6264538 2022-06-03 0.1836433 2022-07-03 -0.8356286 2022-08-03 1.5952808 2022-09-03 0.3295078 > lag(x,1) [,1] 2022-06-03 -0.6264538 2022-07-03 0.1836433 2022-08-03 -0.8356286 2022-09-03 1.5952808 > lead(x,1) [,1] 2022-05-03 0.1836433 2022-06-03 -0.8356286 2022-07-03 1.5952808 2022-08-03 0.3295078 > > > > cleanEx() > nameEx("intersect.all") > ### * intersect.all > > flush(stderr()); flush(stdout()) > > ### Name: intersect.all > ### Title: find date intersection among multiple fts objects > ### Aliases: intersect.all > ### Keywords: ts > > ### ** Examples > > x <- fts(index=seq(from=Sys.Date(),by="days",length.out=100),data=1:100) > y <- fts(index=seq(from=Sys.Date(),by="days",length.out=100),data=1:100) > y <- y[1:nrow(y) %% 2==0,] > intersect.all(x,y) [1] "2022-05-04" "2022-05-06" "2022-05-08" "2022-05-10" "2022-05-12" [6] "2022-05-14" "2022-05-16" "2022-05-18" "2022-05-20" "2022-05-22" [11] "2022-05-24" "2022-05-26" "2022-05-28" "2022-05-30" "2022-06-01" [16] "2022-06-03" "2022-06-05" "2022-06-07" "2022-06-09" "2022-06-11" [21] "2022-06-13" "2022-06-15" "2022-06-17" "2022-06-19" "2022-06-21" [26] "2022-06-23" "2022-06-25" "2022-06-27" "2022-06-29" "2022-07-01" [31] "2022-07-03" "2022-07-05" "2022-07-07" "2022-07-09" "2022-07-11" [36] "2022-07-13" "2022-07-15" "2022-07-17" "2022-07-19" "2022-07-21" [41] "2022-07-23" "2022-07-25" "2022-07-27" "2022-07-29" "2022-07-31" [46] "2022-08-02" "2022-08-04" "2022-08-06" "2022-08-08" "2022-08-10" > > > > cleanEx() > nameEx("lead.lag") > ### * lead.lag > > flush(stderr()); flush(stdout()) > > ### Name: lead.lag > ### Title: Shift an Fts ojbect in time > ### Aliases: lead.lag.fts lead lag.fts lead.fts > ### Keywords: ts > > ### ** Examples > > x <- fts(index=seq(from=Sys.Date(),by="days",length.out=10),data=1:10) > print(x) [,1] 2022-05-03 1 2022-05-04 2 2022-05-05 3 2022-05-06 4 2022-05-07 5 2022-05-08 6 2022-05-09 7 2022-05-10 8 2022-05-11 9 2022-05-12 10 > lag(x,1) [,1] 2022-05-04 1 2022-05-05 2 2022-05-06 3 2022-05-07 4 2022-05-08 5 2022-05-09 6 2022-05-10 7 2022-05-11 8 2022-05-12 9 > lead(x,1) [,1] 2022-05-03 2 2022-05-04 3 2022-05-05 4 2022-05-06 5 2022-05-07 6 2022-05-08 7 2022-05-09 8 2022-05-10 9 2022-05-11 10 > > > > cleanEx() > nameEx("moving") > ### * moving > > flush(stderr()); flush(stdout()) > > ### Name: moving > ### Title: Moving Functions > ### Aliases: moving.functions moving.mean moving.sum moving.product > ### moving.max moving.min moving.sd moving.rank moving.cor moving.cov > ### cor.by.row > ### Keywords: ts > > ### ** Examples > > x <- fts(index=seq(from=Sys.Date(),by="days",length.out=100),data=1:100) > y <- fts(index=seq(from=Sys.Date(),by="days",length.out=100),data=1:100) > > x.mean <- moving.mean(x,20) > x.sum <- moving.sum(x,20) > x.prod <- moving.product(x,20) tslib/tslib/vector.summary/prod.hpp:53:6: runtime error: signed integer overflow: 479001600 * 13 cannot be represented in type 'int' #0 0x7ff6604a7315 in int tslib::Prod::apply(int*, int*) /data/gannet/ripley/R/packages/tests-clang-SAN/fts/src/./tslib/tslib/vector.summary/prod.hpp:53:6 #1 0x7ff6604a7315 in void tslib::windowApply::apply(int*, int*, int*, unsigned long) /data/gannet/ripley/R/packages/tests-clang-SAN/fts/src/./tslib/tslib/utils/window.apply.hpp:36:9 #2 0x7ff6604a6dda in tslib::TSeries const tslib::TSeries::window(unsigned long) const /data/gannet/ripley/R/packages/tests-clang-SAN/fts/src/./tslib/tslib/tseries.hpp:314:7 #3 0x7ff6604a49d0 in SEXPREC* windowFun(SEXPREC*, SEXPREC*) /data/gannet/ripley/R/packages/tests-clang-SAN/fts/src/./helpers/window.template.hpp:28:79 #4 0x7ff6604887b9 in SEXPREC* windowSpecializer(SEXPREC*, SEXPREC*) /data/gannet/ripley/R/packages/tests-clang-SAN/fts/src/./helpers/window.template.hpp #5 0x6e60c6 in R_doDotCall /data/gannet/ripley/R/svn/R-devel/src/main/dotcode.c:604:17 #6 0x732b59 in do_dotcall /data/gannet/ripley/R/svn/R-devel/src/main/dotcode.c:1284:11 #7 0x842775 in bcEval /data/gannet/ripley/R/svn/R-devel/src/main/eval.c:7136:14 #8 0x82d11e in Rf_eval /data/gannet/ripley/R/svn/R-devel/src/main/eval.c:748:8 #9 0x895993 in R_execClosure /data/gannet/ripley/R/svn/R-devel/src/main/eval.c #10 0x89163f in Rf_applyClosure /data/gannet/ripley/R/svn/R-devel/src/main/eval.c:1844:16 #11 0x82db58 in Rf_eval /data/gannet/ripley/R/svn/R-devel/src/main/eval.c:871:12 #12 0x8a1a91 in do_set /data/gannet/ripley/R/svn/R-devel/src/main/eval.c:2991:8 #13 0x82d508 in Rf_eval /data/gannet/ripley/R/svn/R-devel/src/main/eval.c:823:12 #14 0x95c796 in Rf_ReplIteration /data/gannet/ripley/R/svn/R-devel/src/main/main.c:264:2 #15 0x95fcf0 in R_ReplConsole /data/gannet/ripley/R/svn/R-devel/src/main/main.c:316:11 #16 0x95faf9 in run_Rmainloop /data/gannet/ripley/R/svn/R-devel/src/main/main.c:1139:5 #17 0x95fe32 in Rf_mainloop /data/gannet/ripley/R/svn/R-devel/src/main/main.c:1146:5 #18 0x4f30ba in main /data/gannet/ripley/R/svn/R-devel/src/main/Rmain.c:29:5 #19 0x7ff66fdd1b74 in __libc_start_main (/lib64/libc.so.6+0x27b74) (BuildId: 08df60634339b221bb854d4e10b7278cafde70c4) #20 0x43231d in _start (/data/gannet/ripley/R/R-clang-SAN/bin/exec/R+0x43231d) SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior tslib/tslib/vector.summary/prod.hpp:53:6 in > x.max <- moving.max(x,20) > x.min <- moving.min(x,20) > x.sd <- moving.sd(x,20) > x.rank <- moving.rank(x,20) > > ## take only odd rows > ## to illustrate that teh correlation and covariance > ## will only be calculated for the intersection of the dates > y <- y[(1:nrow(y))%%2 == 1] > > xy.cor <- moving.cor(x, y, 20) > xy.cov <- moving.cov(x, y, 20) > > > > cleanEx() > nameEx("pad.trim") > ### * pad.trim > > flush(stderr()); flush(stdout()) > > ### Name: pad > ### Title: pad and trim dates > ### Aliases: pad.trim pad trim filter.min.obs > ### Keywords: ts > > ### ** Examples > > > x <- fts(index=seq(from=Sys.Date(),by="days",length.out=5),data=1:5) > pad.dates <- index(x)[1] + c(10L,20L) > pad(x,pad.dates) [,1] 2022-05-03 1 2022-05-04 2 2022-05-05 3 2022-05-06 4 2022-05-07 5 2022-05-13 NA 2022-05-23 NA > > trim.dts <- index(x)[c(1,3)] > > trim(x,trim.dts) [,1] 2022-05-03 1 2022-05-05 3 > > > > cleanEx() > nameEx("read.write.fts") > ### * read.write.fts > > flush(stderr()); flush(stdout()) > > ### Name: read.write.fts > ### Title: Read / Write Files > ### Aliases: read.write.fts read.csv.fts write.csv.fts > ### Keywords: ts > > ### ** Examples > > x <- fts(index=seq(from=Sys.Date(),by="days",length.out=100),data=1:100) > colnames(x) <- "big.ass.black.dog" > > csv.fname <- paste(tempfile(),".csv",sep="") > write.csv.fts(x,csv.fname) > y.csv <- read.csv.fts(csv.fname) > > all.equal(x,y.csv) [1] TRUE > > > > cleanEx() > nameEx("remove.rows") > ### * remove.rows > > flush(stderr()); flush(stdout()) > > ### Name: remove.rows > ### Title: Remove Rows > ### Aliases: remove.rows remove.na.rows remove.all.na.rows > ### Keywords: ts > > ### ** Examples > > x <- fts(index=seq(from=Sys.Date(),by="days",length.out=10),matrix(rnorm(20),ncol=2)) > > x[5,1] <- NA > x[10,] <- NA > > print(x) [,1] [,2] 2022-05-03 -0.6264538 1.51178117 2022-05-04 0.1836433 0.38984324 2022-05-05 -0.8356286 -0.62124058 2022-05-06 1.5952808 -2.21469989 2022-05-07 NA 1.12493092 2022-05-08 -0.8204684 -0.04493361 2022-05-09 0.4874291 -0.01619026 2022-05-10 0.7383247 0.94383621 2022-05-11 0.5757814 0.82122120 2022-05-12 NA NA > > ## will drop rows where NA's appear > ## in any of the columns > remove.na.rows(x) [,1] [,2] 2022-05-03 -0.6264538 1.51178117 2022-05-04 0.1836433 0.38984324 2022-05-05 -0.8356286 -0.62124058 2022-05-06 1.5952808 -2.21469989 2022-05-08 -0.8204684 -0.04493361 2022-05-09 0.4874291 -0.01619026 2022-05-10 0.7383247 0.94383621 2022-05-11 0.5757814 0.82122120 > > ## will drop rows where NA's appear > ## in all of the columns > remove.all.na.rows(x) [,1] [,2] 2022-05-03 -0.6264538 1.51178117 2022-05-04 0.1836433 0.38984324 2022-05-05 -0.8356286 -0.62124058 2022-05-06 1.5952808 -2.21469989 2022-05-07 NA 1.12493092 2022-05-08 -0.8204684 -0.04493361 2022-05-09 0.4874291 -0.01619026 2022-05-10 0.7383247 0.94383621 2022-05-11 0.5757814 0.82122120 > > > > cleanEx() > nameEx("since.na") > ### * since.na > > flush(stderr()); flush(stdout()) > > ### Name: since.na > ### Title: Count distance since an NA has occurred > ### Aliases: since.na > ### Keywords: ts > > ### ** Examples > > x <- fts(index=seq(from=Sys.Date(),by="days",length.out=100),rnorm(100)) > > x[10,] <- NA > > since.na(x) [,1] 2022-05-03 -1 2022-05-04 -1 2022-05-05 -1 2022-05-06 -1 2022-05-07 -1 2022-05-08 -1 2022-05-09 -1 2022-05-10 -1 2022-05-11 -1 2022-05-12 0 2022-05-13 1 2022-05-14 2 2022-05-15 3 2022-05-16 4 2022-05-17 5 2022-05-18 6 2022-05-19 7 2022-05-20 8 2022-05-21 9 2022-05-22 10 2022-05-23 11 2022-05-24 12 2022-05-25 13 2022-05-26 14 2022-05-27 15 2022-05-28 16 2022-05-29 17 2022-05-30 18 2022-05-31 19 2022-06-01 20 2022-06-02 21 2022-06-03 22 2022-06-04 23 2022-06-05 24 2022-06-06 25 2022-06-07 26 2022-06-08 27 2022-06-09 28 2022-06-10 29 2022-06-11 30 2022-06-12 31 2022-06-13 32 2022-06-14 33 2022-06-15 34 2022-06-16 35 2022-06-17 36 2022-06-18 37 2022-06-19 38 2022-06-20 39 2022-06-21 40 2022-06-22 41 2022-06-23 42 2022-06-24 43 2022-06-25 44 2022-06-26 45 2022-06-27 46 2022-06-28 47 2022-06-29 48 2022-06-30 49 2022-07-01 50 2022-07-02 51 2022-07-03 52 2022-07-04 53 2022-07-05 54 2022-07-06 55 2022-07-07 56 2022-07-08 57 2022-07-09 58 2022-07-10 59 2022-07-11 60 2022-07-12 61 2022-07-13 62 2022-07-14 63 2022-07-15 64 2022-07-16 65 2022-07-17 66 2022-07-18 67 2022-07-19 68 2022-07-20 69 2022-07-21 70 2022-07-22 71 2022-07-23 72 2022-07-24 73 2022-07-25 74 2022-07-26 75 2022-07-27 76 2022-07-28 77 2022-07-29 78 2022-07-30 79 2022-07-31 80 2022-08-01 81 2022-08-02 82 2022-08-03 83 2022-08-04 84 2022-08-05 85 2022-08-06 86 2022-08-07 87 2022-08-08 88 2022-08-09 89 2022-08-10 90 > > > > ### *