R Under development (unstable) (2024-08-23 r87049 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 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. 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. > ################################################################################ > ## > ## $Id: portfolio.Arith.test.R 406 2007-04-19 16:30:22Z enos $ > ## > ## Tests for adding portolios > ## > ################################################################################ > > library(portfolio) Loading required package: grid Loading required package: lattice > > load("portfolio.Arith.test.RData") > > ## save(p.0, p.1, truth, file = "portfolio.Arith.test.RData", compress = TRUE) > > p.sum <- p.0 + p.1 > > stopifnot( + isTRUE(all.equal(p.sum, truth)), + nrow(p.sum@data) == length(union(p.0@data$id, p.1@data$id)) + ) > > p.pos <- p.0 > > p.neg <- p.0 > p.neg@shares$shares <- -1 * p.neg@shares$shares > p.neg <- calcWeights(p.neg) > > p.sum <- p.pos + p.neg > > stopifnot(validObject(p.sum, test = TRUE), + nrow(p.sum@shares) == 0) > > proc.time() user system elapsed 0.73 0.07 1.21