R Under development (unstable) (2022-04-08 r82135) -- "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-04-11 2022-05-11 2022-06-11 2022-07-11 2022-08-11 2022-09-11 2022-10-11 FALSE FALSE FALSE FALSE TRUE FALSE FALSE 2022-11-11 2022-12-11 2023-01-11 2023-02-11 2023-03-11 2023-04-11 2023-05-11 FALSE TRUE FALSE TRUE FALSE FALSE FALSE 2023-06-11 2023-07-11 2023-08-11 2023-09-11 2023-10-11 2023-11-11 2023-12-11 FALSE FALSE FALSE TRUE TRUE TRUE TRUE 2024-01-11 2024-02-11 2024-03-11 2024-04-11 2024-05-11 2024-06-11 2024-07-11 FALSE TRUE FALSE FALSE FALSE FALSE FALSE 2024-08-11 2024-09-11 2024-10-11 2024-11-11 2024-12-11 2025-01-11 2025-02-11 FALSE FALSE FALSE FALSE TRUE FALSE FALSE 2025-03-11 2025-04-11 2025-05-11 2025-06-11 2025-07-11 2025-08-11 2025-09-11 FALSE FALSE FALSE TRUE TRUE FALSE FALSE 2025-10-11 2025-11-11 2025-12-11 2026-01-11 2026-02-11 2026-03-11 2026-04-11 TRUE TRUE FALSE FALSE FALSE FALSE FALSE 2026-05-11 FALSE > row.any(jj) 2022-04-11 2022-05-11 2022-06-11 2022-07-11 2022-08-11 2022-09-11 2022-10-11 TRUE TRUE TRUE TRUE TRUE TRUE TRUE 2022-11-11 2022-12-11 2023-01-11 2023-02-11 2023-03-11 2023-04-11 2023-05-11 TRUE TRUE FALSE TRUE TRUE TRUE TRUE 2023-06-11 2023-07-11 2023-08-11 2023-09-11 2023-10-11 2023-11-11 2023-12-11 TRUE TRUE FALSE TRUE TRUE TRUE TRUE 2024-01-11 2024-02-11 2024-03-11 2024-04-11 2024-05-11 2024-06-11 2024-07-11 TRUE TRUE FALSE TRUE TRUE FALSE TRUE 2024-08-11 2024-09-11 2024-10-11 2024-11-11 2024-12-11 2025-01-11 2025-02-11 TRUE TRUE TRUE FALSE TRUE FALSE TRUE 2025-03-11 2025-04-11 2025-05-11 2025-06-11 2025-07-11 2025-08-11 2025-09-11 TRUE TRUE FALSE TRUE TRUE FALSE TRUE 2025-10-11 2025-11-11 2025-12-11 2026-01-11 2026-02-11 2026-03-11 2026-04-11 TRUE TRUE TRUE TRUE TRUE TRUE FALSE 2026-05-11 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-04-11 -0.62645381 2022-04-12 -0.62645381 2022-04-13 -0.83562861 2022-04-14 -0.83562861 2022-04-15 -0.83562861 2022-04-16 -0.82046838 2022-04-17 -0.82046838 2022-04-18 -0.82046838 2022-04-19 -0.82046838 2022-04-20 -0.30538839 2022-04-21 -0.30538839 2022-04-22 -0.30538839 2022-04-23 -0.62124058 2022-04-24 -2.21469989 2022-04-25 -2.21469989 2022-04-26 -0.04493361 2022-04-27 -0.01619026 2022-04-28 -0.01619026 2022-04-29 -0.01619026 2022-04-30 -0.01619026 2022-05-01 -0.01619026 2022-05-02 -0.01619026 2022-05-03 -0.01619026 2022-05-04 -1.98935170 2022-05-05 -1.98935170 2022-05-06 -0.05612874 2022-05-07 -0.15579551 2022-05-08 -1.47075238 2022-05-09 -0.47815006 2022-05-10 -0.47815006 2022-05-11 -0.47815006 2022-05-12 -0.10278773 2022-05-13 -0.10278773 2022-05-14 -0.05380504 2022-05-15 -1.37705956 2022-05-16 -0.41499456 2022-05-17 -0.39428995 2022-05-18 -0.05931340 2022-05-19 -0.05931340 2022-05-20 -0.05931340 2022-05-21 -0.16452360 2022-05-22 -0.25336168 2022-05-23 -0.25336168 2022-05-24 -0.25336168 2022-05-25 -0.68875569 2022-05-26 -0.70749516 2022-05-27 -0.70749516 2022-05-28 -0.70749516 2022-05-29 -0.11234621 2022-05-30 -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-04-11 -0.6120264 2022-04-12 -0.6120264 2022-04-13 -1.1293631 2022-04-14 -1.1293631 2022-04-15 -0.3672215 2022-04-16 -0.3672215 2022-04-17 -0.3672215 2022-04-18 -1.0441346 2022-04-19 -0.1350546 2022-04-20 -0.1350546 2022-04-21 -0.0392400 2022-04-22 -0.0392400 2022-04-23 -0.7432732 2022-04-24 -0.7432732 2022-04-25 -0.7432732 2022-04-26 -1.8049586 2022-04-27 -1.8049586 2022-04-28 -0.7099464 2022-04-29 -0.7099464 2022-04-30 -0.7099464 2022-05-01 -0.7099464 2022-05-02 -0.7099464 2022-05-03 -0.9340976 2022-05-04 -0.9340976 2022-05-05 -1.2536334 2022-05-06 -0.4432919 2022-05-07 -0.4432919 2022-05-08 -0.5895209 2022-05-09 -0.5895209 2022-05-10 -0.5895209 2022-05-11 -0.5686687 2022-05-12 -0.1351786 2022-05-13 -1.5235668 2022-05-14 -1.5235668 2022-05-15 -0.3041839 2022-05-16 -0.3041839 2022-05-17 -0.3041839 2022-05-18 -0.3041839 2022-05-19 -0.5425200 2022-05-20 -0.5425200 2022-05-21 -0.5425200 2022-05-22 -1.2765922 2022-05-23 -1.2765922 2022-05-24 -1.2765922 2022-05-25 -1.2765922 2022-05-26 -1.2765922 2022-05-27 -1.2765922 2022-05-28 -0.5732654 2022-05-29 -1.2246126 2022-05-30 -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-04-11 -0.62036668 2022-04-12 100.00000000 2022-04-13 -0.91092165 2022-04-14 100.00000000 2022-04-15 -0.65458464 2022-04-16 100.00000000 2022-04-17 100.00000000 2022-04-18 100.00000000 2022-04-19 100.00000000 2022-04-20 100.00000000 2022-04-21 -0.63573645 2022-04-22 -0.46164473 2022-04-23 100.00000000 2022-04-24 -0.65069635 2022-04-25 -0.20738074 2022-04-26 -0.39280793 2022-04-27 -0.31999287 2022-04-28 -0.27911330 2022-04-29 100.00000000 2022-04-30 -0.17733048 2022-05-01 -0.50595746 2022-05-02 100.00000000 2022-05-03 -0.21457941 2022-05-04 -0.17955653 2022-05-05 -0.10019074 2022-05-06 100.00000000 2022-05-07 -0.07356440 2022-05-08 -0.03763417 2022-05-09 -0.68166048 2022-05-10 -0.32427027 2022-05-11 100.00000000 2022-05-12 -0.58889449 2022-05-13 100.00000000 2022-05-14 -1.51839408 2022-05-15 100.00000000 2022-05-16 -1.53644982 2022-05-17 -0.30097613 2022-05-18 -0.52827990 2022-05-19 -0.65209478 2022-05-20 -0.05689678 2022-05-21 -1.91435943 2022-05-22 100.00000000 2022-05-23 -1.66497244 2022-05-24 -0.46353040 2022-05-25 -1.11592011 2022-05-26 -0.75081900 2022-05-27 100.00000000 2022-05-28 100.00000000 2022-05-29 -1.28630053 2022-05-30 -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-04-16 6 2022-04-23 13 2022-04-30 20 2022-05-07 27 2022-05-14 34 2022-05-21 41 2022-05-28 48 2022-06-04 55 2022-06-11 62 2022-06-18 69 2022-06-25 76 2022-07-02 83 2022-07-09 90 2022-07-16 97 2022-07-23 104 2022-07-30 111 2022-08-06 118 2022-08-13 125 2022-08-20 132 2022-08-27 139 2022-09-03 146 2022-09-10 153 2022-09-17 160 2022-09-24 167 2022-10-01 174 2022-10-08 181 2022-10-15 188 2022-10-22 195 2022-10-29 202 2022-11-05 209 2022-11-12 216 2022-11-19 223 2022-11-26 230 2022-12-03 237 2022-12-10 244 2022-12-17 251 2022-12-24 258 2022-12-31 265 2023-01-07 272 2023-01-14 279 2023-01-21 286 2023-01-28 293 2023-02-04 300 2023-02-11 307 2023-02-18 314 2023-02-25 321 2023-03-04 328 2023-03-11 335 2023-03-18 342 2023-03-25 349 2023-04-01 356 2023-04-08 363 2023-04-15 370 2023-04-22 377 2023-04-29 384 2023-05-06 391 2023-05-13 398 2023-05-20 405 2023-05-27 412 2023-06-03 419 2023-06-10 426 2023-06-17 433 2023-06-24 440 2023-07-01 447 2023-07-08 454 2023-07-15 461 2023-07-22 468 2023-07-29 475 2023-08-05 482 2023-08-12 489 2023-08-19 496 2023-08-23 500 > to.monthly(x) [,1] 2022-04-30 20 2022-05-31 51 2022-06-30 81 2022-07-31 112 2022-08-31 143 2022-09-30 173 2022-10-31 204 2022-11-30 234 2022-12-31 265 2023-01-31 296 2023-02-28 324 2023-03-31 355 2023-04-30 385 2023-05-31 416 2023-06-30 446 2023-07-31 477 2023-08-23 500 > to.quarterly(x) [,1] 2022-06-30 81 2022-09-30 173 2022-12-31 265 2023-03-31 355 2023-06-30 446 2023-08-23 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-04-11 1 2022-05-11 2 2022-06-11 3 2022-07-11 4 2022-08-11 5 2022-09-11 6 2022-10-11 7 2022-11-11 8 2022-12-11 9 2023-01-11 10 2023-02-11 11 2023-03-11 12 2023-04-11 13 2023-05-11 14 2023-06-11 15 2023-07-11 16 2023-08-11 17 2023-09-11 18 2023-10-11 19 2023-11-11 20 2023-12-11 21 2024-01-11 22 2024-02-11 23 2024-03-11 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-04-11 -0.6264538 2022-05-11 0.1836433 2022-06-11 -0.8356286 2022-07-11 1.5952808 2022-08-11 0.3295078 > lag(x,1) [,1] 2022-05-11 -0.6264538 2022-06-11 0.1836433 2022-07-11 -0.8356286 2022-08-11 1.5952808 > lead(x,1) [,1] 2022-04-11 0.1836433 2022-05-11 -0.8356286 2022-06-11 1.5952808 2022-07-11 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-04-12" "2022-04-14" "2022-04-16" "2022-04-18" "2022-04-20" [6] "2022-04-22" "2022-04-24" "2022-04-26" "2022-04-28" "2022-04-30" [11] "2022-05-02" "2022-05-04" "2022-05-06" "2022-05-08" "2022-05-10" [16] "2022-05-12" "2022-05-14" "2022-05-16" "2022-05-18" "2022-05-20" [21] "2022-05-22" "2022-05-24" "2022-05-26" "2022-05-28" "2022-05-30" [26] "2022-06-01" "2022-06-03" "2022-06-05" "2022-06-07" "2022-06-09" [31] "2022-06-11" "2022-06-13" "2022-06-15" "2022-06-17" "2022-06-19" [36] "2022-06-21" "2022-06-23" "2022-06-25" "2022-06-27" "2022-06-29" [41] "2022-07-01" "2022-07-03" "2022-07-05" "2022-07-07" "2022-07-09" [46] "2022-07-11" "2022-07-13" "2022-07-15" "2022-07-17" "2022-07-19" > > > > 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-04-11 1 2022-04-12 2 2022-04-13 3 2022-04-14 4 2022-04-15 5 2022-04-16 6 2022-04-17 7 2022-04-18 8 2022-04-19 9 2022-04-20 10 > lag(x,1) [,1] 2022-04-12 1 2022-04-13 2 2022-04-14 3 2022-04-15 4 2022-04-16 5 2022-04-17 6 2022-04-18 7 2022-04-19 8 2022-04-20 9 > lead(x,1) [,1] 2022-04-11 2 2022-04-12 3 2022-04-13 4 2022-04-14 5 2022-04-15 6 2022-04-16 7 2022-04-17 8 2022-04-18 9 2022-04-19 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 0x7f3527437cd9 in int tslib::Prod::apply(int*, int*) tslib/tslib/vector.summary/prod.hpp:53 #1 0x7f3527437cd9 in void tslib::windowApply::apply(int*, int*, int*, unsigned long) tslib/tslib/utils/window.apply.hpp:36 #2 0x7f3527437cd9 in tslib::TSeries const tslib::TSeries::window(unsigned long) const tslib/tslib/tseries.hpp:314 #3 0x7f35274386e5 in SEXPREC* windowFun(SEXPREC*, SEXPREC*) helpers/window.template.hpp:28 #4 0x7f352747a53f in SEXPREC* windowSpecializer(SEXPREC*, SEXPREC*) helpers/window.template.hpp:43 #5 0x580b87 in R_doDotCall /data/gannet/ripley/R/svn/R-devel/src/main/dotcode.c:604 #6 0x589d5c in do_dotcall /data/gannet/ripley/R/svn/R-devel/src/main/dotcode.c:1284 #7 0x62d766 in bcEval /data/gannet/ripley/R/svn/R-devel/src/main/eval.c:7136 #8 0x675027 in Rf_eval /data/gannet/ripley/R/svn/R-devel/src/main/eval.c:748 #9 0x67a100 in R_execClosure /data/gannet/ripley/R/svn/R-devel/src/main/eval.c:1918 #10 0x67c4f7 in Rf_applyClosure /data/gannet/ripley/R/svn/R-devel/src/main/eval.c:1844 #11 0x67569f in Rf_eval /data/gannet/ripley/R/svn/R-devel/src/main/eval.c:871 #12 0x681779 in do_set /data/gannet/ripley/R/svn/R-devel/src/main/eval.c:2991 #13 0x675ac0 in Rf_eval /data/gannet/ripley/R/svn/R-devel/src/main/eval.c:823 #14 0x6f765d in Rf_ReplIteration /data/gannet/ripley/R/svn/R-devel/src/main/main.c:264 #15 0x6f7cf0 in R_ReplConsole /data/gannet/ripley/R/svn/R-devel/src/main/main.c:316 #16 0x6f7e34 in run_Rmainloop /data/gannet/ripley/R/svn/R-devel/src/main/main.c:1137 #17 0x6f7e82 in Rf_mainloop /data/gannet/ripley/R/svn/R-devel/src/main/main.c:1144 #18 0x41b418 in main /data/gannet/ripley/R/svn/R-devel/src/main/Rmain.c:29 #19 0x7f35380f4b74 in __libc_start_main (/lib64/libc.so.6+0x27b74) #20 0x41dc1d in _start (/data/gannet/ripley/R/gcc-SAN/bin/exec/R+0x41dc1d) > 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-04-11 1 2022-04-12 2 2022-04-13 3 2022-04-14 4 2022-04-15 5 2022-04-21 NA 2022-05-01 NA > > trim.dts <- index(x)[c(1,3)] > > trim(x,trim.dts) [,1] 2022-04-11 1 2022-04-13 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-04-11 -0.6264538 1.51178117 2022-04-12 0.1836433 0.38984324 2022-04-13 -0.8356286 -0.62124058 2022-04-14 1.5952808 -2.21469989 2022-04-15 NA 1.12493092 2022-04-16 -0.8204684 -0.04493361 2022-04-17 0.4874291 -0.01619026 2022-04-18 0.7383247 0.94383621 2022-04-19 0.5757814 0.82122120 2022-04-20 NA NA > > ## will drop rows where NA's appear > ## in any of the columns > remove.na.rows(x) [,1] [,2] 2022-04-11 -0.6264538 1.51178117 2022-04-12 0.1836433 0.38984324 2022-04-13 -0.8356286 -0.62124058 2022-04-14 1.5952808 -2.21469989 2022-04-16 -0.8204684 -0.04493361 2022-04-17 0.4874291 -0.01619026 2022-04-18 0.7383247 0.94383621 2022-04-19 0.5757814 0.82122120 > > ## will drop rows where NA's appear > ## in all of the columns > remove.all.na.rows(x) [,1] [,2] 2022-04-11 -0.6264538 1.51178117 2022-04-12 0.1836433 0.38984324 2022-04-13 -0.8356286 -0.62124058 2022-04-14 1.5952808 -2.21469989 2022-04-15 NA 1.12493092 2022-04-16 -0.8204684 -0.04493361 2022-04-17 0.4874291 -0.01619026 2022-04-18 0.7383247 0.94383621 2022-04-19 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-04-11 -1 2022-04-12 -1 2022-04-13 -1 2022-04-14 -1 2022-04-15 -1 2022-04-16 -1 2022-04-17 -1 2022-04-18 -1 2022-04-19 -1 2022-04-20 0 2022-04-21 1 2022-04-22 2 2022-04-23 3 2022-04-24 4 2022-04-25 5 2022-04-26 6 2022-04-27 7 2022-04-28 8 2022-04-29 9 2022-04-30 10 2022-05-01 11 2022-05-02 12 2022-05-03 13 2022-05-04 14 2022-05-05 15 2022-05-06 16 2022-05-07 17 2022-05-08 18 2022-05-09 19 2022-05-10 20 2022-05-11 21 2022-05-12 22 2022-05-13 23 2022-05-14 24 2022-05-15 25 2022-05-16 26 2022-05-17 27 2022-05-18 28 2022-05-19 29 2022-05-20 30 2022-05-21 31 2022-05-22 32 2022-05-23 33 2022-05-24 34 2022-05-25 35 2022-05-26 36 2022-05-27 37 2022-05-28 38 2022-05-29 39 2022-05-30 40 2022-05-31 41 2022-06-01 42 2022-06-02 43 2022-06-03 44 2022-06-04 45 2022-06-05 46 2022-06-06 47 2022-06-07 48 2022-06-08 49 2022-06-09 50 2022-06-10 51 2022-06-11 52 2022-06-12 53 2022-06-13 54 2022-06-14 55 2022-06-15 56 2022-06-16 57 2022-06-17 58 2022-06-18 59 2022-06-19 60 2022-06-20 61 2022-06-21 62 2022-06-22 63 2022-06-23 64 2022-06-24 65 2022-06-25 66 2022-06-26 67 2022-06-27 68 2022-06-28 69 2022-06-29 70 2022-06-30 71 2022-07-01 72 2022-07-02 73 2022-07-03 74 2022-07-04 75 2022-07-05 76 2022-07-06 77 2022-07-07 78 2022-07-08 79 2022-07-09 80 2022-07-10 81 2022-07-11 82 2022-07-12 83 2022-07-13 84 2022-07-14 85 2022-07-15 86 2022-07-16 87 2022-07-17 88 2022-07-18 89 2022-07-19 90 > > > > ### *