1s autopkgtest [09:39:51]: starting date and time: 2024-05-24 09:39:51+0000 1s autopkgtest [09:39:51]: git checkout: 699e7f9f ssh-setup/nova: explicitely set 'fqdn' in cloud-init 1s autopkgtest [09:39:51]: host juju-7f2275-prod-proposed-migration-environment-2; command line: /home/ubuntu/autopkgtest/runner/autopkgtest --output-dir /tmp/autopkgtest-work.vyqu5lmy/out --timeout-copy=6000 --setup-commands /home/ubuntu/autopkgtest-cloud/worker-config-production/setup-canonical.sh --apt-pocket=proposed=src:r-cran-ggplot2 --apt-upgrade r-cran-matrixstats --timeout-short=300 --timeout-copy=20000 --timeout-build=20000 --env=ADT_TEST_TRIGGERS=r-cran-ggplot2/3.5.1+dfsg-1 -- ssh -s /home/ubuntu/autopkgtest/ssh-setup/nova -- --flavor autopkgtest --security-groups autopkgtest-juju-7f2275-prod-proposed-migration-environment-2@lcy02-137.secgroup --name adt-oracular-amd64-r-cran-matrixstats-20240524-093950-juju-7f2275-prod-proposed-migration-environment-2-12bdd5f9-b656-478a-837e-faf2674679ec --image adt/ubuntu-oracular-amd64-server --keyname testbed-juju-7f2275-prod-proposed-migration-environment-2 --net-id=net_prod-proposed-migration -e TERM=linux -e ''"'"'http_proxy=http://squid.internal:3128'"'"'' -e ''"'"'https_proxy=http://squid.internal:3128'"'"'' -e ''"'"'no_proxy=127.0.0.1,127.0.1.1,login.ubuntu.com,localhost,localdomain,novalocal,internal,archive.ubuntu.com,ports.ubuntu.com,security.ubuntu.com,ddebs.ubuntu.com,changelogs.ubuntu.com,keyserver.ubuntu.com,launchpadlibrarian.net,launchpadcontent.net,launchpad.net,10.24.0.0/24,keystone.ps5.canonical.com,objectstorage.prodstack5.canonical.com'"'"'' --mirror=http://ftpmaster.internal/ubuntu/ 148s autopkgtest [09:42:18]: testbed dpkg architecture: amd64 148s autopkgtest [09:42:18]: testbed apt version: 2.9.3 148s autopkgtest [09:42:18]: @@@@@@@@@@@@@@@@@@@@ test bed setup 149s Get:1 http://ftpmaster.internal/ubuntu oracular-proposed InRelease [73.9 kB] 149s Get:2 http://ftpmaster.internal/ubuntu oracular-proposed/restricted Sources [1964 B] 149s Get:3 http://ftpmaster.internal/ubuntu oracular-proposed/multiverse Sources [3388 B] 149s Get:4 http://ftpmaster.internal/ubuntu oracular-proposed/universe Sources [507 kB] 149s Get:5 http://ftpmaster.internal/ubuntu oracular-proposed/main Sources [57.4 kB] 149s Get:6 http://ftpmaster.internal/ubuntu oracular-proposed/main amd64 Packages [175 kB] 149s Get:7 http://ftpmaster.internal/ubuntu oracular-proposed/main i386 Packages [136 kB] 149s Get:8 http://ftpmaster.internal/ubuntu oracular-proposed/restricted amd64 Packages [7700 B] 149s Get:9 http://ftpmaster.internal/ubuntu oracular-proposed/universe i386 Packages [192 kB] 149s Get:10 http://ftpmaster.internal/ubuntu oracular-proposed/universe amd64 Packages [519 kB] 149s Get:11 http://ftpmaster.internal/ubuntu oracular-proposed/multiverse amd64 Packages [2536 B] 149s Get:12 http://ftpmaster.internal/ubuntu oracular-proposed/multiverse i386 Packages [1392 B] 149s Fetched 1677 kB in 0s (5010 kB/s) 149s Reading package lists... 151s Reading package lists... 151s Building dependency tree... 151s Reading state information... 151s Calculating upgrade... 152s The following packages will be upgraded: 152s libclang-cpp18 libclang1-18 libllvm18 152s 3 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 152s Need to get 48.8 MB of archives. 152s After this operation, 726 kB of additional disk space will be used. 152s Get:1 http://ftpmaster.internal/ubuntu oracular/main amd64 libclang-cpp18 amd64 1:18.1.6-1 [13.5 MB] 152s Get:2 http://ftpmaster.internal/ubuntu oracular/main amd64 libllvm18 amd64 1:18.1.6-1 [27.5 MB] 152s Get:3 http://ftpmaster.internal/ubuntu oracular/main amd64 libclang1-18 amd64 1:18.1.6-1 [7804 kB] 153s Fetched 48.8 MB in 0s (117 MB/s) 153s (Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 74358 files and directories currently installed.) 153s Preparing to unpack .../libclang-cpp18_1%3a18.1.6-1_amd64.deb ... 153s Unpacking libclang-cpp18 (1:18.1.6-1) over (1:18.1.3-1) ... 153s Preparing to unpack .../libllvm18_1%3a18.1.6-1_amd64.deb ... 153s Unpacking libllvm18:amd64 (1:18.1.6-1) over (1:18.1.3-1) ... 154s Preparing to unpack .../libclang1-18_1%3a18.1.6-1_amd64.deb ... 154s Unpacking libclang1-18 (1:18.1.6-1) over (1:18.1.3-1) ... 154s Setting up libllvm18:amd64 (1:18.1.6-1) ... 154s Setting up libclang1-18 (1:18.1.6-1) ... 154s Setting up libclang-cpp18 (1:18.1.6-1) ... 154s Processing triggers for libc-bin (2.39-0ubuntu8.1) ... 154s Reading package lists... 155s Building dependency tree... 155s Reading state information... 155s 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 155s Hit:1 http://ftpmaster.internal/ubuntu oracular-proposed InRelease 155s Hit:2 http://ftpmaster.internal/ubuntu oracular InRelease 155s Hit:3 http://ftpmaster.internal/ubuntu oracular-updates InRelease 155s Hit:4 http://ftpmaster.internal/ubuntu oracular-security InRelease 156s Reading package lists... 156s Reading package lists... 157s Building dependency tree... 157s Reading state information... 157s Calculating upgrade... 157s 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 157s Reading package lists... 157s Building dependency tree... 157s Reading state information... 158s 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 158s autopkgtest [09:42:28]: testbed running kernel: Linux 6.8.0-31-generic #31-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 20 00:40:06 UTC 2024 158s autopkgtest [09:42:28]: @@@@@@@@@@@@@@@@@@@@ apt-source r-cran-matrixstats 159s Get:1 http://ftpmaster.internal/ubuntu oracular/universe r-cran-matrixstats 1.2.0-1 (dsc) [2230 B] 159s Get:2 http://ftpmaster.internal/ubuntu oracular/universe r-cran-matrixstats 1.2.0-1 (tar) [211 kB] 159s Get:3 http://ftpmaster.internal/ubuntu oracular/universe r-cran-matrixstats 1.2.0-1 (diff) [4752 B] 159s gpgv: Signature made Mon Jan 8 21:38:59 2024 UTC 159s gpgv: using RSA key F1F007320A035541F0A663CA578A0494D1C646D1 159s gpgv: issuer "tille@debian.org" 159s gpgv: Can't check signature: No public key 159s dpkg-source: warning: cannot verify inline signature for ./r-cran-matrixstats_1.2.0-1.dsc: no acceptable signature found 159s autopkgtest [09:42:29]: testing package r-cran-matrixstats version 1.2.0-1 159s autopkgtest [09:42:29]: build not needed 160s autopkgtest [09:42:30]: test run-unit-test: preparing testbed 160s Reading package lists... 160s Building dependency tree... 160s Reading state information... 161s Starting pkgProblemResolver with broken count: 0 161s Starting 2 pkgProblemResolver with broken count: 0 161s Done 161s The following additional packages will be installed: 161s fontconfig fonts-glyphicons-halflings fonts-mathjax libblas3 libcairo2 161s libdatrie1 libgfortran5 libgomp1 libgraphite2-3 libharfbuzz0b libice6 161s libjs-bootstrap libjs-highlight.js libjs-jquery libjs-jquery-datatables 161s libjs-mathjax liblapack3 libpango-1.0-0 libpangocairo-1.0-0 161s libpangoft2-1.0-0 libpaper-utils libpaper1 libpixman-1-0 libsm6 libtcl8.6 161s libthai-data libthai0 libtk8.6 libxcb-render0 libxcb-shm0 libxft2 161s libxrender1 libxss1 libxt6t64 node-normalize.css r-base-core 161s r-cran-base64enc r-cran-cli r-cran-colorspace r-cran-commonmark 161s r-cran-digest r-cran-evaluate r-cran-fansi r-cran-farver r-cran-ggplot2 161s r-cran-glue r-cran-gtable r-cran-highr r-cran-isoband r-cran-knitr 161s r-cran-labeling r-cran-lattice r-cran-lifecycle r-cran-magrittr 161s r-cran-markdown r-cran-mass r-cran-matrix r-cran-matrixstats r-cran-mgcv 161s r-cran-munsell r-cran-nlme r-cran-pillar r-cran-pkgconfig r-cran-r.cache 161s r-cran-r.devices r-cran-r.methodss3 r-cran-r.oo r-cran-r.rsp r-cran-r.utils 161s r-cran-r6 r-cran-rcolorbrewer r-cran-rlang r-cran-scales r-cran-tibble 161s r-cran-utf8 r-cran-vctrs r-cran-viridislite r-cran-withr r-cran-xfun 161s r-cran-yaml tcl tcl8.6 unzip x11-common xdg-utils zip 161s Suggested packages: 161s fonts-mathjax-extras fonts-stix libjs-mathjax-doc tk8.6 libjs-html5shiv 161s elpa-ess r-doc-info | r-doc-pdf r-mathlib r-base-html r-cran-kernsmooth 161s r-cran-kernlab r-cran-mvtnorm r-cran-vcd r-cran-shiny r-cran-shinyjs 161s r-cran-dplyr r-cran-png r-cran-jpeg r-cran-rmarkdown r-cran-viridis 161s r-cran-covr r-cran-magick r-cran-sf r-cran-bit64 r-cran-dbi 161s r-cran-formattable r-cran-nanotime r-cran-palmerpenguins r-cran-stringi 161s r-cran-survival r-cran-units r-cran-vdiffr r-cran-testthat r-cran-cairo 161s r-cran-codetools r-cran-bench r-cran-blob r-cran-brio r-cran-callr 161s r-cran-crayon r-cran-here r-cran-hms r-cran-htmltools r-cran-pkgbuild 161s r-cran-pkgload r-cran-purrr r-cran-tidyr tcl-tclreadline 161s Recommended packages: 161s javascript-common r-recommended r-base-dev r-doc-html r-cran-callr 161s r-cran-covr r-cran-crayon r-cran-htmltools r-cran-htmlwidgets r-cran-mockery 161s r-cran-processx r-cran-ps r-cran-rmarkdown r-cran-rprojroot 161s r-cran-rstudioapi r-cran-testthat r-cran-whoami r-cran-curl r-cran-xml2 161s r-cran-unitizer r-cran-dplyr r-cran-hexbin r-cran-hmisc r-cran-mapproj 161s r-cran-maps r-cran-multcomp r-cran-profvis r-cran-quantreg r-cran-ragg 161s r-cran-rpart r-cran-sf r-cran-svglite r-cran-vdiffr r-cran-dbi 161s r-cran-rsqlite r-cran-waldo r-cran-testit r-cran-bslib r-cran-codetools 161s r-cran-formatr r-cran-gridsvg r-cran-jpeg r-cran-magick r-cran-png 161s r-cran-reticulate r-cran-rgl r-cran-sass r-cran-tikzdevice r-cran-tinytex 161s r-cran-webshot node-highlight.js r-cran-lintr r-cran-tidyverse r-cran-rcurl 161s r-cran-lubridate libjs-remark-slide r-cran-fs r-cran-usethis r-cran-bit64 161s r-cran-dichromat r-cran-hms r-cran-stringi r-cran-data.table r-cran-mockr 161s r-cran-formattable r-cran-generics r-cran-pkgdown r-cran-zeallot r-cran-mime 161s r-cran-remotes r-cran-renv r-cran-jsonlite r-cran-runit 161s libfile-mimeinfo-perl libnet-dbus-perl libx11-protocol-perl x11-utils 161s x11-xserver-utils 162s The following NEW packages will be installed: 162s autopkgtest-satdep fontconfig fonts-glyphicons-halflings fonts-mathjax 162s libblas3 libcairo2 libdatrie1 libgfortran5 libgomp1 libgraphite2-3 162s libharfbuzz0b libice6 libjs-bootstrap libjs-highlight.js libjs-jquery 162s libjs-jquery-datatables libjs-mathjax liblapack3 libpango-1.0-0 162s libpangocairo-1.0-0 libpangoft2-1.0-0 libpaper-utils libpaper1 libpixman-1-0 162s libsm6 libtcl8.6 libthai-data libthai0 libtk8.6 libxcb-render0 libxcb-shm0 162s libxft2 libxrender1 libxss1 libxt6t64 node-normalize.css r-base-core 162s r-cran-base64enc r-cran-cli r-cran-colorspace r-cran-commonmark 162s r-cran-digest r-cran-evaluate r-cran-fansi r-cran-farver r-cran-ggplot2 162s r-cran-glue r-cran-gtable r-cran-highr r-cran-isoband r-cran-knitr 162s r-cran-labeling r-cran-lattice r-cran-lifecycle r-cran-magrittr 162s r-cran-markdown r-cran-mass r-cran-matrix r-cran-matrixstats r-cran-mgcv 162s r-cran-munsell r-cran-nlme r-cran-pillar r-cran-pkgconfig r-cran-r.cache 162s r-cran-r.devices r-cran-r.methodss3 r-cran-r.oo r-cran-r.rsp r-cran-r.utils 162s r-cran-r6 r-cran-rcolorbrewer r-cran-rlang r-cran-scales r-cran-tibble 162s r-cran-utf8 r-cran-vctrs r-cran-viridislite r-cran-withr r-cran-xfun 162s r-cran-yaml tcl tcl8.6 unzip x11-common xdg-utils zip 162s 0 upgraded, 87 newly installed, 0 to remove and 0 not upgraded. 162s Need to get 82.2 MB/82.2 MB of archives. 162s After this operation, 183 MB of additional disk space will be used. 162s Get:1 /tmp/autopkgtest.eTRLIq/1-autopkgtest-satdep.deb autopkgtest-satdep amd64 0 [756 B] 162s Get:2 http://ftpmaster.internal/ubuntu oracular/main amd64 fontconfig amd64 2.15.0-1.1ubuntu2 [180 kB] 162s Get:3 http://ftpmaster.internal/ubuntu oracular/universe amd64 fonts-glyphicons-halflings all 1.009~3.4.1+dfsg-3 [118 kB] 162s Get:4 http://ftpmaster.internal/ubuntu oracular/main amd64 fonts-mathjax all 2.7.9+dfsg-1 [2208 kB] 162s Get:5 http://ftpmaster.internal/ubuntu oracular/main amd64 libblas3 amd64 3.12.0-3build1 [238 kB] 162s Get:6 http://ftpmaster.internal/ubuntu oracular/main amd64 libpixman-1-0 amd64 0.42.2-1build1 [279 kB] 162s Get:7 http://ftpmaster.internal/ubuntu oracular/main amd64 libxcb-render0 amd64 1.17.0-2 [16.2 kB] 162s Get:8 http://ftpmaster.internal/ubuntu oracular/main amd64 libxcb-shm0 amd64 1.17.0-2 [5758 B] 162s Get:9 http://ftpmaster.internal/ubuntu oracular/main amd64 libxrender1 amd64 1:0.9.10-1.1build1 [19.0 kB] 162s Get:10 http://ftpmaster.internal/ubuntu oracular/main amd64 libcairo2 amd64 1.18.0-3build1 [566 kB] 162s Get:11 http://ftpmaster.internal/ubuntu oracular/main amd64 libdatrie1 amd64 0.2.13-3build1 [19.0 kB] 162s Get:12 http://ftpmaster.internal/ubuntu oracular/main amd64 libgfortran5 amd64 14.1.0-1ubuntu1 [928 kB] 162s Get:13 http://ftpmaster.internal/ubuntu oracular/main amd64 libgomp1 amd64 14.1.0-1ubuntu1 [148 kB] 162s Get:14 http://ftpmaster.internal/ubuntu oracular/main amd64 libgraphite2-3 amd64 1.3.14-2build1 [73.0 kB] 162s Get:15 http://ftpmaster.internal/ubuntu oracular/main amd64 libharfbuzz0b amd64 8.3.0-2build2 [469 kB] 162s Get:16 http://ftpmaster.internal/ubuntu oracular/main amd64 x11-common all 1:7.7+23ubuntu3 [21.7 kB] 162s Get:17 http://ftpmaster.internal/ubuntu oracular/main amd64 libice6 amd64 2:1.0.10-1build3 [41.4 kB] 162s Get:18 http://ftpmaster.internal/ubuntu oracular/universe amd64 libjs-bootstrap all 3.4.1+dfsg-3 [129 kB] 162s Get:19 http://ftpmaster.internal/ubuntu oracular/universe amd64 libjs-highlight.js all 9.18.5+dfsg1-2 [385 kB] 162s Get:20 http://ftpmaster.internal/ubuntu oracular/main amd64 libjs-jquery all 3.6.1+dfsg+~3.5.14-1 [328 kB] 162s Get:21 http://ftpmaster.internal/ubuntu oracular/universe amd64 libjs-jquery-datatables all 1.11.5+dfsg-2 [146 kB] 162s Get:22 http://ftpmaster.internal/ubuntu oracular/main amd64 liblapack3 amd64 3.12.0-3build1 [2650 kB] 162s Get:23 http://ftpmaster.internal/ubuntu oracular/main amd64 libthai-data all 0.1.29-2build1 [158 kB] 162s Get:24 http://ftpmaster.internal/ubuntu oracular/main amd64 libthai0 amd64 0.1.29-2build1 [18.9 kB] 162s Get:25 http://ftpmaster.internal/ubuntu oracular/main amd64 libpango-1.0-0 amd64 1.52.2+ds-1 [233 kB] 162s Get:26 http://ftpmaster.internal/ubuntu oracular/main amd64 libpangoft2-1.0-0 amd64 1.52.2+ds-1 [42.6 kB] 162s Get:27 http://ftpmaster.internal/ubuntu oracular/main amd64 libpangocairo-1.0-0 amd64 1.52.2+ds-1 [28.7 kB] 162s Get:28 http://ftpmaster.internal/ubuntu oracular/main amd64 libpaper1 amd64 1.1.29build1 [13.4 kB] 162s Get:29 http://ftpmaster.internal/ubuntu oracular/main amd64 libpaper-utils amd64 1.1.29build1 [8650 B] 162s Get:30 http://ftpmaster.internal/ubuntu oracular/main amd64 libsm6 amd64 2:1.2.3-1build3 [15.7 kB] 162s Get:31 http://ftpmaster.internal/ubuntu oracular/main amd64 libtcl8.6 amd64 8.6.14+dfsg-1build1 [988 kB] 162s Get:32 http://ftpmaster.internal/ubuntu oracular/main amd64 libxft2 amd64 2.3.6-1build1 [45.3 kB] 162s Get:33 http://ftpmaster.internal/ubuntu oracular/main amd64 libxss1 amd64 1:1.2.3-1build3 [7204 B] 162s Get:34 http://ftpmaster.internal/ubuntu oracular/main amd64 libtk8.6 amd64 8.6.14-1build1 [779 kB] 162s Get:35 http://ftpmaster.internal/ubuntu oracular/main amd64 libxt6t64 amd64 1:1.2.1-1.2build1 [171 kB] 162s Get:36 http://ftpmaster.internal/ubuntu oracular/universe amd64 node-normalize.css all 8.0.1-5 [10.8 kB] 162s Get:37 http://ftpmaster.internal/ubuntu oracular/main amd64 zip amd64 3.0-13build1 [175 kB] 162s Get:38 http://ftpmaster.internal/ubuntu oracular/main amd64 unzip amd64 6.0-28ubuntu4 [175 kB] 162s Get:39 http://ftpmaster.internal/ubuntu oracular/main amd64 xdg-utils all 1.1.3-4.1ubuntu3 [62.0 kB] 162s Get:40 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-base-core amd64 4.4.0-2 [28.5 MB] 162s Get:41 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-base64enc amd64 0.1-3-3 [27.6 kB] 162s Get:42 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-cli amd64 3.6.2-1 [1380 kB] 162s Get:43 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-colorspace amd64 2.1-0+dfsg-1 [1541 kB] 162s Get:44 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-commonmark amd64 1.9.1-1 [131 kB] 162s Get:45 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-digest amd64 0.6.35-1 [195 kB] 162s Get:46 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-evaluate all 0.23-1 [90.2 kB] 162s Get:47 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-fansi amd64 1.0.5-1 [619 kB] 162s Get:48 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-farver amd64 2.1.1-2 [1349 kB] 162s Get:49 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-glue amd64 1.7.0-1 [154 kB] 162s Get:50 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-rlang amd64 1.1.3-1 [1663 kB] 162s Get:51 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-lifecycle all 1.0.4+dfsg-1 [110 kB] 162s Get:52 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-gtable all 0.3.4+dfsg-1 [191 kB] 162s Get:53 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-isoband amd64 0.2.7-1 [1481 kB] 162s Get:54 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-mass amd64 7.3-60.2-1 [1109 kB] 162s Get:55 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-lattice amd64 0.22-6-1 [1340 kB] 162s Get:56 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-nlme amd64 3.1.164-1build1 [2261 kB] 162s Get:57 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-matrix amd64 1.6-5-1 [3830 kB] 162s Get:58 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-mgcv amd64 1.9-1-1 [3252 kB] 162s Get:59 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-labeling all 0.4.3-1 [62.1 kB] 162s Get:60 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-munsell all 0.5.0-2build1 [208 kB] 162s Get:61 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-r6 all 2.5.1-1 [99.0 kB] 162s Get:62 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-rcolorbrewer all 1.1-3-1build1 [55.4 kB] 162s Get:63 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-viridislite all 0.4.2-2 [1088 kB] 162s Get:64 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-scales all 1.3.0-1 [603 kB] 162s Get:65 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-magrittr amd64 2.0.3-1 [154 kB] 162s Get:66 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-utf8 amd64 1.2.4-1 [140 kB] 162s Get:67 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-vctrs amd64 0.6.5-1 [1335 kB] 162s Get:68 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-pillar all 1.9.0+dfsg-1 [464 kB] 162s Get:69 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-pkgconfig all 2.0.3-2build1 [19.7 kB] 162s Get:70 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-tibble amd64 3.2.1+dfsg-2 [415 kB] 162s Get:71 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-withr all 2.5.0-1 [225 kB] 162s Get:72 http://ftpmaster.internal/ubuntu oracular-proposed/universe amd64 r-cran-ggplot2 all 3.5.1+dfsg-1 [3940 kB] 163s Get:73 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-xfun amd64 0.44+dfsg-1 [518 kB] 163s Get:74 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-highr all 0.10+dfsg-2 [38.5 kB] 163s Get:75 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-yaml amd64 2.3.8-2 [108 kB] 163s Get:76 http://ftpmaster.internal/ubuntu oracular/main amd64 libjs-mathjax all 2.7.9+dfsg-1 [5665 kB] 163s Get:77 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-knitr all 1.46+dfsg-1 [911 kB] 163s Get:78 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-markdown all 1.12+dfsg-2 [179 kB] 163s Get:79 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-matrixstats amd64 1.2.0-1 [488 kB] 163s Get:80 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-r.methodss3 all 1.8.2-1 [84.0 kB] 163s Get:81 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-r.oo all 1.26.0-1 [955 kB] 163s Get:82 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-r.utils all 2.12.3-1 [1386 kB] 163s Get:83 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-r.cache all 0.16.0-1 [113 kB] 163s Get:84 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-r.devices all 2.17.2+ds-1 [398 kB] 163s Get:85 http://ftpmaster.internal/ubuntu oracular/main amd64 tcl8.6 amd64 8.6.14+dfsg-1build1 [14.7 kB] 163s Get:86 http://ftpmaster.internal/ubuntu oracular/main amd64 tcl amd64 8.6.14build1 [4124 B] 163s Get:87 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-r.rsp all 0.46.0+ds-1 [1412 kB] 163s Preconfiguring packages ... 163s Fetched 82.2 MB in 1s (86.3 MB/s) 163s Selecting previously unselected package fontconfig. 163s (Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 74359 files and directories currently installed.) 163s Preparing to unpack .../00-fontconfig_2.15.0-1.1ubuntu2_amd64.deb ... 163s Unpacking fontconfig (2.15.0-1.1ubuntu2) ... 163s Selecting previously unselected package fonts-glyphicons-halflings. 163s Preparing to unpack .../01-fonts-glyphicons-halflings_1.009~3.4.1+dfsg-3_all.deb ... 163s Unpacking fonts-glyphicons-halflings (1.009~3.4.1+dfsg-3) ... 163s Selecting previously unselected package fonts-mathjax. 163s Preparing to unpack .../02-fonts-mathjax_2.7.9+dfsg-1_all.deb ... 163s Unpacking fonts-mathjax (2.7.9+dfsg-1) ... 163s Selecting previously unselected package libblas3:amd64. 163s Preparing to unpack .../03-libblas3_3.12.0-3build1_amd64.deb ... 163s Unpacking libblas3:amd64 (3.12.0-3build1) ... 163s Selecting previously unselected package libpixman-1-0:amd64. 163s Preparing to unpack .../04-libpixman-1-0_0.42.2-1build1_amd64.deb ... 163s Unpacking libpixman-1-0:amd64 (0.42.2-1build1) ... 163s Selecting previously unselected package libxcb-render0:amd64. 163s Preparing to unpack .../05-libxcb-render0_1.17.0-2_amd64.deb ... 163s Unpacking libxcb-render0:amd64 (1.17.0-2) ... 163s Selecting previously unselected package libxcb-shm0:amd64. 163s Preparing to unpack .../06-libxcb-shm0_1.17.0-2_amd64.deb ... 164s Unpacking libxcb-shm0:amd64 (1.17.0-2) ... 164s Selecting previously unselected package libxrender1:amd64. 164s Preparing to unpack .../07-libxrender1_1%3a0.9.10-1.1build1_amd64.deb ... 164s Unpacking libxrender1:amd64 (1:0.9.10-1.1build1) ... 164s Selecting previously unselected package libcairo2:amd64. 164s Preparing to unpack .../08-libcairo2_1.18.0-3build1_amd64.deb ... 164s Unpacking libcairo2:amd64 (1.18.0-3build1) ... 164s Selecting previously unselected package libdatrie1:amd64. 164s Preparing to unpack .../09-libdatrie1_0.2.13-3build1_amd64.deb ... 164s Unpacking libdatrie1:amd64 (0.2.13-3build1) ... 164s Selecting previously unselected package libgfortran5:amd64. 164s Preparing to unpack .../10-libgfortran5_14.1.0-1ubuntu1_amd64.deb ... 164s Unpacking libgfortran5:amd64 (14.1.0-1ubuntu1) ... 164s Selecting previously unselected package libgomp1:amd64. 164s Preparing to unpack .../11-libgomp1_14.1.0-1ubuntu1_amd64.deb ... 164s Unpacking libgomp1:amd64 (14.1.0-1ubuntu1) ... 164s Selecting previously unselected package libgraphite2-3:amd64. 164s Preparing to unpack .../12-libgraphite2-3_1.3.14-2build1_amd64.deb ... 164s Unpacking libgraphite2-3:amd64 (1.3.14-2build1) ... 164s Selecting previously unselected package libharfbuzz0b:amd64. 164s Preparing to unpack .../13-libharfbuzz0b_8.3.0-2build2_amd64.deb ... 164s Unpacking libharfbuzz0b:amd64 (8.3.0-2build2) ... 164s Selecting previously unselected package x11-common. 164s Preparing to unpack .../14-x11-common_1%3a7.7+23ubuntu3_all.deb ... 164s Unpacking x11-common (1:7.7+23ubuntu3) ... 164s Selecting previously unselected package libice6:amd64. 164s Preparing to unpack .../15-libice6_2%3a1.0.10-1build3_amd64.deb ... 164s Unpacking libice6:amd64 (2:1.0.10-1build3) ... 164s Selecting previously unselected package libjs-bootstrap. 164s Preparing to unpack .../16-libjs-bootstrap_3.4.1+dfsg-3_all.deb ... 164s Unpacking libjs-bootstrap (3.4.1+dfsg-3) ... 164s Selecting previously unselected package libjs-highlight.js. 164s Preparing to unpack .../17-libjs-highlight.js_9.18.5+dfsg1-2_all.deb ... 164s Unpacking libjs-highlight.js (9.18.5+dfsg1-2) ... 164s Selecting previously unselected package libjs-jquery. 164s Preparing to unpack .../18-libjs-jquery_3.6.1+dfsg+~3.5.14-1_all.deb ... 164s Unpacking libjs-jquery (3.6.1+dfsg+~3.5.14-1) ... 164s Selecting previously unselected package libjs-jquery-datatables. 164s Preparing to unpack .../19-libjs-jquery-datatables_1.11.5+dfsg-2_all.deb ... 164s Unpacking libjs-jquery-datatables (1.11.5+dfsg-2) ... 164s Selecting previously unselected package liblapack3:amd64. 164s Preparing to unpack .../20-liblapack3_3.12.0-3build1_amd64.deb ... 164s Unpacking liblapack3:amd64 (3.12.0-3build1) ... 164s Selecting previously unselected package libthai-data. 164s Preparing to unpack .../21-libthai-data_0.1.29-2build1_all.deb ... 164s Unpacking libthai-data (0.1.29-2build1) ... 164s Selecting previously unselected package libthai0:amd64. 164s Preparing to unpack .../22-libthai0_0.1.29-2build1_amd64.deb ... 164s Unpacking libthai0:amd64 (0.1.29-2build1) ... 164s Selecting previously unselected package libpango-1.0-0:amd64. 164s Preparing to unpack .../23-libpango-1.0-0_1.52.2+ds-1_amd64.deb ... 164s Unpacking libpango-1.0-0:amd64 (1.52.2+ds-1) ... 164s Selecting previously unselected package libpangoft2-1.0-0:amd64. 164s Preparing to unpack .../24-libpangoft2-1.0-0_1.52.2+ds-1_amd64.deb ... 164s Unpacking libpangoft2-1.0-0:amd64 (1.52.2+ds-1) ... 164s Selecting previously unselected package libpangocairo-1.0-0:amd64. 164s Preparing to unpack .../25-libpangocairo-1.0-0_1.52.2+ds-1_amd64.deb ... 164s Unpacking libpangocairo-1.0-0:amd64 (1.52.2+ds-1) ... 164s Selecting previously unselected package libpaper1:amd64. 164s Preparing to unpack .../26-libpaper1_1.1.29build1_amd64.deb ... 164s Unpacking libpaper1:amd64 (1.1.29build1) ... 164s Selecting previously unselected package libpaper-utils. 164s Preparing to unpack .../27-libpaper-utils_1.1.29build1_amd64.deb ... 164s Unpacking libpaper-utils (1.1.29build1) ... 164s Selecting previously unselected package libsm6:amd64. 164s Preparing to unpack .../28-libsm6_2%3a1.2.3-1build3_amd64.deb ... 164s Unpacking libsm6:amd64 (2:1.2.3-1build3) ... 164s Selecting previously unselected package libtcl8.6:amd64. 164s Preparing to unpack .../29-libtcl8.6_8.6.14+dfsg-1build1_amd64.deb ... 164s Unpacking libtcl8.6:amd64 (8.6.14+dfsg-1build1) ... 164s Selecting previously unselected package libxft2:amd64. 164s Preparing to unpack .../30-libxft2_2.3.6-1build1_amd64.deb ... 164s Unpacking libxft2:amd64 (2.3.6-1build1) ... 164s Selecting previously unselected package libxss1:amd64. 164s Preparing to unpack .../31-libxss1_1%3a1.2.3-1build3_amd64.deb ... 164s Unpacking libxss1:amd64 (1:1.2.3-1build3) ... 164s Selecting previously unselected package libtk8.6:amd64. 164s Preparing to unpack .../32-libtk8.6_8.6.14-1build1_amd64.deb ... 164s Unpacking libtk8.6:amd64 (8.6.14-1build1) ... 165s Selecting previously unselected package libxt6t64:amd64. 165s Preparing to unpack .../33-libxt6t64_1%3a1.2.1-1.2build1_amd64.deb ... 165s Unpacking libxt6t64:amd64 (1:1.2.1-1.2build1) ... 165s Selecting previously unselected package node-normalize.css. 165s Preparing to unpack .../34-node-normalize.css_8.0.1-5_all.deb ... 165s Unpacking node-normalize.css (8.0.1-5) ... 165s Selecting previously unselected package zip. 165s Preparing to unpack .../35-zip_3.0-13build1_amd64.deb ... 165s Unpacking zip (3.0-13build1) ... 165s Selecting previously unselected package unzip. 165s Preparing to unpack .../36-unzip_6.0-28ubuntu4_amd64.deb ... 165s Unpacking unzip (6.0-28ubuntu4) ... 165s Selecting previously unselected package xdg-utils. 165s Preparing to unpack .../37-xdg-utils_1.1.3-4.1ubuntu3_all.deb ... 165s Unpacking xdg-utils (1.1.3-4.1ubuntu3) ... 165s Selecting previously unselected package r-base-core. 165s Preparing to unpack .../38-r-base-core_4.4.0-2_amd64.deb ... 165s Unpacking r-base-core (4.4.0-2) ... 165s Selecting previously unselected package r-cran-base64enc. 165s Preparing to unpack .../39-r-cran-base64enc_0.1-3-3_amd64.deb ... 165s Unpacking r-cran-base64enc (0.1-3-3) ... 165s Selecting previously unselected package r-cran-cli. 165s Preparing to unpack .../40-r-cran-cli_3.6.2-1_amd64.deb ... 165s Unpacking r-cran-cli (3.6.2-1) ... 165s Selecting previously unselected package r-cran-colorspace. 165s Preparing to unpack .../41-r-cran-colorspace_2.1-0+dfsg-1_amd64.deb ... 165s Unpacking r-cran-colorspace (2.1-0+dfsg-1) ... 165s Selecting previously unselected package r-cran-commonmark. 165s Preparing to unpack .../42-r-cran-commonmark_1.9.1-1_amd64.deb ... 165s Unpacking r-cran-commonmark (1.9.1-1) ... 165s Selecting previously unselected package r-cran-digest. 165s Preparing to unpack .../43-r-cran-digest_0.6.35-1_amd64.deb ... 165s Unpacking r-cran-digest (0.6.35-1) ... 165s Selecting previously unselected package r-cran-evaluate. 165s Preparing to unpack .../44-r-cran-evaluate_0.23-1_all.deb ... 165s Unpacking r-cran-evaluate (0.23-1) ... 165s Selecting previously unselected package r-cran-fansi. 165s Preparing to unpack .../45-r-cran-fansi_1.0.5-1_amd64.deb ... 165s Unpacking r-cran-fansi (1.0.5-1) ... 165s Selecting previously unselected package r-cran-farver. 165s Preparing to unpack .../46-r-cran-farver_2.1.1-2_amd64.deb ... 165s Unpacking r-cran-farver (2.1.1-2) ... 165s Selecting previously unselected package r-cran-glue. 165s Preparing to unpack .../47-r-cran-glue_1.7.0-1_amd64.deb ... 165s Unpacking r-cran-glue (1.7.0-1) ... 165s Selecting previously unselected package r-cran-rlang. 165s Preparing to unpack .../48-r-cran-rlang_1.1.3-1_amd64.deb ... 165s Unpacking r-cran-rlang (1.1.3-1) ... 165s Selecting previously unselected package r-cran-lifecycle. 165s Preparing to unpack .../49-r-cran-lifecycle_1.0.4+dfsg-1_all.deb ... 165s Unpacking r-cran-lifecycle (1.0.4+dfsg-1) ... 166s Selecting previously unselected package r-cran-gtable. 166s Preparing to unpack .../50-r-cran-gtable_0.3.4+dfsg-1_all.deb ... 166s Unpacking r-cran-gtable (0.3.4+dfsg-1) ... 166s Selecting previously unselected package r-cran-isoband. 166s Preparing to unpack .../51-r-cran-isoband_0.2.7-1_amd64.deb ... 166s Unpacking r-cran-isoband (0.2.7-1) ... 166s Selecting previously unselected package r-cran-mass. 166s Preparing to unpack .../52-r-cran-mass_7.3-60.2-1_amd64.deb ... 166s Unpacking r-cran-mass (7.3-60.2-1) ... 166s Selecting previously unselected package r-cran-lattice. 166s Preparing to unpack .../53-r-cran-lattice_0.22-6-1_amd64.deb ... 166s Unpacking r-cran-lattice (0.22-6-1) ... 166s Selecting previously unselected package r-cran-nlme. 166s Preparing to unpack .../54-r-cran-nlme_3.1.164-1build1_amd64.deb ... 166s Unpacking r-cran-nlme (3.1.164-1build1) ... 166s Selecting previously unselected package r-cran-matrix. 166s Preparing to unpack .../55-r-cran-matrix_1.6-5-1_amd64.deb ... 166s Unpacking r-cran-matrix (1.6-5-1) ... 166s Selecting previously unselected package r-cran-mgcv. 166s Preparing to unpack .../56-r-cran-mgcv_1.9-1-1_amd64.deb ... 166s Unpacking r-cran-mgcv (1.9-1-1) ... 166s Selecting previously unselected package r-cran-labeling. 166s Preparing to unpack .../57-r-cran-labeling_0.4.3-1_all.deb ... 166s Unpacking r-cran-labeling (0.4.3-1) ... 166s Selecting previously unselected package r-cran-munsell. 166s Preparing to unpack .../58-r-cran-munsell_0.5.0-2build1_all.deb ... 166s Unpacking r-cran-munsell (0.5.0-2build1) ... 166s Selecting previously unselected package r-cran-r6. 166s Preparing to unpack .../59-r-cran-r6_2.5.1-1_all.deb ... 166s Unpacking r-cran-r6 (2.5.1-1) ... 166s Selecting previously unselected package r-cran-rcolorbrewer. 166s Preparing to unpack .../60-r-cran-rcolorbrewer_1.1-3-1build1_all.deb ... 166s Unpacking r-cran-rcolorbrewer (1.1-3-1build1) ... 166s Selecting previously unselected package r-cran-viridislite. 166s Preparing to unpack .../61-r-cran-viridislite_0.4.2-2_all.deb ... 166s Unpacking r-cran-viridislite (0.4.2-2) ... 166s Selecting previously unselected package r-cran-scales. 166s Preparing to unpack .../62-r-cran-scales_1.3.0-1_all.deb ... 166s Unpacking r-cran-scales (1.3.0-1) ... 166s Selecting previously unselected package r-cran-magrittr. 166s Preparing to unpack .../63-r-cran-magrittr_2.0.3-1_amd64.deb ... 166s Unpacking r-cran-magrittr (2.0.3-1) ... 166s Selecting previously unselected package r-cran-utf8. 166s Preparing to unpack .../64-r-cran-utf8_1.2.4-1_amd64.deb ... 166s Unpacking r-cran-utf8 (1.2.4-1) ... 166s Selecting previously unselected package r-cran-vctrs. 166s Preparing to unpack .../65-r-cran-vctrs_0.6.5-1_amd64.deb ... 166s Unpacking r-cran-vctrs (0.6.5-1) ... 166s Selecting previously unselected package r-cran-pillar. 166s Preparing to unpack .../66-r-cran-pillar_1.9.0+dfsg-1_all.deb ... 166s Unpacking r-cran-pillar (1.9.0+dfsg-1) ... 166s Selecting previously unselected package r-cran-pkgconfig. 166s Preparing to unpack .../67-r-cran-pkgconfig_2.0.3-2build1_all.deb ... 166s Unpacking r-cran-pkgconfig (2.0.3-2build1) ... 166s Selecting previously unselected package r-cran-tibble. 166s Preparing to unpack .../68-r-cran-tibble_3.2.1+dfsg-2_amd64.deb ... 166s Unpacking r-cran-tibble (3.2.1+dfsg-2) ... 166s Selecting previously unselected package r-cran-withr. 166s Preparing to unpack .../69-r-cran-withr_2.5.0-1_all.deb ... 166s Unpacking r-cran-withr (2.5.0-1) ... 166s Selecting previously unselected package r-cran-ggplot2. 166s Preparing to unpack .../70-r-cran-ggplot2_3.5.1+dfsg-1_all.deb ... 166s Unpacking r-cran-ggplot2 (3.5.1+dfsg-1) ... 166s Selecting previously unselected package r-cran-xfun. 166s Preparing to unpack .../71-r-cran-xfun_0.44+dfsg-1_amd64.deb ... 166s Unpacking r-cran-xfun (0.44+dfsg-1) ... 167s Selecting previously unselected package r-cran-highr. 167s Preparing to unpack .../72-r-cran-highr_0.10+dfsg-2_all.deb ... 167s Unpacking r-cran-highr (0.10+dfsg-2) ... 167s Selecting previously unselected package r-cran-yaml. 167s Preparing to unpack .../73-r-cran-yaml_2.3.8-2_amd64.deb ... 167s Unpacking r-cran-yaml (2.3.8-2) ... 167s Selecting previously unselected package libjs-mathjax. 167s Preparing to unpack .../74-libjs-mathjax_2.7.9+dfsg-1_all.deb ... 167s Unpacking libjs-mathjax (2.7.9+dfsg-1) ... 167s Selecting previously unselected package r-cran-knitr. 167s Preparing to unpack .../75-r-cran-knitr_1.46+dfsg-1_all.deb ... 167s Unpacking r-cran-knitr (1.46+dfsg-1) ... 167s Selecting previously unselected package r-cran-markdown. 167s Preparing to unpack .../76-r-cran-markdown_1.12+dfsg-2_all.deb ... 167s Unpacking r-cran-markdown (1.12+dfsg-2) ... 167s Selecting previously unselected package r-cran-matrixstats. 167s Preparing to unpack .../77-r-cran-matrixstats_1.2.0-1_amd64.deb ... 167s Unpacking r-cran-matrixstats (1.2.0-1) ... 168s Selecting previously unselected package r-cran-r.methodss3. 168s Preparing to unpack .../78-r-cran-r.methodss3_1.8.2-1_all.deb ... 168s Unpacking r-cran-r.methodss3 (1.8.2-1) ... 168s Selecting previously unselected package r-cran-r.oo. 168s Preparing to unpack .../79-r-cran-r.oo_1.26.0-1_all.deb ... 168s Unpacking r-cran-r.oo (1.26.0-1) ... 168s Selecting previously unselected package r-cran-r.utils. 168s Preparing to unpack .../80-r-cran-r.utils_2.12.3-1_all.deb ... 168s Unpacking r-cran-r.utils (2.12.3-1) ... 168s Selecting previously unselected package r-cran-r.cache. 168s Preparing to unpack .../81-r-cran-r.cache_0.16.0-1_all.deb ... 168s Unpacking r-cran-r.cache (0.16.0-1) ... 168s Selecting previously unselected package r-cran-r.devices. 168s Preparing to unpack .../82-r-cran-r.devices_2.17.2+ds-1_all.deb ... 168s Unpacking r-cran-r.devices (2.17.2+ds-1) ... 168s Selecting previously unselected package tcl8.6. 168s Preparing to unpack .../83-tcl8.6_8.6.14+dfsg-1build1_amd64.deb ... 168s Unpacking tcl8.6 (8.6.14+dfsg-1build1) ... 168s Selecting previously unselected package tcl. 168s Preparing to unpack .../84-tcl_8.6.14build1_amd64.deb ... 168s Unpacking tcl (8.6.14build1) ... 168s Selecting previously unselected package r-cran-r.rsp. 168s Preparing to unpack .../85-r-cran-r.rsp_0.46.0+ds-1_all.deb ... 168s Unpacking r-cran-r.rsp (0.46.0+ds-1) ... 168s Selecting previously unselected package autopkgtest-satdep. 168s Preparing to unpack .../86-1-autopkgtest-satdep.deb ... 168s Unpacking autopkgtest-satdep (0) ... 168s Setting up libgraphite2-3:amd64 (1.3.14-2build1) ... 168s Setting up libpixman-1-0:amd64 (0.42.2-1build1) ... 168s Setting up libpaper1:amd64 (1.1.29build1) ... 168s 168s Creating config file /etc/papersize with new version 168s Setting up fontconfig (2.15.0-1.1ubuntu2) ... 170s Regenerating fonts cache... done. 170s Setting up fonts-mathjax (2.7.9+dfsg-1) ... 170s Setting up libjs-mathjax (2.7.9+dfsg-1) ... 170s Setting up libxrender1:amd64 (1:0.9.10-1.1build1) ... 170s Setting up libdatrie1:amd64 (0.2.13-3build1) ... 170s Setting up libxcb-render0:amd64 (1.17.0-2) ... 170s Setting up fonts-glyphicons-halflings (1.009~3.4.1+dfsg-3) ... 170s Setting up unzip (6.0-28ubuntu4) ... 170s Setting up x11-common (1:7.7+23ubuntu3) ... 171s Setting up libxcb-shm0:amd64 (1.17.0-2) ... 171s Setting up libpaper-utils (1.1.29build1) ... 171s Setting up libgomp1:amd64 (14.1.0-1ubuntu1) ... 171s Setting up libcairo2:amd64 (1.18.0-3build1) ... 171s Setting up zip (3.0-13build1) ... 171s Setting up libblas3:amd64 (3.12.0-3build1) ... 171s update-alternatives: using /usr/lib/x86_64-linux-gnu/blas/libblas.so.3 to provide /usr/lib/x86_64-linux-gnu/libblas.so.3 (libblas.so.3-x86_64-linux-gnu) in auto mode 171s Setting up libtcl8.6:amd64 (8.6.14+dfsg-1build1) ... 171s Setting up libgfortran5:amd64 (14.1.0-1ubuntu1) ... 171s Setting up libjs-highlight.js (9.18.5+dfsg1-2) ... 171s Setting up libharfbuzz0b:amd64 (8.3.0-2build2) ... 171s Setting up libthai-data (0.1.29-2build1) ... 171s Setting up libxss1:amd64 (1:1.2.3-1build3) ... 171s Setting up libjs-jquery (3.6.1+dfsg+~3.5.14-1) ... 171s Setting up node-normalize.css (8.0.1-5) ... 171s Setting up xdg-utils (1.1.3-4.1ubuntu3) ... 171s update-alternatives: using /usr/bin/xdg-open to provide /usr/bin/open (open) in auto mode 171s Setting up libjs-bootstrap (3.4.1+dfsg-3) ... 171s Setting up libice6:amd64 (2:1.0.10-1build3) ... 171s Setting up tcl8.6 (8.6.14+dfsg-1build1) ... 171s Setting up liblapack3:amd64 (3.12.0-3build1) ... 171s update-alternatives: using /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3 to provide /usr/lib/x86_64-linux-gnu/liblapack.so.3 (liblapack.so.3-x86_64-linux-gnu) in auto mode 171s Setting up libxft2:amd64 (2.3.6-1build1) ... 171s Setting up libtk8.6:amd64 (8.6.14-1build1) ... 171s Setting up libjs-jquery-datatables (1.11.5+dfsg-2) ... 171s Setting up libthai0:amd64 (0.1.29-2build1) ... 171s Setting up tcl (8.6.14build1) ... 171s Setting up libsm6:amd64 (2:1.2.3-1build3) ... 171s Setting up libpango-1.0-0:amd64 (1.52.2+ds-1) ... 171s Setting up libxt6t64:amd64 (1:1.2.1-1.2build1) ... 171s Setting up libpangoft2-1.0-0:amd64 (1.52.2+ds-1) ... 171s Setting up libpangocairo-1.0-0:amd64 (1.52.2+ds-1) ... 171s Setting up r-base-core (4.4.0-2) ... 171s 171s Creating config file /etc/R/Renviron with new version 171s Setting up r-cran-labeling (0.4.3-1) ... 171s Setting up r-cran-lattice (0.22-6-1) ... 171s Setting up r-cran-nlme (3.1.164-1build1) ... 171s Setting up r-cran-farver (2.1.1-2) ... 171s Setting up r-cran-viridislite (0.4.2-2) ... 171s Setting up r-cran-commonmark (1.9.1-1) ... 171s Setting up r-cran-r6 (2.5.1-1) ... 171s Setting up r-cran-magrittr (2.0.3-1) ... 171s Setting up r-cran-rlang (1.1.3-1) ... 171s Setting up r-cran-matrixstats (1.2.0-1) ... 171s Setting up r-cran-xfun (0.44+dfsg-1) ... 171s Setting up r-cran-withr (2.5.0-1) ... 171s Setting up r-cran-base64enc (0.1-3-3) ... 171s Setting up r-cran-digest (0.6.35-1) ... 171s Setting up r-cran-yaml (2.3.8-2) ... 171s Setting up r-cran-evaluate (0.23-1) ... 171s Setting up r-cran-highr (0.10+dfsg-2) ... 171s Setting up r-cran-fansi (1.0.5-1) ... 171s Setting up r-cran-mass (7.3-60.2-1) ... 171s Setting up r-cran-glue (1.7.0-1) ... 171s Setting up r-cran-cli (3.6.2-1) ... 171s Setting up r-cran-lifecycle (1.0.4+dfsg-1) ... 171s Setting up r-cran-r.methodss3 (1.8.2-1) ... 171s Setting up r-cran-pkgconfig (2.0.3-2build1) ... 171s Setting up r-cran-utf8 (1.2.4-1) ... 171s Setting up r-cran-colorspace (2.1-0+dfsg-1) ... 171s Setting up r-cran-markdown (1.12+dfsg-2) ... 171s Setting up r-cran-rcolorbrewer (1.1-3-1build1) ... 171s Setting up r-cran-isoband (0.2.7-1) ... 171s Setting up r-cran-gtable (0.3.4+dfsg-1) ... 171s Setting up r-cran-matrix (1.6-5-1) ... 171s Setting up r-cran-knitr (1.46+dfsg-1) ... 171s Setting up r-cran-mgcv (1.9-1-1) ... 171s Setting up r-cran-vctrs (0.6.5-1) ... 171s Setting up r-cran-pillar (1.9.0+dfsg-1) ... 171s Setting up r-cran-munsell (0.5.0-2build1) ... 171s Setting up r-cran-tibble (3.2.1+dfsg-2) ... 171s Setting up r-cran-r.oo (1.26.0-1) ... 171s Setting up r-cran-scales (1.3.0-1) ... 171s Setting up r-cran-r.utils (2.12.3-1) ... 171s Setting up r-cran-ggplot2 (3.5.1+dfsg-1) ... 171s Setting up r-cran-r.devices (2.17.2+ds-1) ... 171s Setting up r-cran-r.cache (0.16.0-1) ... 171s Setting up r-cran-r.rsp (0.46.0+ds-1) ... 171s Setting up autopkgtest-satdep (0) ... 171s Processing triggers for man-db (2.12.1-1) ... 172s Processing triggers for install-info (7.1-3build2) ... 172s Processing triggers for libc-bin (2.39-0ubuntu8.1) ... 177s (Reading database ... 85453 files and directories currently installed.) 177s Removing autopkgtest-satdep (0) ... 177s autopkgtest [09:42:47]: test run-unit-test: [----------------------- 177s 177s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 177s Copyright (C) 2024 The R Foundation for Statistical Computing 177s Platform: x86_64-pc-linux-gnu 177s 177s R is free software and comes with ABSOLUTELY NO WARRANTY. 177s You are welcome to redistribute it under certain conditions. 177s Type 'license()' or 'licence()' for distribution details. 177s 177s R is a collaborative project with many contributors. 177s Type 'contributors()' for more information and 177s 'citation()' on how to cite R or R packages in publications. 177s 177s Type 'demo()' for some demos, 'help()' for on-line help, or 177s 'help.start()' for an HTML browser interface to help. 177s Type 'q()' to quit R. 177s 177s > library("matrixStats") 177s > 177s > allocArray_R <- function(nrow, ncol, value = NA) { 177s + array(data = value, dim = dim) 177s + } 177s > 177s > values <- list( 177s + -1L, 0L, +1L, NA_integer_, .Machine$integer.max, 177s + -1, 0, +1, NA_real_, NaN, -Inf, +Inf, 177s + .Machine$double.xmin, .Machine$double.xmax, 177s + .Machine$double.eps, .Machine$double.neg.eps, 177s + FALSE, TRUE, NA 177s + ) 177s > 177s > dim <- c(2L, 4L, 3L) 177s > for (value in values) { 177s + x0 <- allocArray_R(dim, value = value) 177s + x <- allocArray(dim, value = value) 177s + if (!identical(x, x0)) { 177s + str(list(dim = dim, value = value, x = x, x0 = x0)) 177s + stopifnot(identical(x, x0)) 177s + } 177s + } 177s > 177s 177s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 177s Copyright (C) 2024 The R Foundation for Statistical Computing 177s Platform: x86_64-pc-linux-gnu 177s 177s R is free software and comes with ABSOLUTELY NO WARRANTY. 177s You are welcome to redistribute it under certain conditions. 177s Type 'license()' or 'licence()' for distribution details. 177s 177s R is a collaborative project with many contributors. 177s Type 'contributors()' for more information and 177s 'citation()' on how to cite R or R packages in publications. 177s 177s Type 'demo()' for some demos, 'help()' for on-line help, or 177s 'help.start()' for an HTML browser interface to help. 177s Type 'q()' to quit R. 177s 177s > library("matrixStats") 177s > 177s > allocMatrix_R <- function(nrow, ncol, value = NA) { 177s + matrix(data = value, nrow = nrow, ncol = ncol) 177s + } 177s > 177s > values <- list( 177s + -1L, 0L, +1L, NA_integer_, .Machine$integer.max, 177s + -1, 0, +1, NA_real_, NaN, -Inf, +Inf, 177s + .Machine$double.xmin, .Machine$double.xmax, 177s + .Machine$double.eps, .Machine$double.neg.eps, 177s + FALSE, TRUE, NA 177s + ) 177s > 177s > nrow <- 2L 177s > ncol <- 3L 177s > for (value in values) { 177s + x0 <- allocMatrix_R(nrow, ncol, value = value) 177s + x <- allocMatrix(nrow, ncol, value = value) 177s + if (!identical(x, x0)) { 177s + str(list(nrow = nrow, ncol = ncol, value = value, x = x, x0 = x0)) 177s + stopifnot(identical(x, x0)) 177s + } 177s + } 177s > 177s 177s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 177s Copyright (C) 2024 The R Foundation for Statistical Computing 177s Platform: x86_64-pc-linux-gnu 177s 177s R is free software and comes with ABSOLUTELY NO WARRANTY. 177s You are welcome to redistribute it under certain conditions. 177s Type 'license()' or 'licence()' for distribution details. 177s 177s R is a collaborative project with many contributors. 177s Type 'contributors()' for more information and 177s 'citation()' on how to cite R or R packages in publications. 177s 177s Type 'demo()' for some demos, 'help()' for on-line help, or 177s 'help.start()' for an HTML browser interface to help. 177s Type 'q()' to quit R. 177s 177s > library("matrixStats") 177s > 177s > allocVector_R <- function(length, value = NA) { 177s + x <- vector(mode = typeof(value), length = length) 177s + if (!is.finite(value) || value != 0) x[] <- value 177s + x 177s + } 177s > 177s > values <- list( 177s + -1L, 0L, +1L, NA_integer_, .Machine$integer.max, 177s + -1, 0, +1, NA_real_, NaN, -Inf, +Inf, 177s + .Machine$double.xmin, .Machine$double.xmax, 177s + .Machine$double.eps, .Machine$double.neg.eps, 177s + FALSE, TRUE, NA 177s + ) 177s > 177s > n <- 10L 177s > for (value in values) { 177s + x0 <- allocVector_R(n, value = value) 177s + x <- allocVector(n, value = value) 177s + if (!identical(x, x0)) { 177s + str(list(n = n, value = value, x = x, x0 = x0)) 177s + stopifnot(identical(x, x0)) 177s + } 177s + } 178s > 178s 178s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 178s Copyright (C) 2024 The R Foundation for Statistical Computing 178s Platform: x86_64-pc-linux-gnu 178s 178s R is free software and comes with ABSOLUTELY NO WARRANTY. 178s You are welcome to redistribute it under certain conditions. 178s Type 'license()' or 'licence()' for distribution details. 178s 178s R is a collaborative project with many contributors. 178s Type 'contributors()' for more information and 178s 'citation()' on how to cite R or R packages in publications. 178s 178s Type 'demo()' for some demos, 'help()' for on-line help, or 178s 'help.start()' for an HTML browser interface to help. 178s Type 'q()' to quit R. 178s 178s > library("matrixStats") 178s > 178s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 178s > # Setup 178s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 178s > data <- data.frame( 178s + logical = c(TRUE, FALSE, TRUE), 178s + integer = 1:3, 178s + double = seq(from = 1.0, to = 3.0, by = 1.0), 178s + complex = seq(from = 1.0, to = 3.0, by = 1.0) + 1.0i, 178s + character = letters[1:3], 178s + stringsAsFactors = FALSE 178s + ) 178s > 178s > modes <- names(data) 178s > 178s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 178s > # Special cases 178s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 178s > cat("NULL...\n") 178s NULL... 178s > stopifnot(identical(anyMissing(NULL), FALSE)) 178s > cat("NULL...done\n") 178s NULL...done 178s > 178s > cat("raw...\n") 178s raw... 178s > stopifnot(identical(anyMissing(as.raw(0:2)), FALSE)) 178s > cat("raw...done\n") 178s raw...done 178s > 178s > cat("list(NULL)...\n") 178s list(NULL)... 178s > stopifnot(identical(anyMissing(list(NULL)), FALSE)) 178s > cat("list(NULL)...done\n") 178s list(NULL)...done 178s > 178s > 178s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 178s > # Scalars, vectors, and matrices of various modes 178s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 178s > for (mode in modes) { 178s + cat(sprintf("Mode: %s...\n", mode)) 178s + values <- data[[mode]] 178s + 178s + # Scalars 178s + cat(" scalar\n") 178s + x <- values[1L] 178s + print(x) 178s + stopifnot(identical(anyMissing(x), FALSE)) 178s + is.na(x) <- TRUE 178s + print(x) 178s + stopifnot(identical(anyMissing(x), TRUE)) 178s + 178s + # Vectors 178s + cat(" vector\n") 178s + x <- values 178s + print(x) 178s + stopifnot(identical(anyMissing(x), FALSE)) 178s + is.na(x)[2L] <- TRUE 178s + print(x) 178s + stopifnot(identical(anyMissing(x), TRUE)) 178s + 178s + # Matrices 178s + cat(" matrix\n") 178s + x <- matrix(c(values, values), ncol = 2L) 178s + print(x) 178s + stopifnot(identical(anyMissing(x), FALSE)) 178s + is.na(x)[2L] <- TRUE 178s + print(x) 178s + stopifnot(identical(anyMissing(x), TRUE)) 178s + 178s + cat(sprintf("Mode: %s...done\n", mode)) 178s + } # for (mode ...) 178s Mode: logical... 178s scalar 178s [1] TRUE 178s [1] NA 178s vector 178s [1] TRUE FALSE TRUE 178s [1] TRUE NA TRUE 178s matrix 178s [,1] [,2] 178s [1,] TRUE TRUE 178s [2,] FALSE FALSE 178s [3,] TRUE TRUE 178s [,1] [,2] 178s [1,] TRUE TRUE 178s [2,] NA FALSE 178s [3,] TRUE TRUE 178s Mode: logical...done 178s Mode: integer... 178s scalar 178s [1] 1 178s [1] NA 178s vector 178s [1] 1 2 3 178s [1] 1 NA 3 178s matrix 178s [,1] [,2] 178s [1,] 1 1 178s [2,] 2 2 178s [3,] 3 3 178s [,1] [,2] 178s [1,] 1 1 178s [2,] NA 2 178s [3,] 3 3 178s Mode: integer...done 178s Mode: double... 178s scalar 178s [1] 1 178s [1] NA 178s vector 178s [1] 1 2 3 178s [1] 1 NA 3 178s matrix 178s [,1] [,2] 178s [1,] 1 1 178s [2,] 2 2 178s [3,] 3 3 178s [,1] [,2] 178s [1,] 1 1 178s [2,] NA 2 178s [3,] 3 3 178s Mode: double...done 178s Mode: complex... 178s scalar 178s [1] 1+1i 178s [1] NA 178s vector 178s [1] 1+1i 2+1i 3+1i 178s [1] 1+1i NA 3+1i 178s matrix 178s [,1] [,2] 178s [1,] 1+1i 1+1i 178s [2,] 2+1i 2+1i 178s [3,] 3+1i 3+1i 178s [,1] [,2] 178s [1,] 1+1i 1+1i 178s [2,] NA 2+1i 178s [3,] 3+1i 3+1i 178s Mode: complex...done 178s Mode: character... 178s scalar 178s [1] "a" 178s [1] NA 178s vector 178s [1] "a" "b" "c" 178s [1] "a" NA "c" 178s matrix 178s [,1] [,2] 178s [1,] "a" "a" 178s [2,] "b" "b" 178s [3,] "c" "c" 178s [,1] [,2] 178s [1,] "a" "a" 178s [2,] NA "b" 178s [3,] "c" "c" 178s Mode: character...done 178s > 178s > 178s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 178s > # Data frames 178s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 178s > cat("data.frame...\n") 178s data.frame... 178s > x <- data 178s > stopifnot(identical(anyMissing(x), FALSE)) 178s > for (mode in modes) { 178s + x <- data 178s + is.na(x[[mode]])[2L] <- TRUE 178s + print(x) 178s + stopifnot(identical(anyMissing(x), TRUE)) 178s + } # for (mode ...) 178s logical integer double complex character 178s 1 TRUE 1 1 1+1i a 178s 2 NA 2 2 2+1i b 178s 3 TRUE 3 3 3+1i c 178s logical integer double complex character 178s 1 TRUE 1 1 1+1i a 178s 2 FALSE NA 2 2+1i b 178s 3 TRUE 3 3 3+1i c 178s logical integer double complex character 178s 1 TRUE 1 1 1+1i a 178s 2 FALSE 2 NA 2+1i b 178s 3 TRUE 3 3 3+1i c 178s logical integer double complex character 178s 1 TRUE 1 1 1+1i a 178s 2 FALSE 2 2 NA b 178s 3 TRUE 3 3 3+1i c 178s logical integer double complex character 178s 1 TRUE 1 1 1+1i a 178s 2 FALSE 2 2 2+1i 178s 3 TRUE 3 3 3+1i c 178s > cat("data.frame...done\n") 178s data.frame...done 178s > 178s > 178s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 178s > # Lists 178s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 178s > cat("list...\n") 178s list... 178s > x <- as.list(data) 178s > stopifnot(identical(anyMissing(x), FALSE)) 178s > for (mode in modes) { 178s + x <- as.list(data) 178s + is.na(x[[mode]])[2L] <- TRUE 178s + print(x) 178s + stopifnot(identical(anyMissing(x), TRUE)) 178s + } # for (mode ...) 178s $logical 178s [1] TRUE NA TRUE 178s 178s $integer 178s [1] 1 2 3 178s 178s $double 178s [1] 1 2 3 178s 178s $complex 178s [1] 1+1i 2+1i 3+1i 178s 178s $character 178s [1] "a" "b" "c" 178s 178s $logical 178s [1] TRUE FALSE TRUE 178s 178s $integer 178s [1] 1 NA 3 178s 178s $double 178s [1] 1 2 3 178s 178s $complex 178s [1] 1+1i 2+1i 3+1i 178s 178s $character 178s [1] "a" "b" "c" 178s 178s $logical 178s [1] TRUE FALSE TRUE 178s 178s $integer 178s [1] 1 2 3 178s 178s $double 178s [1] 1 NA 3 178s 178s $complex 178s [1] 1+1i 2+1i 3+1i 178s 178s $character 178s [1] "a" "b" "c" 178s 178s $logical 178s [1] TRUE FALSE TRUE 178s 178s $integer 178s [1] 1 2 3 178s 178s $double 178s [1] 1 2 3 178s 178s $complex 178s [1] 1+1i NA 3+1i 178s 178s $character 178s [1] "a" "b" "c" 178s 178s $logical 178s [1] TRUE FALSE TRUE 178s 178s $integer 178s [1] 1 2 3 178s 178s $double 178s [1] 1 2 3 178s 178s $complex 178s [1] 1+1i 2+1i 3+1i 178s 178s $character 178s [1] "a" NA "c" 178s 178s > cat("list...done\n") 178s list...done 178s > 178s 178s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 178s Copyright (C) 2024 The R Foundation for Statistical Computing 178s Platform: x86_64-pc-linux-gnu 178s 178s R is free software and comes with ABSOLUTELY NO WARRANTY. 178s You are welcome to redistribute it under certain conditions. 178s Type 'license()' or 'licence()' for distribution details. 178s 178s R is a collaborative project with many contributors. 178s Type 'contributors()' for more information and 178s 'citation()' on how to cite R or R packages in publications. 178s 178s Type 'demo()' for some demos, 'help()' for on-line help, or 178s 'help.start()' for an HTML browser interface to help. 178s Type 'q()' to quit R. 178s 178s > library("matrixStats") 178s > 178s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 178s > # Subsetted tests 178s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 178s > source("utils/validateIndicesFramework.R") 178s > x <- runif(4, min = -3, max = 3) 178s > x[2] <- NA 178s > for (mode in c("integer", "numeric")) { 178s + storage.mode(x) <- mode 178s + for (idxs in index_cases) { 178s + validateIndicesTestVector(x, idxs, 178s + ftest = anyMissing, fsure = function(x, ...) { 178s + anyValue(x, value = NA) 178s + }) 178s + } 178s + } 178s > 178s 178s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 178s Copyright (C) 2024 The R Foundation for Statistical Computing 178s Platform: x86_64-pc-linux-gnu 178s 178s R is free software and comes with ABSOLUTELY NO WARRANTY. 178s You are welcome to redistribute it under certain conditions. 178s Type 'license()' or 'licence()' for distribution details. 178s 178s R is a collaborative project with many contributors. 178s Type 'contributors()' for more information and 178s 'citation()' on how to cite R or R packages in publications. 178s 178s Type 'demo()' for some demos, 'help()' for on-line help, or 178s 'help.start()' for an HTML browser interface to help. 178s Type 'q()' to quit R. 178s 178s > ## 1. Don't test with valgrind 178s > ## 2. Test only R (>= 3.0.2) because of that's what knitr requires 178s > if (getRversion() >= "3.0.2" && Sys.getenv("_R_CHECK_USE_VALGRIND_") == "") { 178s + 178s + ## 3. Make sure all suggested packages are installed / can be loaded 178s + pkgs <- c("base64enc", "ggplot2", "knitr", "markdown", "microbenchmark", 178s + "R.devices", "R.rsp") 178s + if (all(unlist(lapply(pkgs, FUN = requireNamespace)))) { 178s + html <- matrixStats:::benchmark("binCounts") 178s + print(html) 178s + } 178s + 178s + rm(list = "pkgs") 178s + 178s + } 178s Loading required namespace: base64enc 178s Loading required namespace: ggplot2 179s Loading required namespace: knitr 179s Loading required namespace: markdown 179s Loading required namespace: microbenchmark 179s Failed with error: ‘there is no package called ‘microbenchmark’’ 179s Loading required namespace: R.devices 179s Loading required namespace: R.rsp 179s > 179s 179s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 179s Copyright (C) 2024 The R Foundation for Statistical Computing 179s Platform: x86_64-pc-linux-gnu 179s 179s R is free software and comes with ABSOLUTELY NO WARRANTY. 179s You are welcome to redistribute it under certain conditions. 179s Type 'license()' or 'licence()' for distribution details. 179s 179s R is a collaborative project with many contributors. 179s Type 'contributors()' for more information and 179s 'citation()' on how to cite R or R packages in publications. 179s 179s Type 'demo()' for some demos, 'help()' for on-line help, or 179s 'help.start()' for an HTML browser interface to help. 179s Type 'q()' to quit R. 179s 179s > library("matrixStats") 179s > library("stats") 179s > 179s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 179s > # Local functions 179s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 179s > binCounts_hist <- function(x, bx, right = FALSE, ...) { 179s + n0 <- graphics::hist(x, breaks = bx, right = right, 179s + include.lowest = TRUE, plot = FALSE)$counts 179s + } 179s > 179s > 179s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 179s > # Non-sorted and sorted positions 179s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 179s > nx <- 1000L # Number of data points 179s > nb <- 200L # Number of bins 179s > 179s > # Uniformely distributed bins 179s > bx <- seq(from = 0, to = 1, length.out = nb + 1L) 179s > bx <- c(-1, bx, 2) 179s > 179s > # Sample data points 179s > set.seed(0xBEEF) 179s > x <- runif(nx, min = 0, max = 1) 179s > 179s > for (kk in 1:2) { 179s + n0 <- binCounts_hist(x, bx = bx) 179s + n1 <- binCounts(x, bx = bx) 179s + # Sanity check 179s + stopifnot(identical(n1, n0)) 179s + 179s + # Check reversed 179s + n1r <- rev(binCounts(-x, bx = rev(-bx), right = TRUE)) 179s + stopifnot(identical(n1r, n1)) 179s + 179s + # Retry with a sorted vector 179s + x <- sort(x) 179s + } # for (kk in 1:2) 179s > 179s > 179s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 179s > # Missing values 179s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 179s > x <- 1:40 179s > x[20] <- NA_integer_ 179s > nx <- length(x) 179s > 179s > # Bins 179s > bx <- c(0.5, 50.5, 100.5, 150.5, 200.5) 179s > 179s > y_smooth0 <- binCounts_hist(x, bx = bx) 179s > y_smooth <- binCounts(x, bx = bx) 179s > # Sanity check 179s > stopifnot(all.equal(y_smooth, y_smooth0)) 179s > 179s > 179s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 179s > # Border cases 179s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 179s > x <- 1:10 179s > bx <- min(x) - c(10, 1) 179s > y_smooth <- binCounts(x, bx = bx) 179s > stopifnot(all.equal(y_smooth, 0L)) 179s > bx <- range(x) 179s > y_smooth <- binCounts(x, bx = bx) 179s > stopifnot(all.equal(y_smooth, length(x) - 1L)) 179s > bx <- max(x) + c(1, 10) 179s > y_smooth <- binCounts(x, bx = bx) 179s > stopifnot(all.equal(y_smooth, 0L)) 179s > 179s > # Every second empty 179s > x <- 1:10 179s > bx <- rep(x, each = 2L) 179s > y_smooth <- binCounts(x, bx = bx) 179s > stopifnot(all.equal(y_smooth, rep(c(0L, 1L), length.out = length(bx) - 1L))) 179s > ## NOTE: binCounts_hist() does not give the same last bin count 179s > 179s > 179s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 179s > # Exception handling 179s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 179s > # Zero bin bounderies (invalid bin definition) 179s > bx <- double(0L) 179s > res <- try(y_smooth <- binCounts(1:10, bx = bx), silent = TRUE) 179s > stopifnot(inherits(res, "try-error")) 179s > 179s > # One bin boundery (invalid bin definition) 179s > bx <- double(1L) 179s > res <- try(y_smooth <- binCounts(1:10, bx = bx), silent = TRUE) 179s > stopifnot(inherits(res, "try-error")) 179s > 179s 179s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 179s Copyright (C) 2024 The R Foundation for Statistical Computing 179s Platform: x86_64-pc-linux-gnu 179s 179s R is free software and comes with ABSOLUTELY NO WARRANTY. 179s You are welcome to redistribute it under certain conditions. 179s Type 'license()' or 'licence()' for distribution details. 179s 179s R is a collaborative project with many contributors. 179s Type 'contributors()' for more information and 179s 'citation()' on how to cite R or R packages in publications. 179s 179s Type 'demo()' for some demos, 'help()' for on-line help, or 179s 'help.start()' for an HTML browser interface to help. 179s Type 'q()' to quit R. 179s 179s > library("matrixStats") 179s > 179s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 179s > # Local functions 179s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 179s > binCounts_hist <- function(x, bx, right = FALSE, ...) { 179s + n0 <- graphics::hist(x, breaks = bx, right = right, 179s + include.lowest = TRUE, plot = FALSE)$counts 179s + } 179s > 179s > 179s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 179s > # Subsetted tests 179s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 179s > source("utils/validateIndicesFramework.R") 179s > x <- runif(6, min = -6, max = 6) 179s > storage.mode(x) <- "integer" 179s > bx <- c(-6, 0, 3, 4, 10) 179s > for (idxs in index_cases) { 179s + validateIndicesTestVector(x, idxs, 179s + ftest = binCounts, fsure = binCounts_hist, 179s + bx = bx, right = FALSE) 179s + validateIndicesTestVector(x, idxs, 179s + ftest = binCounts, fsure = binCounts_hist, 179s + bx = bx, right = TRUE) 179s + } 179s > 179s 179s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 179s Copyright (C) 2024 The R Foundation for Statistical Computing 179s Platform: x86_64-pc-linux-gnu 179s 179s R is free software and comes with ABSOLUTELY NO WARRANTY. 179s You are welcome to redistribute it under certain conditions. 179s Type 'license()' or 'licence()' for distribution details. 179s 179s R is a collaborative project with many contributors. 179s Type 'contributors()' for more information and 179s 'citation()' on how to cite R or R packages in publications. 179s 179s Type 'demo()' for some demos, 'help()' for on-line help, or 179s 'help.start()' for an HTML browser interface to help. 179s Type 'q()' to quit R. 179s 180s > library("matrixStats") 180s > library("stats") 180s > 180s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 180s > # Naive R implementation of binMeans() 180s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 180s > binMeans0 <- function(y, x, bx, na.rm = TRUE, count = TRUE, right = FALSE) { 180s + n_smooth <- length(bx) - 1L 180s + res <- double(n_smooth) 180s + counts <- rep(NaN, times = n_smooth) 180s + 180s + if (na.rm) { 180s + keep <- !is.na(x) & !is.na(y) 180s + x <- x[keep] 180s + y <- y[keep] 180s + } 180s + 180s + # For each bin... 180s + for (kk in seq_len(n_smooth)) { 180s + if (right) { 180s + idxs <- which(bx[kk] < x & x <= bx[kk + 1L]) 180s + } else { 180s + idxs <- which(bx[kk] <= x & x < bx[kk + 1L]) 180s + } 180s + y_kk <- y[idxs] 180s + res[kk] <- mean(y_kk) 180s + counts[kk] <- length(idxs) 180s + } # for (kk ...) 180s + 180s + if (count) attr(res, "count") <- counts 180s + res 180s + } 180s > 180s > 180s > 180s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 180s > # Case #1 180s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 180s > x <- 1:100 180s > nx <- length(x) 180s > y <- double(nx) 180s > y[1:25] <- 5 180s > y[51:75] <- -5 180s > y <- y + rnorm(nx) 180s > 180s > # Bins 180s > bx <- c(0.5, 25.5, 50.5, 75.5, 100.5) 180s > 180s > y_smooth0 <- binMeans0(y, x = x, bx = bx) 180s > y_smooth <- binMeans(y, x = x, bx = bx) 180s > n_smooth <- binCounts(x, bx = bx) 180s > # Sanity check 180s > stopifnot(all.equal(y_smooth, y_smooth0)) 180s > stopifnot(all.equal(attr(y_smooth, "count"), n_smooth)) 180s > 180s > y_smooth0r <- rev(binMeans0(y, x = -x, bx = rev(-bx), 180s + count = FALSE, right = TRUE)) 180s > y_smoothr <- rev(binMeans(y, x = -x, bx = rev(-bx), 180s + count = FALSE, right = TRUE)) 180s > # Sanity check 180s > stopifnot(all.equal(y_smooth0r, y_smooth0, check.attributes = FALSE)) 180s > stopifnot(all.equal(y_smoothr, y_smooth0r)) 180s > 180s > 180s > # Integer input 180s > y <- as.integer(y) 180s > y_smooth0 <- binMeans0(y, x = x, bx = bx) 180s > y_smooth <- binMeans(y, x = x, bx = bx) 180s > n_smooth <- binCounts(x, bx = bx) 180s > # Sanity check 180s > stopifnot(is.integer(y), 180s + all.equal(y_smooth, y_smooth0), 180s + all.equal(attr(y_smooth, "count"), n_smooth)) 180s > 180s > # Logical input 180s > y <- as.logical(y) 180s > y_smooth0 <- binMeans0(y, x = x, bx = bx) 180s > y_smooth <- binMeans(y, x = x, bx = bx) 180s > n_smooth <- binCounts(x, bx = bx) 180s > # Sanity check 180s > stopifnot(is.logical(y), 180s + all.equal(y_smooth, y_smooth0), 180s + all.equal(attr(y_smooth, "count"), n_smooth)) 180s > 180s > 180s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 180s > # Case #2 180s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 180s > nx <- 1e3 180s > x <- runif(nx) 180s > y <- runif(nx) 180s > 180s > nb <- 10 180s > bx <- do.call(seq, c(as.list(range(x)), length.out = nb)) 180s > bx1 <- c(bx[-1], bx[nb] + 1) 180s > 180s > y_smooth0 <- binMeans0(y, x = x, bx = bx1) 180s > y_smooth <- binMeans(y, x = x, bx = bx1) 180s > n_smooth <- binCounts(x, bx = bx1) 180s > y_smoothr <- rev(binMeans(y, x = -x, bx = rev(-bx1), right = TRUE)) 180s > 180s > # Sanity check 180s > stopifnot(all.equal(y_smooth, y_smooth0)) 180s > stopifnot(all.equal(attr(y_smooth, "count"), n_smooth)) 180s > stopifnot(all.equal(y_smoothr, y_smooth, check.attributes = FALSE)) 180s > 180s > 180s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 180s > # Empty bins 180s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 180s > x <- c(6:8, 16:19) 180s > nx <- length(x) 180s > y <- runif(nx) 180s > bx <- c(0, 5, 10, 15, 20, 25) 180s > y_smooth0 <- binMeans0(y, x = x, bx = bx) 180s > y_smooth <- binMeans(y, x = x, bx = bx) 180s > n_smooth <- binCounts(x, bx = bx) 180s > stopifnot(all.equal(attr(y_smooth, "count"), n_smooth)) 180s > stopifnot(all.equal(y_smooth, y_smooth0)) 180s > 180s > 180s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 180s > # Missing values 180s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 180s > x <- 1:100 180s > x[50] <- NA_integer_ 180s > nx <- length(x) 180s > y <- double(nx) 180s > y[1:25] <- 5 180s > y[51:75] <- -5 180s > y[82:92] <- NA_real_ 180s > y <- y + rnorm(nx) 180s > 180s > # Bins 180s > bx <- c(0.5, 25.5, 75.5, 82.5, 100.5) 180s > 180s > y_smooth0 <- binMeans0(y, x = x, bx = bx) 180s > y_smooth <- binMeans(y, x = x, bx = bx) 180s > # Sanity check 180s > stopifnot(all.equal(y_smooth, y_smooth0)) 180s > 180s > 180s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 180s > # Exception handling 180s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 180s > # Zero bin bounderies (invalid bin definition) 180s > bx <- double(0L) 180s > res <- try(y_smooth <- binMeans(x = 1:5, y = 1:5, bx = bx), silent = TRUE) 180s > stopifnot(inherits(res, "try-error")) 180s > 180s > # One bin boundery (invalid bin definition) 180s > bx <- double(1L) 180s > res <- try(y_smooth <- binMeans(x = 1:5, y = 1:5, bx = bx), silent = TRUE) 180s > stopifnot(inherits(res, "try-error")) 180s > 180s 180s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 180s Copyright (C) 2024 The R Foundation for Statistical Computing 180s Platform: x86_64-pc-linux-gnu 180s 180s R is free software and comes with ABSOLUTELY NO WARRANTY. 180s You are welcome to redistribute it under certain conditions. 180s Type 'license()' or 'licence()' for distribution details. 180s 180s R is a collaborative project with many contributors. 180s Type 'contributors()' for more information and 180s 'citation()' on how to cite R or R packages in publications. 180s 180s Type 'demo()' for some demos, 'help()' for on-line help, or 180s 'help.start()' for an HTML browser interface to help. 180s Type 'q()' to quit R. 180s 180s > library("matrixStats") 180s > 180s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 180s > # Naive R implementation of binMeans() 180s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 180s > binMeans0 <- function(y, x, bx, na.rm = TRUE, count = TRUE, right = FALSE) { 180s + n_smooth <- length(bx) - 1L 180s + res <- double(n_smooth) 180s + counts <- rep(NaN, times = n_smooth) 180s + 180s + if (na.rm) { 180s + keep <- !is.na(x) & !is.na(y) 180s + x <- x[keep] 180s + y <- y[keep] 180s + } 180s + 180s + # For each bin... 180s + for (kk in seq_len(n_smooth)) { 180s + if (right) { 180s + idxs <- which(bx[kk] < x & x <= bx[kk + 1L]) 180s + } else { 180s + idxs <- which(bx[kk] <= x & x < bx[kk + 1L]) 180s + } 180s + y_kk <- y[idxs] 180s + res[kk] <- mean(y_kk) 180s + counts[kk] <- length(idxs) 180s + } # for (kk ...) 180s + 180s + if (count) attr(res, "count") <- counts 180s + res 180s + } 180s > 180s > 180s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 180s > # Subsetted tests 180s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 180s > source("utils/validateIndicesFramework.R") 180s > y <- runif(6, min = -6, max = 6) 180s > x <- runif(6, min = -6, max = 6) 180s > storage.mode(x) <- "integer" 180s > bx <- c(-6, 0, 3, 4, 10) 180s > for (idxs in index_cases) { 180s + for (na.rm in c(TRUE, FALSE)) { 180s + validateIndicesTestVector_w(y, x, idxs, 180s + ftest = binMeans, fsure = binMeans0, 180s + bx = bx, na.rm = na.rm, 180s + count = TRUE, right = FALSE) 180s + validateIndicesTestVector_w(y, x, idxs, 180s + ftest = binMeans, fsure = binMeans0, 180s + bx = bx, na.rm = na.rm, 180s + count = TRUE, right = TRUE) 180s + } 180s + } 180s > 180s 180s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 180s Copyright (C) 2024 The R Foundation for Statistical Computing 180s Platform: x86_64-pc-linux-gnu 180s 180s R is free software and comes with ABSOLUTELY NO WARRANTY. 180s You are welcome to redistribute it under certain conditions. 180s Type 'license()' or 'licence()' for distribution details. 180s 180s R is a collaborative project with many contributors. 180s Type 'contributors()' for more information and 180s 'citation()' on how to cite R or R packages in publications. 180s 180s Type 'demo()' for some demos, 'help()' for on-line help, or 180s 'help.start()' for an HTML browser interface to help. 180s Type 'q()' to quit R. 180s 180s > library("matrixStats") 180s > 180s > count_R <- function(x, value = TRUE, na.rm = FALSE, ...) { 180s + if (is.na(value)) { 180s + counts <- sum(is.na(x)) 180s + } else { 180s + counts <- sum(x == value, na.rm = na.rm) 180s + } 180s + as.integer(counts) 180s + } 180s > 180s > 180s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 180s > # Data type: integer and numeric 180s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 180s > for (mode in c("integer", "double")) { 180s + x <- runif(20 * 5, min = -3, max = 3) 180s + x[sample.int(length(x), size = 7)] <- 0 180s + storage.mode(x) <- mode 180s + 180s + for (na.rm in c(FALSE, TRUE)) { 180s + # Count zeros 180s + n0 <- count_R(x, value = 0, na.rm = na.rm) 180s + n1 <- count(x, value = 0, na.rm = na.rm) 180s + stopifnot(identical(n1, n0)) 180s + all <- allValue(x, value = 0, na.rm = na.rm) 180s + any <- anyValue(x, value = 0, na.rm = na.rm) 180s + 180s + # Count NAs 180s + n0 <- count_R(x, value = NA, na.rm = na.rm) 180s + n1 <- count(x, value = NA, na.rm = na.rm) 180s + stopifnot(identical(n1, n0)) 180s + all <- allValue(x, value = NA, na.rm = na.rm) 180s + any <- anyValue(x, value = NA, na.rm = na.rm) 180s + 180s + if (mode == "integer") { 180s + ux <- unique(as.vector(x)) 180s + n0 <- n1 <- integer(length(x)) 180s + for (value in ux) { 180s + n0 <- n0 + count_R(x, value = value, na.rm = na.rm) 180s + n1 <- n1 + count(x, value = value, na.rm = na.rm) 180s + stopifnot(identical(n1, n0)) 180s + } 180s + stopifnot(all(n0 == ncol(x))) 180s + } # if (mode == "integer") 180s + 180s + } # for (na.rm ...) 180s + } # for (mode ...) 180s > 180s > # All NAs 180s > na_list <- list(NA_integer_, NA_real_, NaN) 180s > for (na_value in na_list) { 180s + x <- rep(na_value, times = 10L) 180s + for (na.rm in c(FALSE, TRUE)) { 180s + n0 <- count_R(x, na.rm = na.rm) 180s + n1 <- count(x, na.rm = na.rm) 180s + stopifnot(identical(n1, n0)) 180s + 180s + # Count NAs 180s + n0 <- count_R(x, value = NA, na.rm = na.rm) 180s + n1 <- count(x, value = NA, na.rm = na.rm) 180s + stopifnot(identical(n1, n0)) 180s + any <- anyValue(x, value = NA, na.rm = na.rm) 180s + all <- allValue(x, value = NA, na.rm = na.rm) 180s + stopifnot(any) 180s + stopifnot(all) 180s + } 180s + } # for (na_value ...) 180s > 180s > 180s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 180s > # Data type: logical 180s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 180s > x <- logical(length = 10L) 180s > x[3:7] <- TRUE 180s > 180s > # Row/column counts 180s > for (na.rm in c(FALSE, TRUE)) { 180s + n0 <- count_R(x, na.rm = na.rm) 180s + n1 <- count(x, na.rm = na.rm) 180s + stopifnot(identical(n1, n0)) 180s + 180s + n_true <- count(x, value = TRUE, na.rm = na.rm) 180s + n_false <- count(x, value = FALSE, na.rm = na.rm) 180s + stopifnot(n_true + n_false == ncol(x)) 180s + 180s + # Count NAs 180s + n0 <- count_R(x, value = NA, na.rm = na.rm) 180s + n1 <- count(x, value = NA, na.rm = na.rm) 180s + stopifnot(identical(n1, n0)) 180s + } 180s > 180s 180s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 180s Copyright (C) 2024 The R Foundation for Statistical Computing 180s Platform: x86_64-pc-linux-gnu 180s 180s R is free software and comes with ABSOLUTELY NO WARRANTY. 180s You are welcome to redistribute it under certain conditions. 180s Type 'license()' or 'licence()' for distribution details. 180s 180s R is a collaborative project with many contributors. 180s Type 'contributors()' for more information and 180s 'citation()' on how to cite R or R packages in publications. 180s 180s Type 'demo()' for some demos, 'help()' for on-line help, or 180s 'help.start()' for an HTML browser interface to help. 180s Type 'q()' to quit R. 180s 180s > library("matrixStats") 180s > 180s > count_R <- function(x, value = TRUE, na.rm = FALSE, ...) { 180s + if (is.na(value)) { 180s + counts <- sum(is.na(x)) 180s + } else { 180s + counts <- sum(x == value, na.rm = na.rm) 180s + } 180s + as.integer(counts) 180s + } 180s > 180s > 180s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 180s > # Subsetted tests 180s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 180s > source("utils/validateIndicesFramework.R") 180s > x <- runif(6, min = -3, max = 3) 180s > storage.mode(x) <- "integer" 180s > for (idxs in index_cases) { 180s + validateIndicesTestVector(x, idxs, 180s + ftest = count, fsure = count_R, 180s + value = 0, na.rm = TRUE) 180s + validateIndicesTestVector(x, idxs, 180s + ftest = count, fsure = count_R, 180s + value = 0, na.rm = FALSE) 180s + validateIndicesTestVector(x, idxs, 180s + ftest = count, fsure = count_R, 180s + value = NA_integer_) 180s + } 180s > 180s 180s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 180s Copyright (C) 2024 The R Foundation for Statistical Computing 180s Platform: x86_64-pc-linux-gnu 180s 180s R is free software and comes with ABSOLUTELY NO WARRANTY. 180s You are welcome to redistribute it under certain conditions. 180s Type 'license()' or 'licence()' for distribution details. 180s 180s R is a collaborative project with many contributors. 180s Type 'contributors()' for more information and 180s 'citation()' on how to cite R or R packages in publications. 180s 180s Type 'demo()' for some demos, 'help()' for on-line help, or 180s 'help.start()' for an HTML browser interface to help. 180s Type 'q()' to quit R. 180s 181s > library("matrixStats") 181s > 181s > diff2_R <- function(..., useNames = NA){ 181s + res <- diff(...) 181s + if (is.na(useNames) || !useNames) names(res) <- NULL 181s + res 181s + } 181s > 181s > set.seed(0x42) 181s > 181s > for (mode in c("integer", "double")) { 181s + x <- rnorm(10, sd = 5) 181s + storage.mode(x) <- mode 181s + str(x) 181s + 181s + for (has_na in c(FALSE, TRUE)) { 181s + for (setNames in c(TRUE, FALSE)) { 181s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 181s + if (has_na) { 181s + x[sample(1:10, size = 3)] <- NA 181s + } 181s + if (setNames) { 181s + names(x) <- LETTERS[1:10] 181s + } 181s + for (l in 1:3) { 181s + for (d in 1:4) { 181s + cat(sprintf("%s: NAs = %s, lag = %d, differences = %d, setNames = %d, useNames = %d\n", 181s + mode, has_na, l, d, setNames, useNames)) 181s + y0 <- diff2_R(x, lag = l, differences = d, useNames = useNames) 181s + str(y0) 181s + y1 <- diff2(x, lag = l, differences = d, useNames = useNames) 181s + str(y1) 181s + stopifnot(identical(y1, y0)) 181s + } 181s + } 181s + } 181s + } 181s + } # for (has_na ...) 181s + } 181s int [1:10] 11 1 2 0 -1 -3 -3 6 0 0 181s integer: NAs = FALSE, lag = 1, differences = 1, setNames = 1, useNames = 1 181s Named int [1:9] -10 1 -2 -1 -2 0 9 -6 0 181s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 181s Named int [1:9] -10 1 -2 -1 -2 0 9 -6 0 181s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 181s integer: NAs = FALSE, lag = 1, differences = 2, setNames = 1, useNames = 1 181s Named int [1:8] 11 -3 1 -1 2 9 -15 6 181s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 181s Named int [1:8] 11 -3 1 -1 2 9 -15 6 181s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 181s integer: NAs = FALSE, lag = 1, differences = 3, setNames = 1, useNames = 1 181s Named int [1:7] -14 4 -2 3 7 -24 21 181s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 181s Named int [1:7] -14 4 -2 3 7 -24 21 181s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 181s integer: NAs = FALSE, lag = 1, differences = 4, setNames = 1, useNames = 1 181s Named int [1:6] 18 -6 5 4 -31 45 181s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 181s Named int [1:6] 18 -6 5 4 -31 45 181s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 181s integer: NAs = FALSE, lag = 2, differences = 1, setNames = 1, useNames = 1 181s Named int [1:8] -9 -1 -3 -3 -2 9 3 -6 181s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 181s Named int [1:8] -9 -1 -3 -3 -2 9 3 -6 181s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 181s integer: NAs = FALSE, lag = 2, differences = 2, setNames = 1, useNames = 1 181s Named int [1:6] 6 -2 1 12 5 -15 181s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 181s Named int [1:6] 6 -2 1 12 5 -15 181s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 181s integer: NAs = FALSE, lag = 2, differences = 3, setNames = 1, useNames = 1 181s Named int [1:4] -5 14 4 -27 181s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 181s Named int [1:4] -5 14 4 -27 181s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 181s integer: NAs = FALSE, lag = 2, differences = 4, setNames = 1, useNames = 1 181s Named int [1:2] 9 -41 181s - attr(*, "names")= chr [1:2] "I" "J" 181s Named int [1:2] 9 -41 181s - attr(*, "names")= chr [1:2] "I" "J" 181s integer: NAs = FALSE, lag = 3, differences = 1, setNames = 1, useNames = 1 181s Named int [1:7] -11 -2 -5 -3 7 3 3 181s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 181s Named int [1:7] -11 -2 -5 -3 7 3 3 181s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 181s integer: NAs = FALSE, lag = 3, differences = 2, setNames = 1, useNames = 1 181s Named int [1:4] 8 9 8 6 181s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 181s Named int [1:4] 8 9 8 6 181s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 181s integer: NAs = FALSE, lag = 3, differences = 3, setNames = 1, useNames = 1 181s Named int -2 181s - attr(*, "names")= chr "J" 181s Named int -2 181s - attr(*, "names")= chr "J" 181s integer: NAs = FALSE, lag = 3, differences = 4, setNames = 1, useNames = 1 181s Named int(0) 181s - attr(*, "names")= chr(0) 181s Named int(0) 181s - attr(*, "names")= chr(0) 181s integer: NAs = FALSE, lag = 1, differences = 1, setNames = 1, useNames = 0 181s int [1:9] -10 1 -2 -1 -2 0 9 -6 0 181s int [1:9] -10 1 -2 -1 -2 0 9 -6 0 181s integer: NAs = FALSE, lag = 1, differences = 2, setNames = 1, useNames = 0 181s int [1:8] 11 -3 1 -1 2 9 -15 6 181s int [1:8] 11 -3 1 -1 2 9 -15 6 181s integer: NAs = FALSE, lag = 1, differences = 3, setNames = 1, useNames = 0 181s int [1:7] -14 4 -2 3 7 -24 21 181s int [1:7] -14 4 -2 3 7 -24 21 181s integer: NAs = FALSE, lag = 1, differences = 4, setNames = 1, useNames = 0 181s int [1:6] 18 -6 5 4 -31 45 181s int [1:6] 18 -6 5 4 -31 45 181s integer: NAs = FALSE, lag = 2, differences = 1, setNames = 1, useNames = 0 181s int [1:8] -9 -1 -3 -3 -2 9 3 -6 181s int [1:8] -9 -1 -3 -3 -2 9 3 -6 181s integer: NAs = FALSE, lag = 2, differences = 2, setNames = 1, useNames = 0 181s int [1:6] 6 -2 1 12 5 -15 181s int [1:6] 6 -2 1 12 5 -15 181s integer: NAs = FALSE, lag = 2, differences = 3, setNames = 1, useNames = 0 181s int [1:4] -5 14 4 -27 181s int [1:4] -5 14 4 -27 181s integer: NAs = FALSE, lag = 2, differences = 4, setNames = 1, useNames = 0 181s int [1:2] 9 -41 181s int [1:2] 9 -41 181s integer: NAs = FALSE, lag = 3, differences = 1, setNames = 1, useNames = 0 181s int [1:7] -11 -2 -5 -3 7 3 3 181s int [1:7] -11 -2 -5 -3 7 3 3 181s integer: NAs = FALSE, lag = 3, differences = 2, setNames = 1, useNames = 0 181s int [1:4] 8 9 8 6 181s int [1:4] 8 9 8 6 181s integer: NAs = FALSE, lag = 3, differences = 3, setNames = 1, useNames = 0 181s int -2 181s int -2 181s integer: NAs = FALSE, lag = 3, differences = 4, setNames = 1, useNames = 0 181s int(0) 181s int(0) 181s integer: NAs = FALSE, lag = 1, differences = 1, setNames = 0, useNames = 1 181s Named int [1:9] -10 1 -2 -1 -2 0 9 -6 0 181s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 181s Named int [1:9] -10 1 -2 -1 -2 0 9 -6 0 181s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 181s integer: NAs = FALSE, lag = 1, differences = 2, setNames = 0, useNames = 1 181s Named int [1:8] 11 -3 1 -1 2 9 -15 6 181s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 181s Named int [1:8] 11 -3 1 -1 2 9 -15 6 181s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 181s integer: NAs = FALSE, lag = 1, differences = 3, setNames = 0, useNames = 1 181s Named int [1:7] -14 4 -2 3 7 -24 21 181s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 181s Named int [1:7] -14 4 -2 3 7 -24 21 181s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 181s integer: NAs = FALSE, lag = 1, differences = 4, setNames = 0, useNames = 1 181s Named int [1:6] 18 -6 5 4 -31 45 181s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 181s Named int [1:6] 18 -6 5 4 -31 45 181s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 181s integer: NAs = FALSE, lag = 2, differences = 1, setNames = 0, useNames = 1 181s Named int [1:8] -9 -1 -3 -3 -2 9 3 -6 181s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 181s Named int [1:8] -9 -1 -3 -3 -2 9 3 -6 181s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 181s integer: NAs = FALSE, lag = 2, differences = 2, setNames = 0, useNames = 1 181s Named int [1:6] 6 -2 1 12 5 -15 181s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 181s Named int [1:6] 6 -2 1 12 5 -15 181s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 181s integer: NAs = FALSE, lag = 2, differences = 3, setNames = 0, useNames = 1 181s Named int [1:4] -5 14 4 -27 181s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 181s Named int [1:4] -5 14 4 -27 181s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 181s integer: NAs = FALSE, lag = 2, differences = 4, setNames = 0, useNames = 1 181s Named int [1:2] 9 -41 181s - attr(*, "names")= chr [1:2] "I" "J" 181s Named int [1:2] 9 -41 181s - attr(*, "names")= chr [1:2] "I" "J" 181s integer: NAs = FALSE, lag = 3, differences = 1, setNames = 0, useNames = 1 181s Named int [1:7] -11 -2 -5 -3 7 3 3 181s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 181s Named int [1:7] -11 -2 -5 -3 7 3 3 181s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 181s integer: NAs = FALSE, lag = 3, differences = 2, setNames = 0, useNames = 1 181s Named int [1:4] 8 9 8 6 181s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 181s Named int [1:4] 8 9 8 6 181s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 181s integer: NAs = FALSE, lag = 3, differences = 3, setNames = 0, useNames = 1 181s Named int -2 181s - attr(*, "names")= chr "J" 181s Named int -2 181s - attr(*, "names")= chr "J" 181s integer: NAs = FALSE, lag = 3, differences = 4, setNames = 0, useNames = 1 181s Named int(0) 181s - attr(*, "names")= chr(0) 181s Named int(0) 181s - attr(*, "names")= chr(0) 181s integer: NAs = FALSE, lag = 1, differences = 1, setNames = 0, useNames = 0 181s int [1:9] -10 1 -2 -1 -2 0 9 -6 0 181s int [1:9] -10 1 -2 -1 -2 0 9 -6 0 181s integer: NAs = FALSE, lag = 1, differences = 2, setNames = 0, useNames = 0 181s int [1:8] 11 -3 1 -1 2 9 -15 6 181s int [1:8] 11 -3 1 -1 2 9 -15 6 181s integer: NAs = FALSE, lag = 1, differences = 3, setNames = 0, useNames = 0 181s int [1:7] -14 4 -2 3 7 -24 21 181s int [1:7] -14 4 -2 3 7 -24 21 181s integer: NAs = FALSE, lag = 1, differences = 4, setNames = 0, useNames = 0 181s int [1:6] 18 -6 5 4 -31 45 181s int [1:6] 18 -6 5 4 -31 45 181s integer: NAs = FALSE, lag = 2, differences = 1, setNames = 0, useNames = 0 181s int [1:8] -9 -1 -3 -3 -2 9 3 -6 181s int [1:8] -9 -1 -3 -3 -2 9 3 -6 181s integer: NAs = FALSE, lag = 2, differences = 2, setNames = 0, useNames = 0 181s int [1:6] 6 -2 1 12 5 -15 181s int [1:6] 6 -2 1 12 5 -15 181s integer: NAs = FALSE, lag = 2, differences = 3, setNames = 0, useNames = 0 181s int [1:4] -5 14 4 -27 181s int [1:4] -5 14 4 -27 181s integer: NAs = FALSE, lag = 2, differences = 4, setNames = 0, useNames = 0 181s int [1:2] 9 -41 181s int [1:2] 9 -41 181s integer: NAs = FALSE, lag = 3, differences = 1, setNames = 0, useNames = 0 181s int [1:7] -11 -2 -5 -3 7 3 3 181s int [1:7] -11 -2 -5 -3 7 3 3 181s integer: NAs = FALSE, lag = 3, differences = 2, setNames = 0, useNames = 0 181s int [1:4] 8 9 8 6 181s int [1:4] 8 9 8 6 181s integer: NAs = FALSE, lag = 3, differences = 3, setNames = 0, useNames = 0 181s int -2 181s int -2 181s integer: NAs = FALSE, lag = 3, differences = 4, setNames = 0, useNames = 0 181s int(0) 181s int(0) 181s integer: NAs = TRUE, lag = 1, differences = 1, setNames = 1, useNames = 1 181s Named int [1:9] NA NA NA NA NA 0 9 -6 0 181s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 181s Named int [1:9] NA NA NA NA NA 0 9 -6 0 181s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 181s integer: NAs = TRUE, lag = 1, differences = 2, setNames = 1, useNames = 1 181s Named int [1:8] NA NA NA NA NA 9 -15 6 181s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 181s Named int [1:8] NA NA NA NA NA 9 -15 6 181s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 181s integer: NAs = TRUE, lag = 1, differences = 3, setNames = 1, useNames = 1 181s Named int [1:7] NA NA NA NA NA -24 21 181s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 181s Named int [1:7] NA NA NA NA NA -24 21 181s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 181s integer: NAs = TRUE, lag = 1, differences = 4, setNames = 1, useNames = 1 181s Named int [1:6] NA NA NA NA NA 45 181s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 181s Named int [1:6] NA NA NA NA NA 45 181s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 181s integer: NAs = TRUE, lag = 2, differences = 1, setNames = 1, useNames = 1 181s Named int [1:8] -9 NA NA NA NA 9 3 -6 181s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 181s Named int [1:8] -9 NA NA NA NA 9 3 -6 181s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 181s integer: NAs = TRUE, lag = 2, differences = 2, setNames = 1, useNames = 1 181s Named int [1:6] NA NA NA NA NA -15 181s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 181s Named int [1:6] NA NA NA NA NA -15 181s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 181s integer: NAs = TRUE, lag = 2, differences = 3, setNames = 1, useNames = 1 181s Named int [1:4] NA NA NA NA 181s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 181s Named int [1:4] NA NA NA NA 181s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 181s integer: NAs = TRUE, lag = 2, differences = 4, setNames = 1, useNames = 1 181s Named int [1:2] NA NA 181s - attr(*, "names")= chr [1:2] "I" "J" 181s Named int [1:2] NA NA 181s - attr(*, "names")= chr [1:2] "I" "J" 181s integer: NAs = TRUE, lag = 3, differences = 1, setNames = 1, useNames = 1 181s Named int [1:7] NA NA -5 NA NA 3 3 181s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 181s Named int [1:7] NA NA -5 NA NA 3 3 181s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 181s integer: NAs = TRUE, lag = 3, differences = 2, setNames = 1, useNames = 1 181s Named int [1:4] NA NA 8 NA 181s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 181s Named int [1:4] NA NA 8 NA 181s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 181s integer: NAs = TRUE, lag = 3, differences = 3, setNames = 1, useNames = 1 181s Named int NA 181s - attr(*, "names")= chr "J" 181s Named int NA 181s - attr(*, "names")= chr "J" 181s integer: NAs = TRUE, lag = 3, differences = 4, setNames = 1, useNames = 1 181s Named int(0) 181s - attr(*, "names")= chr(0) 181s Named int(0) 181s - attr(*, "names")= chr(0) 181s integer: NAs = TRUE, lag = 1, differences = 1, setNames = 1, useNames = 0 181s int [1:9] NA NA NA NA NA 0 9 NA NA 181s int [1:9] NA NA NA NA NA 0 9 NA NA 181s integer: NAs = TRUE, lag = 1, differences = 2, setNames = 1, useNames = 0 181s int [1:8] NA NA NA NA NA 9 NA NA 181s int [1:8] NA NA NA NA NA 9 NA NA 181s integer: NAs = TRUE, lag = 1, differences = 3, setNames = 1, useNames = 0 181s int [1:7] NA NA NA NA NA NA NA 181s int [1:7] NA NA NA NA NA NA NA 181s integer: NAs = TRUE, lag = 1, differences = 4, setNames = 1, useNames = 0 181s int [1:6] NA NA NA NA NA NA 181s int [1:6] NA NA NA NA NA NA 181s integer: NAs = TRUE, lag = 2, differences = 1, setNames = 1, useNames = 0 181s int [1:8] NA NA NA NA NA 9 NA -6 181s int [1:8] NA NA NA NA NA 9 NA -6 181s integer: NAs = TRUE, lag = 2, differences = 2, setNames = 1, useNames = 0 181s int [1:6] NA NA NA NA NA -15 181s int [1:6] NA NA NA NA NA -15 181s integer: NAs = TRUE, lag = 2, differences = 3, setNames = 1, useNames = 0 181s int [1:4] NA NA NA NA 181s int [1:4] NA NA NA NA 181s integer: NAs = TRUE, lag = 2, differences = 4, setNames = 1, useNames = 0 181s int [1:2] NA NA 181s int [1:2] NA NA 181s integer: NAs = TRUE, lag = 3, differences = 1, setNames = 1, useNames = 0 181s int [1:7] NA NA NA NA NA NA 3 181s int [1:7] NA NA NA NA NA NA 3 181s integer: NAs = TRUE, lag = 3, differences = 2, setNames = 1, useNames = 0 181s int [1:4] NA NA NA NA 181s int [1:4] NA NA NA NA 181s integer: NAs = TRUE, lag = 3, differences = 3, setNames = 1, useNames = 0 181s int NA 181s int NA 181s integer: NAs = TRUE, lag = 3, differences = 4, setNames = 1, useNames = 0 181s int(0) 181s int(0) 181s integer: NAs = TRUE, lag = 1, differences = 1, setNames = 0, useNames = 1 181s Named int [1:9] NA NA NA NA NA NA NA NA NA 181s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 181s Named int [1:9] NA NA NA NA NA NA NA NA NA 181s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 181s integer: NAs = TRUE, lag = 1, differences = 2, setNames = 0, useNames = 1 181s Named int [1:8] NA NA NA NA NA NA NA NA 181s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 181s Named int [1:8] NA NA NA NA NA NA NA NA 181s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 181s integer: NAs = TRUE, lag = 1, differences = 3, setNames = 0, useNames = 1 181s Named int [1:7] NA NA NA NA NA NA NA 181s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 181s Named int [1:7] NA NA NA NA NA NA NA 181s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 181s integer: NAs = TRUE, lag = 1, differences = 4, setNames = 0, useNames = 1 181s Named int [1:6] NA NA NA NA NA NA 181s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 181s Named int [1:6] NA NA NA NA NA NA 181s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 181s integer: NAs = TRUE, lag = 2, differences = 1, setNames = 0, useNames = 1 181s Named int [1:8] NA NA NA NA NA NA NA NA 181s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 181s Named int [1:8] NA NA NA NA NA NA NA NA 181s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 181s integer: NAs = TRUE, lag = 2, differences = 2, setNames = 0, useNames = 1 181s Named int [1:6] NA NA NA NA NA NA 181s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 181s Named int [1:6] NA NA NA NA NA NA 181s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 181s integer: NAs = TRUE, lag = 2, differences = 3, setNames = 0, useNames = 1 181s Named int [1:4] NA NA NA NA 181s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 181s Named int [1:4] NA NA NA NA 181s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 181s integer: NAs = TRUE, lag = 2, differences = 4, setNames = 0, useNames = 1 181s Named int [1:2] NA NA 181s - attr(*, "names")= chr [1:2] "I" "J" 181s Named int [1:2] NA NA 181s - attr(*, "names")= chr [1:2] "I" "J" 181s integer: NAs = TRUE, lag = 3, differences = 1, setNames = 0, useNames = 1 181s Named int [1:7] NA NA NA NA NA NA 3 181s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 181s Named int [1:7] NA NA NA NA NA NA 3 181s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 181s integer: NAs = TRUE, lag = 3, differences = 2, setNames = 0, useNames = 1 181s Named int [1:4] NA NA NA NA 181s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 181s Named int [1:4] NA NA NA NA 181s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 181s integer: NAs = TRUE, lag = 3, differences = 3, setNames = 0, useNames = 1 181s Named int NA 181s - attr(*, "names")= chr "J" 181s Named int NA 181s - attr(*, "names")= chr "J" 181s integer: NAs = TRUE, lag = 3, differences = 4, setNames = 0, useNames = 1 181s Named int(0) 181s - attr(*, "names")= chr(0) 181s Named int(0) 181s - attr(*, "names")= chr(0) 181s integer: NAs = TRUE, lag = 1, differences = 1, setNames = 0, useNames = 0 181s int [1:9] NA NA NA NA NA NA NA NA NA 181s int [1:9] NA NA NA NA NA NA NA NA NA 181s integer: NAs = TRUE, lag = 1, differences = 2, setNames = 0, useNames = 0 181s int [1:8] NA NA NA NA NA NA NA NA 181s int [1:8] NA NA NA NA NA NA NA NA 181s integer: NAs = TRUE, lag = 1, differences = 3, setNames = 0, useNames = 0 181s int [1:7] NA NA NA NA NA NA NA 181s int [1:7] NA NA NA NA NA NA NA 181s integer: NAs = TRUE, lag = 1, differences = 4, setNames = 0, useNames = 0 181s int [1:6] NA NA NA NA NA NA 181s int [1:6] NA NA NA NA NA NA 181s integer: NAs = TRUE, lag = 2, differences = 1, setNames = 0, useNames = 0 181s int [1:8] NA NA NA NA NA NA NA NA 181s int [1:8] NA NA NA NA NA NA NA NA 181s integer: NAs = TRUE, lag = 2, differences = 2, setNames = 0, useNames = 0 181s int [1:6] NA NA NA NA NA NA 181s int [1:6] NA NA NA NA NA NA 181s integer: NAs = TRUE, lag = 2, differences = 3, setNames = 0, useNames = 0 181s int [1:4] NA NA NA NA 181s int [1:4] NA NA NA NA 181s integer: NAs = TRUE, lag = 2, differences = 4, setNames = 0, useNames = 0 181s int [1:2] NA NA 181s int [1:2] NA NA 181s integer: NAs = TRUE, lag = 3, differences = 1, setNames = 0, useNames = 0 181s int [1:7] NA NA NA NA NA NA 3 181s int [1:7] NA NA NA NA NA NA 3 181s integer: NAs = TRUE, lag = 3, differences = 2, setNames = 0, useNames = 0 181s int [1:4] NA NA NA NA 181s int [1:4] NA NA NA NA 181s integer: NAs = TRUE, lag = 3, differences = 3, setNames = 0, useNames = 0 181s int NA 181s int NA 181s integer: NAs = TRUE, lag = 3, differences = 4, setNames = 0, useNames = 0 181s int(0) 181s int(0) 181s num [1:10] 2.586 -0.344 0.33 9.155 -3.254 ... 181s double: NAs = FALSE, lag = 1, differences = 1, setNames = 1, useNames = 1 181s Named num [1:9] -2.929 0.673 8.826 -12.409 -1.221 ... 181s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 181s Named num [1:9] -2.929 0.673 8.826 -12.409 -1.221 ... 181s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 181s double: NAs = FALSE, lag = 1, differences = 2, setNames = 1, useNames = 1 181s Named num [1:8] 3.6 8.15 -21.23 11.19 -2.1 ... 181s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 181s Named num [1:8] 3.6 8.15 -21.23 11.19 -2.1 ... 181s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 181s double: NAs = FALSE, lag = 1, differences = 3, setNames = 1, useNames = 1 181s Named num [1:7] 4.55 -29.39 32.42 -13.29 14.97 ... 181s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 181s Named num [1:7] 4.55 -29.39 32.42 -13.29 14.97 ... 181s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 181s double: NAs = FALSE, lag = 1, differences = 4, setNames = 1, useNames = 1 181s Named num [1:6] -33.9 61.8 -45.7 28.3 -37 ... 181s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 181s Named num [1:6] -33.9 61.8 -45.7 28.3 -37 ... 181s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 181s double: NAs = FALSE, lag = 2, differences = 1, setNames = 1, useNames = 1 181s Named num [1:8] -2.26 9.5 -3.58 -13.63 -4.54 ... 181s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 181s Named num [1:8] -2.26 9.5 -3.58 -13.63 -4.54 ... 181s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 181s double: NAs = FALSE, lag = 2, differences = 2, setNames = 1, useNames = 1 181s Named num [1:6] -1.33 -23.13 -0.96 19.86 14.44 ... 181s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 181s Named num [1:6] -1.33 -23.13 -0.96 19.86 14.44 ... 181s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 181s double: NAs = FALSE, lag = 2, differences = 3, setNames = 1, useNames = 1 181s Named num [1:4] 0.368 42.988 15.396 -29.313 181s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 181s Named num [1:4] 0.368 42.988 15.396 -29.313 181s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 181s double: NAs = FALSE, lag = 2, differences = 4, setNames = 1, useNames = 1 181s Named num [1:2] 15 -72.3 181s - attr(*, "names")= chr [1:2] "I" "J" 181s Named num [1:2] 15 -72.3 181s - attr(*, "names")= chr [1:2] "I" "J" 181s double: NAs = FALSE, lag = 3, differences = 1, setNames = 1, useNames = 1 181s Named num [1:7] 6.57 -2.91 -4.81 -16.95 5.01 ... 181s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 181s Named num [1:7] 6.57 -2.91 -4.81 -16.95 5.01 ... 181s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 181s double: NAs = FALSE, lag = 3, differences = 2, setNames = 1, useNames = 1 181s Named num [1:4] -23.52 7.92 11.38 23.27 181s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 181s Named num [1:4] -23.52 7.92 11.38 23.27 181s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 181s double: NAs = FALSE, lag = 3, differences = 3, setNames = 1, useNames = 1 181s Named num 46.8 181s - attr(*, "names")= chr "J" 181s Named num 46.8 181s - attr(*, "names")= chr "J" 181s double: NAs = FALSE, lag = 3, differences = 4, setNames = 1, useNames = 1 181s Named num(0) 181s - attr(*, "names")= chr(0) 181s Named num(0) 181s - attr(*, "names")= chr(0) 181s double: NAs = FALSE, lag = 1, differences = 1, setNames = 1, useNames = 0 181s num [1:9] -2.929 0.673 8.826 -12.409 -1.221 ... 181s num [1:9] -2.929 0.673 8.826 -12.409 -1.221 ... 181s double: NAs = FALSE, lag = 1, differences = 2, setNames = 1, useNames = 0 181s num [1:8] 3.6 8.15 -21.23 11.19 -2.1 ... 181s num [1:8] 3.6 8.15 -21.23 11.19 -2.1 ... 181s double: NAs = FALSE, lag = 1, differences = 3, setNames = 1, useNames = 0 181s num [1:7] 4.55 -29.39 32.42 -13.29 14.97 ... 181s num [1:7] 4.55 -29.39 32.42 -13.29 14.97 ... 181s double: NAs = FALSE, lag = 1, differences = 4, setNames = 1, useNames = 0 181s num [1:6] -33.9 61.8 -45.7 28.3 -37 ... 181s num [1:6] -33.9 61.8 -45.7 28.3 -37 ... 181s double: NAs = FALSE, lag = 2, differences = 1, setNames = 1, useNames = 0 181s num [1:8] -2.26 9.5 -3.58 -13.63 -4.54 ... 181s num [1:8] -2.26 9.5 -3.58 -13.63 -4.54 ... 181s double: NAs = FALSE, lag = 2, differences = 2, setNames = 1, useNames = 0 181s num [1:6] -1.33 -23.13 -0.96 19.86 14.44 ... 181s num [1:6] -1.33 -23.13 -0.96 19.86 14.44 ... 181s double: NAs = FALSE, lag = 2, differences = 3, setNames = 1, useNames = 0 181s num [1:4] 0.368 42.988 15.396 -29.313 181s num [1:4] 0.368 42.988 15.396 -29.313 181s double: NAs = FALSE, lag = 2, differences = 4, setNames = 1, useNames = 0 181s num [1:2] 15 -72.3 181s num [1:2] 15 -72.3 181s double: NAs = FALSE, lag = 3, differences = 1, setNames = 1, useNames = 0 181s num [1:7] 6.57 -2.91 -4.81 -16.95 5.01 ... 181s num [1:7] 6.57 -2.91 -4.81 -16.95 5.01 ... 181s double: NAs = FALSE, lag = 3, differences = 2, setNames = 1, useNames = 0 181s num [1:4] -23.52 7.92 11.38 23.27 181s num [1:4] -23.52 7.92 11.38 23.27 181s double: NAs = FALSE, lag = 3, differences = 3, setNames = 1, useNames = 0 181s num 46.8 181s num 46.8 181s double: NAs = FALSE, lag = 3, differences = 4, setNames = 1, useNames = 0 181s num(0) 181s num(0) 181s double: NAs = FALSE, lag = 1, differences = 1, setNames = 0, useNames = 1 181s Named num [1:9] -2.929 0.673 8.826 -12.409 -1.221 ... 181s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 181s Named num [1:9] -2.929 0.673 8.826 -12.409 -1.221 ... 181s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 181s double: NAs = FALSE, lag = 1, differences = 2, setNames = 0, useNames = 1 181s Named num [1:8] 3.6 8.15 -21.23 11.19 -2.1 ... 181s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 181s Named num [1:8] 3.6 8.15 -21.23 11.19 -2.1 ... 181s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 181s double: NAs = FALSE, lag = 1, differences = 3, setNames = 0, useNames = 1 181s Named num [1:7] 4.55 -29.39 32.42 -13.29 14.97 ... 181s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 181s Named num [1:7] 4.55 -29.39 32.42 -13.29 14.97 ... 181s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 181s double: NAs = FALSE, lag = 1, differences = 4, setNames = 0, useNames = 1 181s Named num [1:6] -33.9 61.8 -45.7 28.3 -37 ... 181s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 181s Named num [1:6] -33.9 61.8 -45.7 28.3 -37 ... 181s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 181s double: NAs = FALSE, lag = 2, differences = 1, setNames = 0, useNames = 1 181s Named num [1:8] -2.26 9.5 -3.58 -13.63 -4.54 ... 181s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 181s Named num [1:8] -2.26 9.5 -3.58 -13.63 -4.54 ... 181s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 181s double: NAs = FALSE, lag = 2, differences = 2, setNames = 0, useNames = 1 181s Named num [1:6] -1.33 -23.13 -0.96 19.86 14.44 ... 181s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 181s Named num [1:6] -1.33 -23.13 -0.96 19.86 14.44 ... 181s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 181s double: NAs = FALSE, lag = 2, differences = 3, setNames = 0, useNames = 1 181s Named num [1:4] 0.368 42.988 15.396 -29.313 181s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 181s Named num [1:4] 0.368 42.988 15.396 -29.313 181s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 181s double: NAs = FALSE, lag = 2, differences = 4, setNames = 0, useNames = 1 181s Named num [1:2] 15 -72.3 181s - attr(*, "names")= chr [1:2] "I" "J" 181s Named num [1:2] 15 -72.3 181s - attr(*, "names")= chr [1:2] "I" "J" 181s double: NAs = FALSE, lag = 3, differences = 1, setNames = 0, useNames = 1 181s Named num [1:7] 6.57 -2.91 -4.81 -16.95 5.01 ... 181s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 181s Named num [1:7] 6.57 -2.91 -4.81 -16.95 5.01 ... 181s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 181s double: NAs = FALSE, lag = 3, differences = 2, setNames = 0, useNames = 1 181s Named num [1:4] -23.52 7.92 11.38 23.27 181s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 181s Named num [1:4] -23.52 7.92 11.38 23.27 181s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 181s double: NAs = FALSE, lag = 3, differences = 3, setNames = 0, useNames = 1 181s Named num 46.8 181s - attr(*, "names")= chr "J" 181s Named num 46.8 181s - attr(*, "names")= chr "J" 181s double: NAs = FALSE, lag = 3, differences = 4, setNames = 0, useNames = 1 181s Named num(0) 181s - attr(*, "names")= chr(0) 181s Named num(0) 181s - attr(*, "names")= chr(0) 181s double: NAs = FALSE, lag = 1, differences = 1, setNames = 0, useNames = 0 181s num [1:9] -2.929 0.673 8.826 -12.409 -1.221 ... 181s num [1:9] -2.929 0.673 8.826 -12.409 -1.221 ... 181s double: NAs = FALSE, lag = 1, differences = 2, setNames = 0, useNames = 0 181s num [1:8] 3.6 8.15 -21.23 11.19 -2.1 ... 181s num [1:8] 3.6 8.15 -21.23 11.19 -2.1 ... 181s double: NAs = FALSE, lag = 1, differences = 3, setNames = 0, useNames = 0 181s num [1:7] 4.55 -29.39 32.42 -13.29 14.97 ... 181s num [1:7] 4.55 -29.39 32.42 -13.29 14.97 ... 181s double: NAs = FALSE, lag = 1, differences = 4, setNames = 0, useNames = 0 181s num [1:6] -33.9 61.8 -45.7 28.3 -37 ... 181s num [1:6] -33.9 61.8 -45.7 28.3 -37 ... 181s double: NAs = FALSE, lag = 2, differences = 1, setNames = 0, useNames = 0 181s num [1:8] -2.26 9.5 -3.58 -13.63 -4.54 ... 181s num [1:8] -2.26 9.5 -3.58 -13.63 -4.54 ... 181s double: NAs = FALSE, lag = 2, differences = 2, setNames = 0, useNames = 0 181s num [1:6] -1.33 -23.13 -0.96 19.86 14.44 ... 181s num [1:6] -1.33 -23.13 -0.96 19.86 14.44 ... 181s double: NAs = FALSE, lag = 2, differences = 3, setNames = 0, useNames = 0 181s num [1:4] 0.368 42.988 15.396 -29.313 181s num [1:4] 0.368 42.988 15.396 -29.313 181s double: NAs = FALSE, lag = 2, differences = 4, setNames = 0, useNames = 0 181s num [1:2] 15 -72.3 181s num [1:2] 15 -72.3 181s double: NAs = FALSE, lag = 3, differences = 1, setNames = 0, useNames = 0 181s num [1:7] 6.57 -2.91 -4.81 -16.95 5.01 ... 181s num [1:7] 6.57 -2.91 -4.81 -16.95 5.01 ... 181s double: NAs = FALSE, lag = 3, differences = 2, setNames = 0, useNames = 0 181s num [1:4] -23.52 7.92 11.38 23.27 181s num [1:4] -23.52 7.92 11.38 23.27 181s double: NAs = FALSE, lag = 3, differences = 3, setNames = 0, useNames = 0 181s num 46.8 181s num 46.8 181s double: NAs = FALSE, lag = 3, differences = 4, setNames = 0, useNames = 0 181s num(0) 181s num(0) 181s double: NAs = TRUE, lag = 1, differences = 1, setNames = 1, useNames = 1 181s Named num [1:9] -2.929 0.673 8.826 NA NA ... 181s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 181s Named num [1:9] -2.929 0.673 8.826 NA NA ... 181s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 181s double: NAs = TRUE, lag = 1, differences = 2, setNames = 1, useNames = 1 181s Named num [1:8] 3.6 8.15 NA NA NA ... 181s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 181s Named num [1:8] 3.6 8.15 NA NA NA ... 181s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 181s double: NAs = TRUE, lag = 1, differences = 3, setNames = 1, useNames = 1 181s Named num [1:7] 4.55 NA NA NA NA ... 181s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 181s Named num [1:7] 4.55 NA NA NA NA ... 181s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 181s double: NAs = TRUE, lag = 1, differences = 4, setNames = 1, useNames = 1 181s Named num [1:6] NA NA NA NA NA NA 181s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 181s Named num [1:6] NA NA NA NA NA NA 181s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 181s double: NAs = TRUE, lag = 2, differences = 1, setNames = 1, useNames = 1 181s Named num [1:8] -2.26 9.5 NA NA NA ... 181s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 181s Named num [1:8] -2.26 9.5 NA NA NA ... 181s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 181s double: NAs = TRUE, lag = 2, differences = 2, setNames = 1, useNames = 1 181s Named num [1:6] NA NA NA NA NA NA 181s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 181s Named num [1:6] NA NA NA NA NA NA 181s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 181s double: NAs = TRUE, lag = 2, differences = 3, setNames = 1, useNames = 1 181s Named num [1:4] NA NA NA NA 181s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 181s Named num [1:4] NA NA NA NA 181s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 181s double: NAs = TRUE, lag = 2, differences = 4, setNames = 1, useNames = 1 181s Named num [1:2] NA NA 181s - attr(*, "names")= chr [1:2] "I" "J" 181s Named num [1:2] NA NA 181s - attr(*, "names")= chr [1:2] "I" "J" 181s double: NAs = TRUE, lag = 3, differences = 1, setNames = 1, useNames = 1 181s Named num [1:7] 6.57 NA NA -16.95 NA ... 181s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 181s Named num [1:7] 6.57 NA NA -16.95 NA ... 181s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 181s double: NAs = TRUE, lag = 3, differences = 2, setNames = 1, useNames = 1 181s Named num [1:4] -23.5 NA NA 23.3 181s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 181s Named num [1:4] -23.5 NA NA 23.3 181s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 181s double: NAs = TRUE, lag = 3, differences = 3, setNames = 1, useNames = 1 181s Named num 46.8 181s - attr(*, "names")= chr "J" 181s Named num 46.8 181s - attr(*, "names")= chr "J" 181s double: NAs = TRUE, lag = 3, differences = 4, setNames = 1, useNames = 1 181s Named num(0) 181s - attr(*, "names")= chr(0) 181s Named num(0) 181s - attr(*, "names")= chr(0) 181s double: NAs = TRUE, lag = 1, differences = 1, setNames = 1, useNames = 0 181s num [1:9] NA 0.673 8.826 NA NA ... 181s num [1:9] NA 0.673 8.826 NA NA ... 181s double: NAs = TRUE, lag = 1, differences = 2, setNames = 1, useNames = 0 181s num [1:8] NA 8.15 NA NA NA ... 181s num [1:8] NA 8.15 NA NA NA ... 181s double: NAs = TRUE, lag = 1, differences = 3, setNames = 1, useNames = 0 181s num [1:7] NA NA NA NA NA NA NA 181s num [1:7] NA NA NA NA NA NA NA 181s double: NAs = TRUE, lag = 1, differences = 4, setNames = 1, useNames = 0 181s num [1:6] NA NA NA NA NA NA 181s num [1:6] NA NA NA NA NA NA 181s double: NAs = TRUE, lag = 2, differences = 1, setNames = 1, useNames = 0 181s num [1:8] NA 9.5 NA NA NA ... 181s num [1:8] NA 9.5 NA NA NA ... 181s double: NAs = TRUE, lag = 2, differences = 2, setNames = 1, useNames = 0 181s num [1:6] NA NA NA NA NA NA 181s num [1:6] NA NA NA NA NA NA 181s double: NAs = TRUE, lag = 2, differences = 3, setNames = 1, useNames = 0 181s num [1:4] NA NA NA NA 181s num [1:4] NA NA NA NA 181s double: NAs = TRUE, lag = 2, differences = 4, setNames = 1, useNames = 0 181s num [1:2] NA NA 181s num [1:2] NA NA 181s double: NAs = TRUE, lag = 3, differences = 1, setNames = 1, useNames = 0 181s num [1:7] NA NA NA NA NA NA NA 181s num [1:7] NA NA NA NA NA NA NA 181s double: NAs = TRUE, lag = 3, differences = 2, setNames = 1, useNames = 0 181s num [1:4] NA NA NA NA 181s num [1:4] NA NA NA NA 181s double: NAs = TRUE, lag = 3, differences = 3, setNames = 1, useNames = 0 181s num NA 181s num NA 181s double: NAs = TRUE, lag = 3, differences = 4, setNames = 1, useNames = 0 181s num(0) 181s num(0) 181s double: NAs = TRUE, lag = 1, differences = 1, setNames = 0, useNames = 1 181s Named num [1:9] NA 0.673 8.826 NA NA ... 181s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 181s Named num [1:9] NA 0.673 8.826 NA NA ... 181s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 181s double: NAs = TRUE, lag = 1, differences = 2, setNames = 0, useNames = 1 181s Named num [1:8] NA 8.15 NA NA NA ... 181s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 181s Named num [1:8] NA 8.15 NA NA NA ... 181s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 181s double: NAs = TRUE, lag = 1, differences = 3, setNames = 0, useNames = 1 181s Named num [1:7] NA NA NA NA NA NA NA 181s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 181s Named num [1:7] NA NA NA NA NA NA NA 181s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 181s double: NAs = TRUE, lag = 1, differences = 4, setNames = 0, useNames = 1 181s Named num [1:6] NA NA NA NA NA NA 181s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 181s Named num [1:6] NA NA NA NA NA NA 181s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 181s double: NAs = TRUE, lag = 2, differences = 1, setNames = 0, useNames = 1 181s Named num [1:8] NA 9.5 NA NA NA ... 181s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 181s Named num [1:8] NA 9.5 NA NA NA ... 181s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 181s double: NAs = TRUE, lag = 2, differences = 2, setNames = 0, useNames = 1 181s Named num [1:6] NA NA NA NA NA NA 181s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 181s Named num [1:6] NA NA NA NA NA NA 181s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 181s double: NAs = TRUE, lag = 2, differences = 3, setNames = 0, useNames = 1 181s Named num [1:4] NA NA NA NA 181s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 181s Named num [1:4] NA NA NA NA 181s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 181s double: NAs = TRUE, lag = 2, differences = 4, setNames = 0, useNames = 1 181s Named num [1:2] NA NA 181s - attr(*, "names")= chr [1:2] "I" "J" 181s Named num [1:2] NA NA 181s - attr(*, "names")= chr [1:2] "I" "J" 181s double: NAs = TRUE, lag = 3, differences = 1, setNames = 0, useNames = 1 181s Named num [1:7] NA NA NA NA NA NA NA 181s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 181s Named num [1:7] NA NA NA NA NA NA NA 181s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 181s double: NAs = TRUE, lag = 3, differences = 2, setNames = 0, useNames = 1 181s Named num [1:4] NA NA NA NA 181s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 181s Named num [1:4] NA NA NA NA 181s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 181s double: NAs = TRUE, lag = 3, differences = 3, setNames = 0, useNames = 1 181s Named num NA 181s - attr(*, "names")= chr "J" 181s Named num NA 181s - attr(*, "names")= chr "J" 181s double: NAs = TRUE, lag = 3, differences = 4, setNames = 0, useNames = 1 181s Named num(0) 181s - attr(*, "names")= chr(0) 181s Named num(0) 181s - attr(*, "names")= chr(0) 181s double: NAs = TRUE, lag = 1, differences = 1, setNames = 0, useNames = 0 181s num [1:9] NA 0.673 8.826 NA NA ... 181s num [1:9] NA 0.673 8.826 NA NA ... 181s double: NAs = TRUE, lag = 1, differences = 2, setNames = 0, useNames = 0 181s num [1:8] NA 8.15 NA NA NA ... 181s num [1:8] NA 8.15 NA NA NA ... 181s double: NAs = TRUE, lag = 1, differences = 3, setNames = 0, useNames = 0 181s num [1:7] NA NA NA NA NA NA NA 181s num [1:7] NA NA NA NA NA NA NA 181s double: NAs = TRUE, lag = 1, differences = 4, setNames = 0, useNames = 0 181s num [1:6] NA NA NA NA NA NA 181s num [1:6] NA NA NA NA NA NA 181s double: NAs = TRUE, lag = 2, differences = 1, setNames = 0, useNames = 0 181s num [1:8] NA 9.5 NA NA NA ... 181s num [1:8] NA 9.5 NA NA NA ... 181s double: NAs = TRUE, lag = 2, differences = 2, setNames = 0, useNames = 0 181s num [1:6] NA NA NA NA NA NA 181s num [1:6] NA NA NA NA NA NA 181s double: NAs = TRUE, lag = 2, differences = 3, setNames = 0, useNames = 0 181s num [1:4] NA NA NA NA 181s num [1:4] NA NA NA NA 181s double: NAs = TRUE, lag = 2, differences = 4, setNames = 0, useNames = 0 181s num [1:2] NA NA 181s num [1:2] NA NA 181s double: NAs = TRUE, lag = 3, differences = 1, setNames = 0, useNames = 0 181s num [1:7] NA NA NA NA NA NA NA 181s num [1:7] NA NA NA NA NA NA NA 181s double: NAs = TRUE, lag = 3, differences = 2, setNames = 0, useNames = 0 181s num [1:4] NA NA NA NA 181s num [1:4] NA NA NA NA 181s double: NAs = TRUE, lag = 3, differences = 3, setNames = 0, useNames = 0 181s num NA 181s num NA 181s double: NAs = TRUE, lag = 3, differences = 4, setNames = 0, useNames = 0 181s num(0) 181s num(0) 181s > 181s 181s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 181s Copyright (C) 2024 The R Foundation for Statistical Computing 181s Platform: x86_64-pc-linux-gnu 181s 181s R is free software and comes with ABSOLUTELY NO WARRANTY. 181s You are welcome to redistribute it under certain conditions. 181s Type 'license()' or 'licence()' for distribution details. 181s 181s R is a collaborative project with many contributors. 181s Type 'contributors()' for more information and 181s 'citation()' on how to cite R or R packages in publications. 181s 181s Type 'demo()' for some demos, 'help()' for on-line help, or 181s 'help.start()' for an HTML browser interface to help. 181s Type 'q()' to quit R. 181s 181s > library("matrixStats") 181s > 181s > diff2_R <- function(..., useNames=NA){ 181s + res <- diff(...) 181s + if (is.na(useNames) || !useNames) names(res) <- NULL 181s + res 181s + } 181s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 181s > # Subsetted tests 181s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 181s > source("utils/validateIndicesFramework.R") 181s > x <- runif(6, min = -6, max = 6) 181s > for (setNames in c(TRUE, FALSE)) { 181s + if (setNames) names(x) <- LETTERS[1:6] 181s + else names(x) <- NULL 181s + for (l in 1:2) { 181s + for (d in 1:2) { 181s + for (idxs in index_cases) { 181s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 181s + validateIndicesTestVector(x, idxs, 181s + ftest = diff2, fsure = diff2_R, 181s + lag = l, differences = d, useNames = useNames) 181s + } 181s + } 181s + } 181s + } 181s + } 181s > 181s 181s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 181s Copyright (C) 2024 The R Foundation for Statistical Computing 181s Platform: x86_64-pc-linux-gnu 181s 181s R is free software and comes with ABSOLUTELY NO WARRANTY. 181s You are welcome to redistribute it under certain conditions. 181s Type 'license()' or 'licence()' for distribution details. 181s 181s R is a collaborative project with many contributors. 181s Type 'contributors()' for more information and 181s 'citation()' on how to cite R or R packages in publications. 181s 181s Type 'demo()' for some demos, 'help()' for on-line help, or 181s 'help.start()' for an HTML browser interface to help. 181s Type 'q()' to quit R. 181s 181s > library("matrixStats") 181s > 181s > indexByRow_R1 <- function(dim, idxs = NULL, ...) { 181s + n <- prod(dim) 181s + x <- matrix(seq_len(n), nrow = dim[2L], ncol = dim[1L], byrow = TRUE) 181s + if (!is.null(idxs)) 181s + x <- x[idxs] 181s + as.vector(x) 181s + } 181s > 181s > 181s > indexByRow_R2 <- function(dim, idxs = NULL, ...) { 181s + n <- prod(dim) 181s + if (is.null(idxs)) { 181s + x <- matrix(seq_len(n), nrow = dim[2L], ncol = dim[1L], byrow = TRUE) 181s + as.vector(x) 181s + } else { 181s + idxs <- idxs - 1L 181s + cols <- idxs %/% dim[2L] 181s + rows <- idxs %% dim[2L] 181s + cols + dim[1L] * rows + 1L 181s + } 181s + } 181s > 181s > 181s > dim <- c(5L, 4L) 181s > x <- matrix(NA_integer_, nrow = dim[1L], ncol = dim[2L]) 181s > y <- t(x) 181s > idxs_by_cols <- seq_along(x) 181s > 181s > # Assign by columns 181s > x[idxs_by_cols] <- idxs_by_cols 181s > print(x) 181s [,1] [,2] [,3] [,4] 181s [1,] 1 6 11 16 181s [2,] 2 7 12 17 181s [3,] 3 8 13 18 181s [4,] 4 9 14 19 181s [5,] 5 10 15 20 181s > 181s > # Truth 181s > y0 <- t(x) 181s > idxs_by_rows <- as.vector(y0) 181s > 181s > # Assert 181s > idxs <- indexByRow(dim) 181s > stopifnot(all.equal(idxs, idxs_by_rows)) 181s > y <- x 181s > y[idxs_by_rows] <- idxs 181s > print(y) 181s [,1] [,2] [,3] [,4] 181s [1,] 1 6 11 16 181s [2,] 2 7 12 17 181s [3,] 3 8 13 18 181s [4,] 4 9 14 19 181s [5,] 5 10 15 20 181s > stopifnot(all(as.vector(y) == as.vector(x))) 181s > 181s > idxs_R1 <- indexByRow_R1(dim) 181s > stopifnot(all.equal(idxs_R1, idxs_by_rows)) 181s > 181s > idxs_R2 <- indexByRow_R2(dim) 181s > stopifnot(all.equal(idxs_R2, idxs_by_rows)) 181s > 181s > # Assert 181s > idxs_by_cols <- seq(from = 1, to = length(x), by = 3L) 181s > idxs_by_rows <- as.vector(t(x)[idxs_by_cols]) 181s > 181s > idxs <- indexByRow(dim, idxs = idxs_by_cols) 181s > stopifnot(all(idxs == idxs_by_rows)) 181s > 181s > idxs_R1 <- indexByRow_R1(dim, idxs = idxs_by_cols) 181s > stopifnot(all(idxs_R1 == idxs_by_rows)) 181s > 181s > idxs_R2 <- indexByRow_R2(dim, idxs = idxs_by_cols) 181s > stopifnot(all(idxs_R2 == idxs_by_rows)) 181s > 181s > 181s > ## DEFUNCT: Backward compatibility 181s > res <- tryCatch({ 181s + idxs1 <- indexByRow(x) 181s + }, error = identity) 181s > stopifnot(inherits(res, "error")) 181s > 181s > 181s > ## Exceptions: 181s > ## Too large matrices are not supported, which happens 181s > ## when prod(dim) > .Machine$integer.max 181s > dim_too_large <- c(.Machine$integer.max, 2L) 181s > res <- tryCatch({ 181s + idxs <- indexByRow(dim_too_large, idxs = 1L) 181s + }, error = identity) 181s > stopifnot(inherits(res, "error")) 181s > 181s > ## Non-positive indices are not supported 181s > res <- tryCatch({ 181s + idxs <- indexByRow(c(1,1), idxs = 0L) 181s + }, error = identity) 181s > stopifnot(inherits(res, "error")) 181s > 181s > res <- tryCatch({ 181s + idxs <- indexByRow(c(1,1), idxs = -1L) 181s + }, error = identity) 181s > stopifnot(inherits(res, "error")) 181s > 181s 181s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 181s Copyright (C) 2024 The R Foundation for Statistical Computing 181s Platform: x86_64-pc-linux-gnu 181s 181s R is free software and comes with ABSOLUTELY NO WARRANTY. 181s You are welcome to redistribute it under certain conditions. 181s Type 'license()' or 'licence()' for distribution details. 181s 181s R is a collaborative project with many contributors. 181s Type 'contributors()' for more information and 181s 'citation()' on how to cite R or R packages in publications. 181s 181s Type 'demo()' for some demos, 'help()' for on-line help, or 181s 'help.start()' for an HTML browser interface to help. 181s Type 'q()' to quit R. 181s 181s > library("matrixStats") 181s > library("stats") 181s > 181s > logSumExp_R <- function(lx, na.rm = FALSE) { 181s + log(sum(exp(lx), na.rm = na.rm)) 181s + } 181s > 181s > ## R-help thread \emph{'[R] Beyond double-precision?'} on May 9, 2009. 181s > 181s > for (mode in c("integer", "double")) { 181s + cat("mode: ", mode, "\n", sep = "") 181s + 181s + set.seed(1) 181s + x <- runif(20, min = 1.0, max = 3.0) 181s + storage.mode(x) <- mode 181s + str(x) 181s + 181s + ## The logarithm of the harmonic mean 181s + y0 <- log(1 / mean(1 / x)) 181s + print(y0) ## -1.600885 181s + 181s + lx <- log(x) 181s + y1 <- log(length(x)) - logSumExp(-lx) 181s + print(y1) ## [1] -1.600885 181s + 181s + # Sanity check 181s + stopifnot(all.equal(y1, y0)) 181s + 181s + y2 <- log(length(x)) - logSumExp_R(-lx) 181s + # Sanity check 181s + stopifnot(all.equal(y2, y0)) 181s + } # for (mode ...) 181s mode: integer 181s int [1:20] 1 1 2 2 1 2 2 2 2 1 ... 181s [1] 0.3215836 181s [1] 0.3215836 181s mode: double 181s num [1:20] 1.53 1.74 2.15 2.82 1.4 ... 181s [1] 0.6673156 181s [1] 0.6673156 181s > 181s > 181s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 181s > # Missing values 181s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 181s > ## NA values 181s > lx <- c(1, 2, 3) 181s > lx[2] <- NA_real_ 181s > y0 <- logSumExp_R(lx, na.rm = FALSE) 181s > y <- logSumExp(lx, na.rm = FALSE) 181s > print(y) 181s [1] NA 181s > stopifnot(identical(y, NA_real_)) 181s > stopifnot(all.equal(y, y0)) 181s > 181s > y0 <- logSumExp_R(lx, na.rm = TRUE) 181s > y <- logSumExp(lx, na.rm = TRUE) 181s > print(y) 181s [1] 3.126928 181s > stopifnot(all.equal(y, y0)) 181s > 181s > ## NaN values 181s > lx <- c(1, 2, 3) 181s > lx[2] <- NaN 181s > y0 <- logSumExp_R(lx, na.rm = FALSE) 181s > y <- logSumExp(lx, na.rm = FALSE) 181s > print(y) 181s [1] NA 181s > stopifnot(identical(y, NA_real_)) 181s > stopifnot(all.equal(y, y0)) 181s > 181s > y0 <- logSumExp_R(lx, na.rm = TRUE) 181s > y <- logSumExp(lx, na.rm = TRUE) 181s > print(y) 181s [1] 3.126928 181s > stopifnot(all.equal(y, y0)) 181s > 181s > 181s > 181s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 181s > # Corner cases 181s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 181s > ## Zero-length vectors 181s > lx <- numeric(0L) 181s > y0 <- logSumExp_R(lx) 181s > y <- logSumExp(lx) 181s > print(y) 181s [1] -Inf 181s > stopifnot(identical(y, -Inf)) 181s > stopifnot(all.equal(y, y0)) 181s > 181s > ## Vectors of length one 181s > lx <- 1.0 181s > y0 <- logSumExp_R(lx) 181s > y <- logSumExp(lx) 181s > print(y) 181s [1] 1 181s > stopifnot(identical(y, lx)) 181s > stopifnot(all.equal(y, y0)) 181s > 181s > lx <- NA_real_ 181s > y0 <- logSumExp_R(lx, na.rm = TRUE) 181s > y <- logSumExp(lx, na.rm = TRUE) 181s > print(y) 181s [1] -Inf 181s > stopifnot(identical(y, -Inf)) 181s > stopifnot(all.equal(y, y0)) 181s > 181s > ## All missing values 181s > lx <- c(NA_real_, NA_real_) 181s > y0 <- logSumExp_R(lx, na.rm = TRUE) 181s > y <- logSumExp(lx, na.rm = TRUE) 181s > print(y) 181s [1] -Inf 181s > stopifnot(identical(y, -Inf)) 181s > stopifnot(all.equal(y, y0)) 181s > 181s > lx <- c(NA_real_, NA_real_) 181s > y0 <- logSumExp_R(lx, na.rm = FALSE) 181s > y <- logSumExp(lx, na.rm = FALSE) 181s > print(y) 181s [1] NA 181s > stopifnot(identical(y, NA_real_)) 181s > stopifnot(all.equal(y, y0)) 181s > 181s > 181s > ## +Inf values 181s > lx <- c(1, 2, +Inf) 181s > y0 <- logSumExp_R(lx) 181s > y <- logSumExp(lx) 181s > print(y) 181s [1] Inf 181s > stopifnot(identical(y, +Inf)) 181s > stopifnot(all.equal(y, y0)) 181s > 181s > ## First element is a missing value, cf. PR #33 181s > lx <- c(NA_real_, 1) 181s > y0 <- logSumExp_R(lx) 181s > print(y0) 181s [1] NA 181s > y <- logSumExp(lx, na.rm = FALSE) 181s > print(y) 181s [1] NA 181s > stopifnot(identical(y, NA_real_)) 181s > stopifnot(all.equal(y, y0)) 181s > 181s > y0 <- logSumExp_R(lx, na.rm = TRUE) 181s > print(y0) 181s [1] 1 181s > y <- logSumExp(lx, na.rm = TRUE) 181s > print(y) 181s [1] 1 181s > stopifnot(identical(y, 1)) 181s > stopifnot(all.equal(y, y0)) 181s > 181s > ## Multiple -Inf values, cf. issue #84 181s > lx <- c(-Inf, -Inf) 181s > y0 <- logSumExp_R(lx) 181s > y <- logSumExp(lx) 181s > print(y) 181s [1] -Inf 181s > stopifnot(identical(y, -Inf)) 181s > stopifnot(all.equal(y, y0)) 181s > 181s > lx <- c(-Inf, 5, -Inf) 181s > y0 <- logSumExp_R(lx) 181s > y <- logSumExp(lx) 181s > print(y) 181s [1] 5 181s > stopifnot(identical(y, 5)) 181s > stopifnot(all.equal(y, y0)) 181s > 182s 182s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 182s Copyright (C) 2024 The R Foundation for Statistical Computing 182s Platform: x86_64-pc-linux-gnu 182s 182s R is free software and comes with ABSOLUTELY NO WARRANTY. 182s You are welcome to redistribute it under certain conditions. 182s Type 'license()' or 'licence()' for distribution details. 182s 182s R is a collaborative project with many contributors. 182s Type 'contributors()' for more information and 182s 'citation()' on how to cite R or R packages in publications. 182s 182s Type 'demo()' for some demos, 'help()' for on-line help, or 182s 'help.start()' for an HTML browser interface to help. 182s Type 'q()' to quit R. 182s 182s > library("matrixStats") 182s > 182s > logSumExp_R <- function(lx, na.rm = FALSE) { 182s + log(sum(exp(lx), na.rm = na.rm)) 182s + } 182s > 182s > 182s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 182s > # Subsetted tests 182s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 182s > source("utils/validateIndicesFramework.R") 182s > x <- runif(6, min = -6, max = 6) 182s > for (idxs in index_cases) { 182s + validateIndicesTestVector(x, idxs, 182s + ftest = logSumExp, fsure = logSumExp_R, 182s + na.rm = FALSE) 182s + validateIndicesTestVector(x, idxs, 182s + ftest = logSumExp, fsure = logSumExp_R, 182s + na.rm = TRUE) 182s + } 182s > 182s 182s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 182s Copyright (C) 2024 The R Foundation for Statistical Computing 182s Platform: x86_64-pc-linux-gnu 182s 182s R is free software and comes with ABSOLUTELY NO WARRANTY. 182s You are welcome to redistribute it under certain conditions. 182s Type 'license()' or 'licence()' for distribution details. 182s 182s R is a collaborative project with many contributors. 182s Type 'contributors()' for more information and 182s 'citation()' on how to cite R or R packages in publications. 182s 182s Type 'demo()' for some demos, 'help()' for on-line help, or 182s 'help.start()' for an HTML browser interface to help. 182s Type 'q()' to quit R. 182s 182s > library("matrixStats") 182s > 182s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 182s > # Consistency checks 182s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 182s > set.seed(1) 182s > 182s > mean2_R <- function(x, na.rm = FALSE, idxs = NULL) { 182s + if (is.null(idxs)) { 182s + mean(x, na.rm = na.rm) 182s + } else { 182s + mean(x[idxs], na.rm = na.rm) 182s + } 182s + } # mean2_R() 182s > 182s > 182s > cat("Consistency checks:\n") 182s Consistency checks: 182s > for (kk in 1:20) { 182s + cat("Random test #", kk, "\n", sep = "") 182s + 182s + # Simulate data in a matrix of any shape 182s + n <- sample(100L, size = 1L) 182s + x <- rnorm(n, sd = 100) 182s + 182s + # Add NAs? 182s + if ((kk %% 4) %in% c(3, 0)) { 182s + cat("Adding NAs\n") 182s + nna <- sample(n, size = 1L) 182s + na_values <- c(NA_real_, NaN) 182s + t <- sample(na_values, size = nna, replace = TRUE) 182s + x[sample(length(x), size = nna)] <- t 182s + } 182s + 182s + # Integer or double? 182s + if ((kk %% 4) %in% c(2, 0)) { 182s + cat("Coercing to integers\n") 182s + storage.mode(x) <- "integer" 182s + } 182s + 182s + na.rm <- sample(c(TRUE, FALSE), size = 1L) 182s + 182s + # Sum over all 182s + y0 <- mean2_R(x, na.rm = na.rm) 182s + y1 <- mean2(x, na.rm = na.rm) 182s + stopifnot(all.equal(y1, y0)) 182s + 182s + # Sum over subset 182s + nidxs <- sample(n, size = 1L) 182s + idxs <- sample(n, size = nidxs) 182s + y0 <- mean2_R(x, na.rm = na.rm, idxs = idxs) 182s + y1 <- mean2(x, na.rm = na.rm, idxs = idxs) 182s + stopifnot(all.equal(y1, y0)) 182s + 182s + if (storage.mode(x) == "integer") { 182s + storage.mode(x) <- "logical" 182s + 182s + y0 <- mean2_R(x, na.rm = na.rm) 182s + y1 <- mean2(x, na.rm = na.rm) 182s + stopifnot(all.equal(y1, y0)) 182s + 182s + y0 <- mean2_R(x, na.rm = na.rm, idxs = idxs) 182s + y1 <- mean2(x, na.rm = na.rm, idxs = idxs) 182s + stopifnot(all.equal(y1, y0)) 182s + } 182s + } # for (kk ...) 182s Random test #1 182s Random test #2 182s Coercing to integers 182s Random test #3 182s Adding NAs 182s Random test #4 182s Adding NAs 182s Coercing to integers 182s Random test #5 182s Random test #6 182s Coercing to integers 182s Random test #7 182s Adding NAs 182s Random test #8 182s Adding NAs 182s Coercing to integers 182s Random test #9 182s Random test #10 182s Coercing to integers 182s Random test #11 182s Adding NAs 182s Random test #12 182s Adding NAs 182s Coercing to integers 182s Random test #13 182s Random test #14 182s Coercing to integers 182s Random test #15 182s Adding NAs 182s Random test #16 182s Adding NAs 182s Coercing to integers 182s Random test #17 182s Random test #18 182s Coercing to integers 182s Random test #19 182s Adding NAs 182s Random test #20 182s Adding NAs 182s Coercing to integers 182s > 182s > 182s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 182s > # Special cases 182s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 182s > for (na.rm in c(FALSE, TRUE)) { 182s + # Averaging over zero elements (integers) 182s + x <- integer(0) 182s + s1 <- mean(x, na.rm = na.rm) 182s + s2 <- mean2(x, na.rm = na.rm) 182s + stopifnot(identical(s1, s2)) 182s + 182s + x <- 1:5 182s + idxs <- integer(0) 182s + s1 <- mean(x[idxs], na.rm = na.rm) 182s + s2 <- mean2(x, idxs = idxs, na.rm = na.rm) 182s + stopifnot(identical(s1, s2)) 182s + 182s + # Averaging over NA_integer_:s 182s + x <- rep(NA_integer_, times = 5L) 182s + s1 <- mean(x, na.rm = na.rm) 182s + s2 <- mean2(x, na.rm = na.rm) 182s + stopifnot(identical(s1, s2)) 182s + 182s + x <- rep(NA_integer_, times = 5L) 182s + idxs <- 1:3 182s + s1 <- mean(x[idxs], na.rm = na.rm) 182s + s2 <- mean2(x, idxs = idxs, na.rm = na.rm) 182s + stopifnot(identical(s1, s2)) 182s + 182s + 182s + # Averaging over zero elements (doubles) 182s + x <- double(0) 182s + s1 <- mean(x) 182s + s2 <- mean2(x) 182s + stopifnot(identical(s1, s2)) 182s + 182s + x <- as.double(1:10) 182s + idxs <- integer(0) 182s + s1 <- mean(x[idxs]) 182s + s2 <- mean2(x, idxs = idxs) 182s + stopifnot(identical(s1, s2)) 182s + 182s + # Averaging over NA_real_:s 182s + x <- rep(NA_real_, times = 5L) 182s + s1 <- mean(x, na.rm = na.rm) 182s + s2 <- mean2(x, na.rm = na.rm) 182s + stopifnot(identical(s1, s2)) 182s + 182s + x <- rep(NA_real_, times = 5L) 182s + idxs <- 1:3 182s + s1 <- mean(x[idxs], na.rm = na.rm) 182s + s2 <- mean2(x, idxs = idxs, na.rm = na.rm) 182s + stopifnot(identical(s1, s2)) 182s + 182s + # Averaging over -Inf:s 182s + x <- rep(-Inf, times = 3L) 182s + s1 <- mean(x, na.rm = na.rm) 182s + s2 <- mean2(x, na.rm = na.rm) 182s + stopifnot(identical(s1, s2)) 182s + 182s + # Averaging over +Inf:s 182s + x <- rep(+Inf, times = 3L) 182s + s1 <- mean(x, na.rm = na.rm) 182s + s2 <- mean2(x, na.rm = na.rm) 182s + stopifnot(identical(s1, s2)) 182s + 182s + # Averaging over mix of -Inf:s and +Inf:s 182s + x <- rep(c(-Inf, +Inf), times = 3L) 182s + s1 <- mean(x, na.rm = na.rm) 182s + s2 <- mean2(x, na.rm = na.rm) 182s + stopifnot(identical(s1, s2)) 182s + 182s + # Averaging over mix of -Inf:s and +Inf:s and numerics 182s + x <- rep(c(-Inf, +Inf, 3.14), times = 2L) 182s + s1 <- mean(x, na.rm = na.rm) 182s + s2 <- mean2(x, na.rm = na.rm) 182s + stopifnot(identical(s1, s2)) 182s + 182s + # Averaging over mix of NaN, NA, +Inf, and numerics 182s + x <- c(NaN, NA, +Inf, 3.14) 182s + s1 <- mean(x, na.rm = na.rm) 182s + s2 <- mean2(x, na.rm = na.rm) 182s + if (na.rm) { 182s + stopifnot(identical(s2, s1)) 182s + } else { 182s + stopifnot(is.na(s1), is.na(s2)) 182s + ## NOTE, due to compiler optimization, it is not guaranteed that NA is 182s + ## returned here (as one would expect). NaN might very well be returned, 182s + ## when both NA and NaN are involved. This is an accepted feature in R, 182s + ## which is documented in help("is.nan"). See also 182s + ## https://stat.ethz.ch/pipermail/r-devel/2017-April/074009.html. 182s + ## Thus, we cannot guarantee that s1 is identical to s0. 182s + } 182s + 182s + # Averaging over mix of NaN, NA_real_, +Inf, and numerics 182s + x <- c(NA_real_, NaN, +Inf, 3.14) 182s + s1 <- mean(x, na.rm = na.rm) 182s + s2 <- mean2(x, na.rm = na.rm) 182s + if (na.rm) { 182s + stopifnot(identical(s2, s1)) 182s + } else { 182s + stopifnot(is.na(s1), is.na(s2)) 182s + ## NOTE, due to compiler optimization, it is not guaranteed that NA is 182s + ## returned here (as one would expect). NaN might very well be returned, 182s + ## when both NA and NaN are involved. This is an accepted feature in R, 182s + ## which is documented in help("is.nan"). See also 182s + ## https://stat.ethz.ch/pipermail/r-devel/2017-April/074009.html. 182s + ## Thus, we cannot guarantee that s1 is identical to s0. 182s + } 182s + } 182s > 182s > 182s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 182s > # Argument 'idxs' 182s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 182s > x <- 1:5 182s > idxs_list <- list( 182s + integer = 1:3, 182s + double = as.double(1:3), 182s + logical = (x <= 3) 182s + ) 182s > 182s > for (idxs in idxs_list) { 182s + cat("idxs:\n") 182s + str(idxs) 182s + s1 <- mean(x[idxs], na.rm = TRUE) 182s + s2 <- mean2(x, idxs = idxs, na.rm = TRUE) 182s + stopifnot(identical(s1, s2)) 182s + } 182s idxs: 182s int [1:3] 1 2 3 182s idxs: 182s num [1:3] 1 2 3 182s idxs: 182s logi [1:5] TRUE TRUE TRUE FALSE FALSE 182s > 182s 182s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 182s Copyright (C) 2024 The R Foundation for Statistical Computing 182s Platform: x86_64-pc-linux-gnu 182s 182s R is free software and comes with ABSOLUTELY NO WARRANTY. 182s You are welcome to redistribute it under certain conditions. 182s Type 'license()' or 'licence()' for distribution details. 182s 182s R is a collaborative project with many contributors. 182s Type 'contributors()' for more information and 182s 'citation()' on how to cite R or R packages in publications. 182s 182s Type 'demo()' for some demos, 'help()' for on-line help, or 182s 'help.start()' for an HTML browser interface to help. 182s Type 'q()' to quit R. 182s 182s > library("matrixStats") 182s > 182s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 182s > # Subsetted tests 182s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 182s > source("utils/validateIndicesFramework.R") 182s > x <- runif(6, min = -6, max = 6) 182s > storage.mode(x) <- "integer" 182s > for (idxs in index_cases) { 182s + validateIndicesTestVector(x, idxs, 182s + ftest = mean2, fsure = mean, 182s + na.rm = FALSE) 182s + validateIndicesTestVector(x, idxs, 182s + ftest = mean2, fsure = mean, 182s + na.rm = TRUE) 182s + } 182s > 182s 182s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 182s Copyright (C) 2024 The R Foundation for Statistical Computing 182s Platform: x86_64-pc-linux-gnu 182s 182s R is free software and comes with ABSOLUTELY NO WARRANTY. 182s You are welcome to redistribute it under certain conditions. 182s Type 'license()' or 'licence()' for distribution details. 182s 182s R is a collaborative project with many contributors. 182s Type 'contributors()' for more information and 182s 'citation()' on how to cite R or R packages in publications. 182s 182s Type 'demo()' for some demos, 'help()' for on-line help, or 182s 'help.start()' for an HTML browser interface to help. 182s Type 'q()' to quit R. 182s 182s > library("matrixStats") 182s > 182s > for (mode in c("integer", "double")) { 182s + cat("mode: ", mode, "\n", sep = "") 182s + 182s + # Empty vector 182s + x <- 0 182s + storage.mode(x) <- mode 182s + y <- prod(x, na.rm = TRUE) 182s + print(y) 182s + z <- product(x, na.rm = TRUE) 182s + print(z) 182s + stopifnot(all.equal(z, y)) 182s + 182s + # Test negative values 182s + x <- c(1, -4, 2) 182s + storage.mode(x) <- mode 182s + y <- prod(x, na.rm = TRUE) 182s + print(y) 182s + z <- product(x, na.rm = TRUE) 182s + print(z) 182s + stopifnot(all.equal(z, y)) 182s + 182s + # Test missing values 182s + x <- c(1, NA, NaN, 2) 182s + storage.mode(x) <- mode 182s + y <- prod(x, na.rm = TRUE) 182s + print(y) 182s + z <- product(x, na.rm = TRUE) 182s + print(z) 182s + stopifnot(all.equal(z, y)) 182s + 182s + x <- c(1, NA, NaN, 2) 182s + storage.mode(x) <- mode 182s + y <- prod(x, na.rm = FALSE) 182s + print(y) 182s + z <- product(x, na.rm = FALSE) 182s + print(z) 182s + stopifnot(all(is.na(z), is.na(y))) 182s + 182s + x <- c(1, NaN, 2) 182s + storage.mode(x) <- mode 182s + y <- prod(x, na.rm = FALSE) 182s + print(y) 182s + stopifnot(is.na(y)) 182s + z <- product(x, na.rm = FALSE) 182s + print(z) 182s + stopifnot(is.na(z)) 182s + 182s + } # for (mode ...) 183s mode: integer 183s [1] 0 183s [1] 0 183s [1] -8 183s [1] -8 183s [1] 2 183s [1] 2 183s [1] NA 183s [1] NA 183s [1] NA 183s [1] NA 183s mode: double 183s [1] 0 183s [1] 0 183s [1] -8 183s [1] -8 183s [1] 2 183s [1] 2 183s [1] NA 183s [1] NA 183s [1] NaN 183s [1] NA 183s > 183s > 183s > # NAs following 0s 183s > x <- c(0L, NA_integer_) 183s > y <- prod(x, na.rm = FALSE) 183s > print(y) 183s [1] NA 183s > z <- product(x, na.rm = FALSE) 183s > print(z) 183s [1] NA 183s > stopifnot(identical(z, y)) 183s > 183s 183s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 183s Copyright (C) 2024 The R Foundation for Statistical Computing 183s Platform: x86_64-pc-linux-gnu 183s 183s R is free software and comes with ABSOLUTELY NO WARRANTY. 183s You are welcome to redistribute it under certain conditions. 183s Type 'license()' or 'licence()' for distribution details. 183s 183s R is a collaborative project with many contributors. 183s Type 'contributors()' for more information and 183s 'citation()' on how to cite R or R packages in publications. 183s 183s Type 'demo()' for some demos, 'help()' for on-line help, or 183s 'help.start()' for an HTML browser interface to help. 183s Type 'q()' to quit R. 183s 183s > library("matrixStats") 183s > 183s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 183s > # Subsetted tests 183s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 183s > source("utils/validateIndicesFramework.R") 183s > x <- runif(6, min = -6, max = 6) 183s > storage.mode(x) <- "integer" 183s > for (idxs in index_cases) { 183s + validateIndicesTestVector(x, idxs, 183s + ftest = product, fsure = prod, 183s + na.rm = TRUE) 183s + validateIndicesTestVector(x, idxs, 183s + ftest = product, fsure = prod, 183s + na.rm = FALSE) 183s + } 183s > 183s 183s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 183s Copyright (C) 2024 The R Foundation for Statistical Computing 183s Platform: x86_64-pc-linux-gnu 183s 183s R is free software and comes with ABSOLUTELY NO WARRANTY. 183s You are welcome to redistribute it under certain conditions. 183s Type 'license()' or 'licence()' for distribution details. 183s 183s R is a collaborative project with many contributors. 183s Type 'contributors()' for more information and 183s 'citation()' on how to cite R or R packages in publications. 183s 183s Type 'demo()' for some demos, 'help()' for on-line help, or 183s 'help.start()' for an HTML browser interface to help. 183s Type 'q()' to quit R. 183s 183s > library("matrixStats") 183s > library("utils") ## utils::str 183s > 183s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 183s > # Local functions 183s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 183s > psortKM_R <- function(x, k, m) { 183s + x <- sort(x) 183s + x[(k - m + 1):k] 183s + } 183s > 183s > psortKM_R2 <- function(x, k, m) { 183s + partial <- (k - m + 1):k 183s + x <- sort.int(x, partial = partial) 183s + x[partial] 183s + } 183s > 183s > 183s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 183s > # Consistency checks 183s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 183s > set.seed(1) 183s > 183s > cat("Consistency checks:\n") 183s Consistency checks: 183s > x <- 1:30 183s > x[18:20] <- 20 183s > y <- sample(x) 183s > cat("x:\n") 183s x: 183s > str(x) 183s num [1:30] 1 2 3 4 5 6 7 8 9 10 ... 183s > cat("sample(x):\n") 183s sample(x): 183s > str(y) 183s num [1:30] 25 4 7 1 2 23 11 14 20 20 ... 183s > 183s > for (k in c(1L, 2L, 20L, 21L, length(x))) { 183s + for (m in 1:min(5L, k)) { 183s + px0 <- psortKM_R(x, k = k, m = m) 183s + px0b <- psortKM_R2(x, k = k, m = m) 183s + stopifnot(identical(px0b, px0)) 183s + px1 <- matrixStats:::.psortKM(x, k = k, m = m) 183s + cat(sprintf(".psortKM(x, k = %d, m = %d):\n", k, m)) 183s + print(px1) 183s + stopifnot(identical(px1, px0)) 183s + 183s + py0 <- psortKM_R(y, k = k, m = m) 183s + py0b <- psortKM_R2(y, k = k, m = m) 183s + stopifnot(identical(py0b, py0)) 183s + py1 <- matrixStats:::.psortKM(y, k = k, m = m) 183s + cat(sprintf(".psortKM(y, k = %d, m = %d):\n", k, m)) 183s + print(py1) 183s + stopifnot(identical(py1, py0)) 183s + stopifnot(identical(py1, px1)) 183s + } # for (m ...) 183s + } # for (k ...) 183s .psortKM(x, k = 1, m = 1): 183s [1] 1 183s .psortKM(y, k = 1, m = 1): 183s [1] 1 183s .psortKM(x, k = 2, m = 1): 183s [1] 2 183s .psortKM(y, k = 2, m = 1): 183s [1] 2 183s .psortKM(x, k = 2, m = 2): 183s [1] 1 2 183s .psortKM(y, k = 2, m = 2): 183s [1] 1 2 183s .psortKM(x, k = 20, m = 1): 183s [1] 20 183s .psortKM(y, k = 20, m = 1): 183s [1] 20 183s .psortKM(x, k = 20, m = 2): 183s [1] 20 20 183s .psortKM(y, k = 20, m = 2): 183s [1] 20 20 183s .psortKM(x, k = 20, m = 3): 183s [1] 20 20 20 183s .psortKM(y, k = 20, m = 3): 183s [1] 20 20 20 183s .psortKM(x, k = 20, m = 4): 183s [1] 17 20 20 20 183s .psortKM(y, k = 20, m = 4): 183s [1] 17 20 20 20 183s .psortKM(x, k = 20, m = 5): 183s [1] 16 17 20 20 20 183s .psortKM(y, k = 20, m = 5): 183s [1] 16 17 20 20 20 183s .psortKM(x, k = 21, m = 1): 183s [1] 21 183s .psortKM(y, k = 21, m = 1): 183s [1] 21 183s .psortKM(x, k = 21, m = 2): 183s [1] 20 21 183s .psortKM(y, k = 21, m = 2): 183s [1] 20 21 183s .psortKM(x, k = 21, m = 3): 183s [1] 20 20 21 183s .psortKM(y, k = 21, m = 3): 183s [1] 20 20 21 183s .psortKM(x, k = 21, m = 4): 183s [1] 20 20 20 21 183s .psortKM(y, k = 21, m = 4): 183s [1] 20 20 20 21 183s .psortKM(x, k = 21, m = 5): 183s [1] 17 20 20 20 21 183s .psortKM(y, k = 21, m = 5): 183s [1] 17 20 20 20 21 183s .psortKM(x, k = 30, m = 1): 183s [1] 30 183s .psortKM(y, k = 30, m = 1): 183s [1] 30 183s .psortKM(x, k = 30, m = 2): 183s [1] 29 30 183s .psortKM(y, k = 30, m = 2): 183s [1] 29 30 183s .psortKM(x, k = 30, m = 3): 183s [1] 28 29 30 183s .psortKM(y, k = 30, m = 3): 183s [1] 28 29 30 183s .psortKM(x, k = 30, m = 4): 183s [1] 27 28 29 30 183s .psortKM(y, k = 30, m = 4): 183s [1] 27 28 29 30 183s .psortKM(x, k = 30, m = 5): 183s [1] 26 27 28 29 30 183s .psortKM(y, k = 30, m = 5): 183s [1] 26 27 28 29 30 183s > 183s 183s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 183s Copyright (C) 2024 The R Foundation for Statistical Computing 183s Platform: x86_64-pc-linux-gnu 183s 183s R is free software and comes with ABSOLUTELY NO WARRANTY. 183s You are welcome to redistribute it under certain conditions. 183s Type 'license()' or 'licence()' for distribution details. 183s 183s R is a collaborative project with many contributors. 183s Type 'contributors()' for more information and 183s 'citation()' on how to cite R or R packages in publications. 183s 183s Type 'demo()' for some demos, 'help()' for on-line help, or 183s 'help.start()' for an HTML browser interface to help. 183s Type 'q()' to quit R. 183s 183s > library("matrixStats") 183s > 183s > rowAlls_R <- function(x, value = TRUE, na.rm = FALSE, ..., useNames = NA) { 183s + if (is.na(value)) { 183s + res <- apply(is.na(x), MARGIN = 1L, FUN = all, na.rm = na.rm) 183s + } else { 183s + y <- x == value 183s + 183s + # Preserve dimnames attribute 183s + dim <- dim(x) # for 0xN and Mx0 cases; needed in R (< 3.4.0) 183s + if (!isTRUE(all.equal(dim(y), dim))) { 183s + dim(y) <- dim 183s + dimnames(y) <- dimnames(x) 183s + } 183s + 183s + res <- apply(y, MARGIN = 1L, FUN = all, na.rm = na.rm) 183s + } 183s + if (is.na(useNames) || !useNames) names(res) <- NULL 183s + res 183s + } 183s > 183s > rowAnys_R <- function(x, value = TRUE, na.rm = FALSE, ..., useNames = NA) { 183s + if (is.na(value)) { 183s + res <- apply(is.na(x), MARGIN = 1L, FUN = any, na.rm = na.rm) 183s + } else { 183s + y <- x == value 183s + 183s + # Preserve dimnames attribute 183s + dim <- dim(x) # for 0xN and Mx0 cases; needed in R (< 3.4.0) 183s + if (!isTRUE(all.equal(dim(y), dim))) { 183s + dim(y) <- dim 183s + dimnames(y) <- dimnames(x) 183s + } 183s + 183s + res <- apply(y, MARGIN = 1L, FUN = any, na.rm = na.rm) 183s + } 183s + if (is.na(useNames) || !useNames) names(res) <- NULL 183s + res 183s + } 183s > 183s > rowAnyMissings_R <- function(x, ..., useNames = NA) { 183s + res <- apply(x, MARGIN = 1L, FUN = anyMissing) 183s + if (is.na(useNames) || !useNames) names(res) <- NULL 183s + res 183s + } 183s > 183s > 183s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 183s > # Data type: logical 183s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 183s > x <- matrix(FALSE, nrow = 10L, ncol = 4L) 183s > x[7:8, 2:3] <- TRUE 183s > x[1:3, ] <- TRUE 183s > x[, 1] <- TRUE 183s > x[4, ] <- FALSE 183s > x[, 4] <- FALSE 183s > x[2, ] <- FALSE 183s > x[3, ] <- TRUE 183s > 183s > # To check names attribute 183s > dimnames <- list(letters[1:10], LETTERS[1:4]) 183s > 183s > for (kk in 1:3) { 183s + if (kk == 2) { 183s + x[2, 2] <- NA 183s + } else if (kk == 3) { 183s + x[, 2] <- NA 183s + x[2, ] <- NA 183s + } 183s + 183s + # Test with and without dimnames on x 183s + for (setDimnames in c(TRUE, FALSE)) { 183s + dimnames(x) <- if (setDimnames) dimnames else NULL 183s + 183s + for (na.rm in c(FALSE, TRUE)) { 183s + # Check names attribute 183s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 183s + m0 <- rowAlls_R(x, na.rm = na.rm, useNames = useNames) 183s + m1 <- rowAlls(x, na.rm = na.rm, useNames = useNames) 183s + m2 <- colAlls(t(x), na.rm = na.rm, useNames = useNames) 183s + str(list("all()", m0 = m0, m1 = m1, m2 = m2)) 183s + stopifnot(identical(m1, m0)) 183s + stopifnot(identical(m2, m0)) 183s + 183s + m0 <- rowAnys_R(x, na.rm = na.rm, useNames = useNames) 183s + m1 <- rowAnys(x, na.rm = na.rm, useNames = useNames) 183s + m2 <- colAnys(t(x), na.rm = na.rm, useNames = useNames) 183s + str(list("any()", m0 = m0, m1 = m1, m2 = m2)) 183s + stopifnot(identical(m1, m0)) 183s + stopifnot(identical(m2, m0)) 183s + 183s + m0 <- rowAnyMissings_R(x, useNames = useNames) 183s + m1 <- rowAnyMissings(x, useNames = useNames) 183s + m2 <- colAnyMissings(t(x), useNames = useNames) 183s + str(list("anyMissing()", m0 = m0, m1 = m1, m2 = m2)) 183s + stopifnot(identical(m1, m0)) 183s + stopifnot(identical(m2, m0)) 183s + } 183s + } 183s + } 183s + } # for (kk ...) 183s List of 4 183s $ : chr "all()" 183s $ m0: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 183s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 183s $ m1: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 183s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 183s $ m2: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 183s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 183s List of 4 183s $ : chr "any()" 183s $ m0: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 183s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 183s $ m1: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 183s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 183s $ m2: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 183s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 183s List of 4 183s $ : chr "anyMissing()" 183s $ m0: Named logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 183s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 183s $ m1: Named logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 183s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 183s $ m2: Named logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 183s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 183s List of 4 183s $ : chr "all()" 183s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 183s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 183s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 183s List of 4 183s $ : chr "any()" 183s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 183s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 183s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 183s List of 4 183s $ : chr "anyMissing()" 183s $ m0: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 183s $ m1: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 183s $ m2: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 183s List of 4 183s $ : chr "all()" 183s $ m0: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 183s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 183s $ m1: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 183s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 183s $ m2: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 183s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 183s List of 4 183s $ : chr "any()" 183s $ m0: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 183s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 183s $ m1: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 183s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 183s $ m2: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 183s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 183s List of 4 183s $ : chr "anyMissing()" 183s $ m0: Named logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 183s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 183s $ m1: Named logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 183s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 183s $ m2: Named logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 183s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 183s List of 4 183s $ : chr "all()" 183s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 183s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 183s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 183s List of 4 183s $ : chr "any()" 183s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 183s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 183s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 183s List of 4 183s $ : chr "anyMissing()" 183s $ m0: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 183s $ m1: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 183s $ m2: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 183s List of 4 183s $ : chr "all()" 183s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 183s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 183s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 183s List of 4 183s $ : chr "any()" 183s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 183s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 183s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 183s List of 4 183s $ : chr "anyMissing()" 183s $ m0: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 183s $ m1: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 183s $ m2: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 183s List of 4 183s $ : chr "all()" 183s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 183s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 183s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 183s List of 4 183s $ : chr "any()" 183s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 183s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 183s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 183s List of 4 183s $ : chr "anyMissing()" 183s $ m0: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 183s $ m1: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 183s $ m2: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 183s List of 4 183s $ : chr "all()" 183s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 183s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 183s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 183s List of 4 183s $ : chr "any()" 183s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 183s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 183s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 183s List of 4 183s $ : chr "anyMissing()" 183s $ m0: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 183s $ m1: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 183s $ m2: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 183s List of 4 183s $ : chr "all()" 183s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 183s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 183s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 183s List of 4 183s $ : chr "any()" 183s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 183s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 183s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 183s List of 4 183s $ : chr "anyMissing()" 183s $ m0: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 183s $ m1: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 183s $ m2: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 183s List of 4 183s $ : chr "all()" 183s $ m0: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 183s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 183s $ m1: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 183s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 183s $ m2: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 183s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 183s List of 4 183s $ : chr "any()" 183s $ m0: Named logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 183s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 183s $ m1: Named logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 183s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 183s $ m2: Named logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 183s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 183s List of 4 183s $ : chr "anyMissing()" 183s $ m0: Named logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 183s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 183s $ m1: Named logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 183s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 183s $ m2: Named logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 183s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 183s List of 4 183s $ : chr "all()" 183s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 183s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 183s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 183s List of 4 183s $ : chr "any()" 183s $ m0: logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 183s $ m1: logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 183s $ m2: logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 183s List of 4 183s $ : chr "anyMissing()" 183s $ m0: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 183s $ m1: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 183s $ m2: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 183s List of 4 183s $ : chr "all()" 183s $ m0: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 183s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 183s $ m1: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 183s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 183s $ m2: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 183s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 183s List of 4 183s $ : chr "any()" 183s $ m0: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 183s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 183s $ m1: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 183s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 183s $ m2: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 183s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 183s List of 4 183s $ : chr "anyMissing()" 183s $ m0: Named logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 183s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 183s $ m1: Named logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 183s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 183s $ m2: Named logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 183s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 183s List of 4 183s $ : chr "all()" 183s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 183s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 183s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 183s List of 4 183s $ : chr "any()" 183s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 183s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 183s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 183s List of 4 183s $ : chr "anyMissing()" 183s $ m0: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 183s $ m1: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 183s $ m2: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 183s List of 4 183s $ : chr "all()" 183s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 183s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 183s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 183s List of 4 183s $ : chr "any()" 183s $ m0: logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 183s $ m1: logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 183s $ m2: logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 183s List of 4 183s $ : chr "anyMissing()" 183s $ m0: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 183s $ m1: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 183s $ m2: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 183s List of 4 183s $ : chr "all()" 183s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 183s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 183s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 183s List of 4 183s $ : chr "any()" 183s $ m0: logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 183s $ m1: logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 183s $ m2: logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 183s List of 4 183s $ : chr "anyMissing()" 183s $ m0: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 183s $ m1: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 183s $ m2: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 183s List of 4 183s $ : chr "all()" 183s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 183s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 183s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 183s List of 4 183s $ : chr "any()" 183s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 183s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 183s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 183s List of 4 183s $ : chr "anyMissing()" 183s $ m0: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 183s $ m1: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 183s $ m2: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 183s List of 4 183s $ : chr "all()" 183s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 183s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 183s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 183s List of 4 183s $ : chr "any()" 183s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 183s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 183s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 183s List of 4 183s $ : chr "anyMissing()" 183s $ m0: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 183s $ m1: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 183s $ m2: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 183s List of 4 183s $ : chr "all()" 183s $ m0: Named logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 183s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 183s $ m1: Named logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 183s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 183s $ m2: Named logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 183s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 183s List of 4 183s $ : chr "any()" 183s $ m0: Named logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 183s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 183s $ m1: Named logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 183s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 183s $ m2: Named logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 183s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 183s List of 4 183s $ : chr "anyMissing()" 183s $ m0: Named logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 183s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 183s $ m1: Named logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 183s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 183s $ m2: Named logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 183s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 183s List of 4 183s $ : chr "all()" 183s $ m0: logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 183s $ m1: logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 183s $ m2: logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 183s List of 4 183s $ : chr "any()" 183s $ m0: logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 183s $ m1: logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 183s $ m2: logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 183s List of 4 183s $ : chr "anyMissing()" 183s $ m0: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 183s $ m1: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 183s $ m2: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 183s List of 4 183s $ : chr "all()" 183s $ m0: Named logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 183s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 183s $ m1: Named logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 183s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 183s $ m2: Named logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 183s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 183s List of 4 183s $ : chr "any()" 183s $ m0: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 183s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 183s $ m1: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 183s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 183s $ m2: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 183s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 183s List of 4 183s $ : chr "anyMissing()" 183s $ m0: Named logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 183s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 183s $ m1: Named logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 183s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 183s $ m2: Named logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 183s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 183s List of 4 183s $ : chr "all()" 183s $ m0: logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 183s $ m1: logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 183s $ m2: logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 183s List of 4 183s $ : chr "any()" 183s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 183s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 183s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 183s List of 4 183s $ : chr "anyMissing()" 183s $ m0: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 183s $ m1: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 183s $ m2: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 183s List of 4 183s $ : chr "all()" 183s $ m0: logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 183s $ m1: logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 183s $ m2: logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 183s List of 4 183s $ : chr "any()" 183s $ m0: logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 183s $ m1: logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 183s $ m2: logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 183s List of 4 183s $ : chr "anyMissing()" 183s $ m0: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 183s $ m1: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 183s $ m2: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 183s List of 4 183s $ : chr "all()" 183s $ m0: logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 183s $ m1: logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 183s $ m2: logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 183s List of 4 183s $ : chr "any()" 183s $ m0: logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 183s $ m1: logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 183s $ m2: logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 183s List of 4 183s $ : chr "anyMissing()" 183s $ m0: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 183s $ m1: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 183s $ m2: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 183s List of 4 183s $ : chr "all()" 183s $ m0: logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 183s $ m1: logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 183s $ m2: logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 183s List of 4 183s $ : chr "any()" 183s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 183s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 183s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 183s List of 4 183s $ : chr "anyMissing()" 183s $ m0: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 183s $ m1: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 183s $ m2: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 183s List of 4 183s $ : chr "all()" 183s $ m0: logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 183s $ m1: logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 183s $ m2: logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 183s List of 4 183s $ : chr "any()" 183s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 183s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 183s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 183s List of 4 183s $ : chr "anyMissing()" 183s $ m0: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 183s $ m1: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 183s $ m2: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 183s > 183s > 183s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 183s > # Data type: integer 183s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 183s > x <- matrix(rep(1:6, length.out = 4 * 5), nrow = 4L, ncol = 5L) 183s > x[2, ] <- 7L 183s > x[3, 1] <- 7L 183s > x[2:3, 3:4] <- NA_integer_ 183s > 183s > # To check names attribute 183s > dimnames <- list(letters[1:4], LETTERS[1:5]) 183s > 183s > # Row/column counts 183s > value <- 7L 183s > 183s > # Test with and without dimnames on x 183s > for (setDimnames in c(TRUE, FALSE)) { 183s + dimnames(x) <- if (setDimnames) dimnames else NULL 183s + for (na.rm in c(FALSE, TRUE)) { 183s + # Check names attribute 183s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 183s + r0 <- rowAlls_R(x, value = value, na.rm = na.rm, useNames = useNames) 183s + r1 <- rowAlls(x, value = value, na.rm = na.rm, useNames = useNames) 183s + r2 <- colAlls(t(x), value = value, na.rm = na.rm, useNames = useNames) 183s + stopifnot(identical(r1, r0)) 183s + stopifnot(identical(r2, r1)) 183s + if (!is.na(useNames) && !useNames && !setDimnames) { 183s + for (rr in seq_len(nrow(x))) { 183s + c <- allValue(x[rr, ], value = value, na.rm = na.rm) 183s + stopifnot(identical(c, r1[rr])) 183s + c <- allValue(x[rr, ], value = value, na.rm = na.rm) 183s + stopifnot(identical(c, r1[rr])) 183s + } 183s + } 183s + 183s + r0 <- rowAnys_R(x, value = value, na.rm = na.rm, useNames = useNames) 183s + r1 <- rowAnys(x, value = value, na.rm = na.rm, useNames = useNames) 183s + r2 <- colAnys(t(x), value = value, na.rm = na.rm, useNames = useNames) 183s + stopifnot(identical(r1, r0)) 183s + stopifnot(identical(r2, r1)) 183s + if (!is.na(useNames) && !useNames && !setDimnames) { 183s + for (rr in seq_len(nrow(x))) { 183s + c <- anyValue(x[rr, ], value = value, na.rm = na.rm) 183s + stopifnot(identical(c, r1[rr])) 183s + c <- anyValue(x[rr, ], value = value, na.rm = na.rm) 183s + stopifnot(identical(c, r1[rr])) 183s + } 183s + } 183s + } 183s + } 183s + } 183s > 183s > 183s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 183s > # rowAlls(x) et al. on numeric 'x' with logical 'value' 183s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 183s > x <- matrix(0, nrow = 4L, ncol = 5L) 183s > x[2:4, 2] <- (1:3) / 4 183s > x[2, 2:4] <- (1:3) / 4 183s > x[3:4, 3] <- (3:4) / 4 183s > x[3, 3:4] <- (3:4) / 4 183s > x[1:4, 5] <- (1:4) / 5 183s > x[4, 4] <- NA_real_ 183s > 183s > # To check names attribute 183s > dimnames <- list(letters[1:4], LETTERS[1:5]) 183s > 183s > for (value in c(TRUE, FALSE)) { 183s + for (na.rm in c(FALSE, TRUE)) { 183s + y0 <- suppressWarnings(apply(x, MARGIN = 1L, FUN = function(e) any(as.logical(e) == value, na.rm = na.rm))) 183s + y <- rowAnys(x, na.rm = na.rm, value = value) 183s + stopifnot(identical(y, y0)) 183s + # Check names attribute 183s + dimnames(x) <- dimnames 183s + y <- rowAnys(x, na.rm = na.rm, value = value, useNames = FALSE) 183s + stopifnot(all.equal(y, y0)) 183s + y0 <- suppressWarnings(apply(x, MARGIN = 1L, FUN = function(e) any(as.logical(e) == value, na.rm = na.rm))) 183s + y <- rowAnys(x, na.rm = na.rm, value = value, useNames = TRUE) 183s + stopifnot(all.equal(y, y0)) 183s + dimnames(x) <- NULL 183s + 183s + y0 <- suppressWarnings(apply(x, MARGIN = 2L, FUN = function(e) any(as.logical(e) == value, na.rm = na.rm))) 183s + y <- colAnys(x, na.rm = na.rm, value = value) 183s + stopifnot(identical(y, y0)) 183s + # Check names attribute 183s + dimnames(x) <- dimnames 183s + y <- colAnys(x, na.rm = na.rm, value = value, useNames = FALSE) 183s + stopifnot(all.equal(y, y0)) 183s + y0 <- suppressWarnings(apply(x, MARGIN = 2L, FUN = function(e) any(as.logical(e) == value, na.rm = na.rm))) 183s + y <- colAnys(x, na.rm = na.rm, value = value, useNames = TRUE) 183s + stopifnot(all.equal(y, y0)) 183s + dimnames(x) <- NULL 183s + 183s + y0 <- suppressWarnings(apply(x, MARGIN = 1L, FUN = function(e) all(as.logical(e) == value, na.rm = na.rm))) 183s + y <- rowAlls(x, na.rm = na.rm, value = value) 183s + stopifnot(identical(y, y0)) 183s + # Check names attribute 183s + dimnames(x) <- dimnames 183s + y <- rowAlls(x, na.rm = na.rm, value = value, useNames = FALSE) 183s + stopifnot(all.equal(y, y0)) 183s + y0 <- suppressWarnings(apply(x, MARGIN = 1L, FUN = function(e) all(as.logical(e) == value, na.rm = na.rm))) 183s + y <- rowAlls(x, na.rm = na.rm, value = value, useNames = TRUE) 183s + stopifnot(all.equal(y, y0)) 183s + dimnames(x) <- NULL 183s + 183s + y0 <- suppressWarnings(apply(x, MARGIN = 2L, FUN = function(e) all(as.logical(e) == value, na.rm = na.rm))) 183s + y <- colAlls(x, na.rm = na.rm, value = value) 183s + stopifnot(identical(y, y0)) 183s + print(y0) 183s + # Check names attribute 183s + dimnames(x) <- dimnames 183s + y <- colAlls(x, na.rm = na.rm, value = value, useNames = FALSE) 183s + stopifnot(all.equal(y, y0)) 183s + y0 <- suppressWarnings(apply(x, MARGIN = 2L, FUN = function(e) all(as.logical(e) == value, na.rm = na.rm))) 183s + y <- colAlls(x, na.rm = na.rm, value = value, useNames = TRUE) 183s + stopifnot(all.equal(y, y0)) 183s + dimnames(x) <- NULL 183s + } ## for (na.rm ...) 183s + } ## for(value ...) 184s [1] FALSE FALSE FALSE FALSE TRUE 184s [1] FALSE FALSE FALSE FALSE TRUE 184s [1] TRUE FALSE FALSE FALSE FALSE 184s [1] TRUE FALSE FALSE FALSE FALSE 184s > 184s > 184s > 184s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 184s > # Data type: character (not sure if this should be supported) 184s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 184s > all_R <- function(x, value = TRUE, ...) { 184s + if (is.na(value)) { 184s + all(is.na(x), ...) 184s + } else { 184s + all(x == value, ...) 184s + } 184s + } 184s > 184s > any_R <- function(x, value = TRUE, ...) { 184s + if (is.na(value)) { 184s + any(is.na(x), ...) 184s + } else { 184s + any(x == value, ...) 184s + } 184s + } 184s > 184s > x <- matrix(rep(letters, length.out = 10 * 5), nrow = 10L, ncol = 5L) 184s > x[2, ] <- "g" 184s > x[2:4, 3:4] <- NA_character_ 184s > 184s > # To check names attribute 184s > dimnames <- list(letters[1:10], LETTERS[1:5]) 184s > 184s > # Test with and without dimnames on x 184s > for (setDimnames in c(TRUE, FALSE)) { 184s + dimnames(x) <- if (setDimnames) dimnames else NULL 184s + 184s + # Row/column counts 184s + for (value in c("g", NA_character_)) { 184s + for (na.rm in c(FALSE, TRUE)) { 184s + # Check names attribute 184s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 184s + r0 <- rowAlls_R(x, value = value, na.rm = na.rm, useNames = useNames) 184s + r1 <- rowAlls(x, value = value, na.rm = na.rm, useNames = useNames) 184s + r2 <- colAlls(t(x), value = value, na.rm = na.rm, useNames = useNames) 184s + stopifnot(identical(r1, r0)) 184s + stopifnot(identical(r2, r1)) 184s + if (!is.na(useNames) && !useNames && !setDimnames) { 184s + for (rr in seq_len(nrow(x))) { 184s + c0 <- all_R(x[rr, ], value, na.rm = na.rm) 184s + c <- allValue(x[rr, ], value = value, na.rm = na.rm) 184s + stopifnot(identical(c, r1[rr])) 184s + stopifnot(identical(c, c0)) 184s + } 184s + } 184s + 184s + r0 <- rowAnys_R(x, value = value, na.rm = na.rm, useNames = useNames) 184s + r1 <- rowAnys(x, value = value, na.rm = na.rm, useNames = useNames) 184s + r2 <- colAnys(t(x), value = value, na.rm = na.rm, useNames = useNames) 184s + stopifnot(identical(r1, r0)) 184s + stopifnot(identical(r2, r1)) 184s + if (!is.na(useNames) && !useNames && !setDimnames) { 184s + for (rr in seq_len(nrow(x))) { 184s + c0 <- any_R(x[rr, ], value, na.rm = na.rm) 184s + c <- anyValue(x[rr, ], value = value, na.rm = na.rm) 184s + stopifnot(identical(c, c0)) 184s + stopifnot(identical(c, r1[rr])) 184s + } 184s + } 184s + } 184s + } 184s + } 184s + } 184s > 184s > 184s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 184s > # NA 0 test 184s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 184s > x <- matrix(0, nrow = 3L, ncol = 3L) 184s > x[1, ] <- c(NA_real_, NA_real_, 0) 184s > x[3, ] <- c(1, 0, 1) 184s > 184s > dimnames <- list(letters[1:3], LETTERS[1:3]) 184s > 184s > # Test with and without dimnames on x 184s > for (setDimnames in c(TRUE, FALSE)) { 184s + dimnames(x) <- if (setDimnames) dimnames else NULL 184s + # Check names attribute 184s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 184s + r0 <- rowAnys_R(x, value = 0, useNames = useNames) 184s + r1 <- rowAnys(x, value = 0, useNames = useNames) 184s + stopifnot(identical(r0, r1)) 184s + } 184s + } 184s > 184s 184s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 184s Copyright (C) 2024 The R Foundation for Statistical Computing 184s Platform: x86_64-pc-linux-gnu 184s 184s R is free software and comes with ABSOLUTELY NO WARRANTY. 184s You are welcome to redistribute it under certain conditions. 184s Type 'license()' or 'licence()' for distribution details. 184s 184s R is a collaborative project with many contributors. 184s Type 'contributors()' for more information and 184s 'citation()' on how to cite R or R packages in publications. 184s 184s Type 'demo()' for some demos, 'help()' for on-line help, or 184s 'help.start()' for an HTML browser interface to help. 184s Type 'q()' to quit R. 184s 184s > library("matrixStats") 184s > 184s > rowAlls_R <- function(x, value = TRUE, na.rm = FALSE, ..., useNames = NA) { 184s + if (is.na(value)) { 184s + res <- apply(is.na(x), MARGIN = 1L, FUN = all, na.rm = na.rm) 184s + } else { 184s + y <- x == value 184s + 184s + # Preserve dimnames attribute 184s + dim <- dim(x) # for 0xN and Mx0 cases; needed in R (< 3.4.0) 184s + if (!isTRUE(all.equal(dim(y), dim))) { 184s + dim(y) <- dim 184s + dimnames(y) <- dimnames(x) 184s + } 184s + 184s + res <- apply(y, MARGIN = 1L, FUN = all, na.rm = na.rm) 184s + } 184s + if (is.na(useNames) || !useNames) names(res) <- NULL 184s + res 184s + } 184s > 184s > rowAnys_R <- function(x, value = TRUE, na.rm = FALSE, ..., useNames = NA) { 184s + if (is.na(value)) { 184s + res <- apply(is.na(x), MARGIN = 1L, FUN = any, na.rm = na.rm) 184s + } else { 184s + y <- x == value 184s + 184s + # Preserve dimnames attribute 184s + dim <- dim(x) # for 0xN and Mx0 cases; needed in R (< 3.4.0) 184s + if (!isTRUE(all.equal(dim(y), dim))) { 184s + dim(y) <- dim 184s + dimnames(y) <- dimnames(x) 184s + } 184s + 184s + res <- apply(y, MARGIN = 1L, FUN = any, na.rm = na.rm) 184s + } 184s + if (is.na(useNames) || !useNames) names(res) <- NULL 184s + res 184s + } 184s > 184s > rowAnyMissings_R <- function(x, ..., useNames = NA) { 184s + res <- apply(x, MARGIN = 1L, FUN = anyMissing) 184s + if (is.na(useNames) || !useNames) names(res) <- NULL 184s + res 184s + } 184s > 184s > 184s > all_R <- function(x, value = TRUE, ...) { 184s + if (is.na(value)) { 184s + all(is.na(x), ...) 184s + } else { 184s + all(x == value, ...) 184s + } 184s + } 184s > 184s > any_R <- function(x, value = TRUE, ...) { 184s + if (is.na(value)) { 184s + any(is.na(x), ...) 184s + } else { 184s + any(x == value, ...) 184s + } 184s + } 184s > 184s > 184s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 184s > # Subsetted tests 184s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 184s > source("utils/validateIndicesFramework.R") 184s > x <- matrix(runif(6 * 6, min = -3, max = 3), nrow = 6, ncol = 6) 184s > storage.mode(x) <- "integer" 184s > x[2:3, ] <- NA_integer_ 184s > x[2, 1] <- 0L 184s > x[4:5, ] <- 0L 184s > x[4, 6] <- NA_integer_ 184s > 184s > # To check names attribute 184s > dimnames <- list(letters[1:6], LETTERS[1:6]) 184s > 184s > # Test with and without dimnames on x 184s > for (setDimnames in c(TRUE, FALSE)) { 184s + if (setDimnames) dimnames(x) <- dimnames 184s + else dimnames(x) <- NULL 184s + 184s + count <- 0L 184s + for (rows in index_cases) { 184s + for (cols in index_cases) { 184s + count <- count + 1L 184s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 184s + useNames <- c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE) 184s + useNames <- useNames[count %% length(useNames) + 1] 184s + 184s + validateIndicesTestMatrix(x, rows, cols, 184s + ftest = rowAlls, fsure = rowAlls_R, 184s + value = 0, na.rm = TRUE, useNames = useNames) 184s + validateIndicesTestMatrix(x, rows, cols, 184s + ftest = rowAlls, fsure = rowAlls_R, 184s + value = 0, na.rm = FALSE, useNames = useNames) 184s + validateIndicesTestMatrix(x, rows, cols, 184s + ftest = rowAlls, fsure = rowAlls_R, 184s + value = NA_integer_, useNames = useNames) 184s + validateIndicesTestMatrix(x, rows, cols, 184s + fcoltest = colAlls, fsure = rowAlls_R, 184s + value = 0, na.rm = TRUE, useNames = useNames) 184s + validateIndicesTestMatrix(x, rows, cols, 184s + fcoltest = colAlls, fsure = rowAlls_R, 184s + value = 0, na.rm = FALSE, useNames = useNames) 184s + validateIndicesTestMatrix(x, rows, cols, 184s + fcoltest = colAlls, fsure = rowAlls_R, 184s + value = NA_integer_, useNames = useNames) 184s + 184s + validateIndicesTestMatrix(x, rows, cols, 184s + ftest = rowAnys, fsure = rowAnys_R, 184s + value = 0, na.rm = TRUE, useNames = useNames) 184s + validateIndicesTestMatrix(x, rows, cols, 184s + ftest = rowAnys, fsure = rowAnys_R, 184s + value = 0, na.rm = FALSE, useNames = useNames) 184s + validateIndicesTestMatrix(x, rows, cols, 184s + ftest = rowAnys, fsure = rowAnys_R, 184s + value = NA_integer_, useNames = useNames) 184s + validateIndicesTestMatrix(x, rows, cols, 184s + fcoltest = colAnys, fsure = rowAnys_R, 184s + value = 0, na.rm = TRUE, useNames = useNames) 184s + validateIndicesTestMatrix(x, rows, cols, 184s + fcoltest = colAnys, fsure = rowAnys_R, 184s + value = 0, na.rm = FALSE, useNames = useNames) 184s + validateIndicesTestMatrix(x, rows, cols, 184s + fcoltest = colAnys, fsure = rowAnys_R, 184s + value = NA_integer_, useNames = useNames) 184s + 184s + validateIndicesTestMatrix(x, rows, cols, 184s + ftest = rowAnyMissings, 184s + fsure = rowAnyMissings_R, useNames = useNames) 184s + validateIndicesTestMatrix(x, rows, cols, 184s + fcoltest = colAnyMissings, 184s + fsure = rowAnyMissings_R, useNames = useNames) 184s + } 184s + } 184s + } 185s > 185s > for (rr in seq_len(nrow(x))) { 185s + for (idxs in index_cases) { 185s + validateIndicesTestVector(x[rr, ], idxs, 185s + ftest = allValue, fsure = all_R, 185s + value = 0, na.rm = TRUE) 185s + validateIndicesTestVector(x[rr, ], idxs, 185s + ftest = allValue, fsure = all_R, 185s + value = 0, na.rm = FALSE) 185s + validateIndicesTestVector(x[rr, ], idxs, 185s + ftest = allValue, fsure = all_R, 185s + value = NA_integer_) 185s + 185s + validateIndicesTestVector(x[rr, ], idxs, 185s + ftest = anyValue, fsure = any_R, 185s + value = 0, na.rm = TRUE) 185s + validateIndicesTestVector(x[rr, ], idxs, 185s + ftest = anyValue, fsure = any_R, 185s + value = 0, na.rm = FALSE) 185s + validateIndicesTestVector(x[rr, ], idxs, 185s + ftest = anyValue, fsure = any_R, 185s + value = NA_integer_) 185s + } 185s + } 185s > 185s > 185s > storage.mode(x) <- "character" 185s > # Test with and without dimnames on x 185s > for (setDimnames in c(TRUE, FALSE)) { 185s + if (setDimnames) dimnames(x) <- dimnames 185s + else dimnames(x) <- NULL 185s + for (rows in index_cases) { 185s + for (cols in index_cases) { 185s + # Check names attribute 185s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 185s + validateIndicesTestMatrix(x, rows, cols, 185s + ftest = rowAlls, fsure = rowAlls_R, 185s + value = "0", na.rm = TRUE, useNames = useNames) 185s + validateIndicesTestMatrix(x, rows, cols, 185s + ftest = rowAlls, fsure = rowAlls_R, 185s + value = "0", na.rm = FALSE, useNames = useNames) 185s + validateIndicesTestMatrix(x, rows, cols, 185s + ftest = rowAlls, fsure = rowAlls_R, 185s + value = NA_character_, useNames = useNames) 185s + validateIndicesTestMatrix(x, rows, cols, 185s + fcoltest = colAlls, fsure = rowAlls_R, 185s + value = "0", na.rm = TRUE, useNames = useNames) 185s + validateIndicesTestMatrix(x, rows, cols, 185s + fcoltest = colAlls, fsure = rowAlls_R, 185s + value = "0", na.rm = FALSE, useNames = useNames) 185s + validateIndicesTestMatrix(x, rows, cols, 185s + fcoltest = colAlls, fsure = rowAlls_R, 185s + value = NA_character_, useNames = useNames) 185s + 185s + validateIndicesTestMatrix(x, rows, cols, 185s + ftest = rowAnys, fsure = rowAnys_R, 185s + value = "0", na.rm = TRUE, useNames = useNames) 185s + validateIndicesTestMatrix(x, rows, cols, 185s + ftest = rowAnys, fsure = rowAnys_R, 185s + value = "0", na.rm = FALSE, useNames = useNames) 185s + validateIndicesTestMatrix(x, rows, cols, 185s + ftest = rowAnys, fsure = rowAnys_R, 185s + value = NA_character_, useNames = useNames) 185s + validateIndicesTestMatrix(x, rows, cols, 185s + fcoltest = colAnys, fsure = rowAnys_R, 185s + value = "0", na.rm = TRUE, useNames = useNames) 185s + validateIndicesTestMatrix(x, rows, cols, 185s + fcoltest = colAnys, fsure = rowAnys_R, 185s + value = "0", na.rm = FALSE, useNames = useNames) 185s + validateIndicesTestMatrix(x, rows, cols, 185s + fcoltest = colAnys, fsure = rowAnys_R, 185s + value = NA_character_, useNames = useNames) 185s + 185s + validateIndicesTestMatrix(x, rows, cols, 185s + ftest = rowAnyMissings, 185s + fsure = rowAnyMissings_R, useNames = useNames) 185s + validateIndicesTestMatrix(x, rows, cols, 185s + fcoltest = colAnyMissings, 185s + fsure = rowAnyMissings_R, useNames = useNames) 185s + } 185s + } 185s + } 185s + } 188s > 188s > for (rr in seq_len(nrow(x))) { 188s + for (idxs in index_cases) { 188s + validateIndicesTestVector(x[rr, ], idxs, 188s + ftest = allValue, fsure = all_R, 188s + value = "0", na.rm = TRUE) 188s + validateIndicesTestVector(x[rr, ], idxs, 188s + ftest = allValue, fsure = all_R, 188s + value = "0", na.rm = FALSE) 188s + validateIndicesTestVector(x[rr, ], idxs, 188s + ftest = allValue, fsure = all_R, 188s + value = NA_integer_) 188s + 188s + validateIndicesTestVector(x[rr, ], idxs, 188s + ftest = anyValue, fsure = any_R, 188s + value = "0", na.rm = TRUE) 188s + validateIndicesTestVector(x[rr, ], idxs, 188s + ftest = anyValue, fsure = any_R, 188s + value = "0", na.rm = FALSE) 188s + validateIndicesTestVector(x[rr, ], idxs, 188s + ftest = anyValue, fsure = any_R, 188s + value = NA_integer_) 188s + } 188s + } 188s > 188s 188s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 188s Copyright (C) 2024 The R Foundation for Statistical Computing 188s Platform: x86_64-pc-linux-gnu 188s 188s R is free software and comes with ABSOLUTELY NO WARRANTY. 188s You are welcome to redistribute it under certain conditions. 188s Type 'license()' or 'licence()' for distribution details. 188s 188s R is a collaborative project with many contributors. 188s Type 'contributors()' for more information and 188s 'citation()' on how to cite R or R packages in publications. 188s 188s Type 'demo()' for some demos, 'help()' for on-line help, or 188s 'help.start()' for an HTML browser interface to help. 188s Type 'q()' to quit R. 188s 188s > library("matrixStats") 188s > 188s > X <- matrix(rnorm(20 * 6), nrow = 20, ncol = 6) 188s > rownames(X) <- LETTERS[1:nrow(X)] 188s > colnames(X) <- letters[1:ncol(X)] 188s > print(X) 188s a b c d e f 188s A 1.00126396 0.57498269 -0.53539482 0.71949006 -0.06034058 -1.3237818171 188s B 0.60589040 0.39643101 0.41556486 1.96034393 -2.17392688 0.1744422322 188s C 0.68378484 -1.16423386 1.15658085 -0.70182028 -1.82948814 -0.1926190496 188s D -0.56939507 0.55679782 -0.89553899 0.14479869 0.66228719 -0.0005286799 188s E 0.12821126 0.47953462 0.08572031 -1.14099087 -0.27079744 1.1936491916 188s F 0.72151079 0.73903748 -1.56351825 -0.06263680 -1.27031539 -0.5076428947 188s G -0.20019476 -0.16108449 -1.73430660 -0.75914864 -0.25168881 0.9249652224 188s H -0.54013492 0.56827747 -2.61308892 -0.25963215 1.46432357 0.6050879973 188s I -0.28207825 0.74935555 -0.37783713 0.27210946 -0.16465321 -0.9154491103 188s J 0.46554053 1.14937234 0.88040057 2.06671777 -2.24454489 -2.1025252634 188s K 1.10590754 -0.50096365 -0.70175287 0.42252246 0.32876219 -0.5391087999 188s L -0.04406881 -0.55401749 0.68162643 -0.96006649 -1.02124753 0.7468691075 188s M 0.34669613 -1.18857945 -0.92702434 -0.97033827 0.67521823 -0.3780876696 188s N -0.23832976 0.05284645 0.04471755 0.03341009 -1.01730186 1.4292235180 188s O 0.60460621 0.63155682 -0.12899836 0.79340993 0.91570536 1.6556617662 188s P -0.49422937 -1.65677664 -0.31394881 -0.65053681 0.07918951 0.2564287407 188s Q -0.26731022 -2.16891017 -0.52673729 -0.38889102 -0.18659413 0.8614480293 188s R 0.08834804 0.06807860 -0.97570980 1.60213118 -1.37766428 0.4992143963 188s S -0.15432694 -0.60223372 1.61171302 -1.19286143 0.09967702 0.8998517489 188s T 0.24643994 0.16815664 1.87727554 0.29260814 -0.11402043 0.1024281405 188s > 188s > 188s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 188s > # Apply rowMeans() for 3 sets of 2 columns 188s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 188s > nbr_of_sets <- 3L 188s > S <- matrix(1:ncol(X), ncol = nbr_of_sets) 188s > colnames(S) <- sprintf("s%d", 1:nbr_of_sets) 188s > print(S) 188s s1 s2 s3 188s [1,] 1 3 5 188s [2,] 2 4 6 188s > 188s > Z <- rowAvgsPerColSet(X, S = S) 188s > print(Z) 188s s1 s2 s3 188s A 0.788123327 0.09204762 -0.692061197 188s B 0.501160703 1.18795439 -0.999742326 188s C -0.240224513 0.22738029 -1.011053596 188s D -0.006298624 -0.37537015 0.330879255 188s E 0.303872941 -0.52763528 0.461425878 188s F 0.730274140 -0.81307753 -0.888979140 188s G -0.180639624 -1.24672762 0.336638206 188s H 0.014071273 -1.43636053 1.034705783 188s I 0.233638650 -0.05286383 -0.540051160 188s J 0.807456436 1.47355917 -2.173535079 188s K 0.302471942 -0.13961521 -0.105173306 188s L -0.299043146 -0.13922003 -0.137189210 188s M -0.420941660 -0.94868131 0.148565279 188s N -0.092741657 0.03906382 0.205960831 188s O 0.618081517 0.33220579 1.285683565 188s P -1.075503008 -0.48224281 0.167809126 188s Q -1.218110192 -0.45781415 0.337426948 188s R 0.078213320 0.31321069 -0.439224941 188s S -0.378280327 0.20942580 0.499764386 188s T 0.207298289 1.08494184 -0.005796147 188s > 188s > # Validation 188s > Z0 <- cbind(s1 = rowMeans(X[, 1:2]), s2 = rowMeans(X[, 3:4]), 188s + s3 = rowMeans(X[, 5:6])) 188s > stopifnot(identical(drop(Z), Z0)) 188s > 188s > 188s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 188s > # Apply colMeans() for 5 sets of 4 rows 188s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 188s > nbr_of_sets <- 5L 188s > S <- matrix(1:nrow(X), ncol = nbr_of_sets) 188s > colnames(S) <- sprintf("s%d", 1:nbr_of_sets) 188s > print(S) 188s s1 s2 s3 s4 s5 188s [1,] 1 5 9 13 17 188s [2,] 2 6 10 14 18 188s [3,] 3 7 11 15 19 188s [4,] 4 8 12 16 20 188s > 188s > Z <- colAvgsPerRowSet(X, S = S) 188s > print(Z) 188s a b c d e f 188s s1 0.43038603 0.09099442 0.03530298 0.53070310 -0.85036710 -0.3356218 188s s2 0.02734809 0.40644127 -1.45629836 -0.55560212 -0.08211952 0.5540149 188s s3 0.31132525 0.21093669 0.12060925 0.45032080 -0.77542086 -0.7025535 188s s4 0.05468580 -0.54023821 -0.33131349 -0.19851376 0.16320281 0.7408066 188s s5 -0.02171229 -0.63372716 0.49663537 0.07824672 -0.39465046 0.5907356 188s > 188s > # Validation 188s > Z0 <- rbind(s1 = colMeans(X[1:4, ]), s2 = colMeans(X[5:8, ]), 188s + s3 = colMeans(X[9:12, ]), s4 = colMeans(X[13:16, ]), 188s + s5 = colMeans(X[17:20, ])) 188s > stopifnot(identical(drop(Z), Z0)) 188s > 188s > 188s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 188s > # When there is only one "complete" set 188s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 188s > nbr_of_sets <- 1L 188s > S <- matrix(1:ncol(X), ncol = nbr_of_sets) 188s > colnames(S) <- sprintf("s%d", 1:nbr_of_sets) 188s > print(S) 188s s1 188s [1,] 1 188s [2,] 2 188s [3,] 3 188s [4,] 4 188s [5,] 5 188s [6,] 6 188s > 188s > Z <- rowAvgsPerColSet(X, S = S, FUN = rowMeans) 188s > print(Z) 188s s1 188s A 0.06270325 188s B 0.22979092 188s C -0.34129927 188s D -0.01692984 188s E 0.07922118 188s F -0.32392751 188s G -0.36357634 188s H -0.12919449 188s I -0.11975878 188s J 0.03582684 188s K 0.01922781 188s L -0.19181746 188s M -0.40701923 188s N 0.05076100 188s O 0.74532362 188s P -0.46331223 188s Q -0.44616580 188s R -0.01593364 188s S 0.11030329 188s T 0.42881466 188s > 188s > Z0 <- rowMeans(X) 188s > stopifnot(identical(drop(Z), Z0)) 188s > 188s > 188s > nbr_of_sets <- 1L 188s > S <- matrix(1:nrow(X), ncol = nbr_of_sets) 188s > colnames(S) <- sprintf("s%d", 1:nbr_of_sets) 188s > print(S) 188s s1 188s [1,] 1 188s [2,] 2 188s [3,] 3 188s [4,] 4 188s [5,] 5 188s [6,] 6 188s [7,] 7 188s [8,] 8 188s [9,] 9 188s [10,] 10 188s [11,] 11 188s [12,] 12 188s [13,] 13 188s [14,] 14 188s [15,] 15 188s [16,] 16 188s [17,] 17 188s [18,] 18 188s [19,] 19 188s [20,] 20 188s > 188s > Z <- colAvgsPerRowSet(X, S = S, FUN = colMeans) 188s > print(Z) 188s a b c d e f 188s s1 0.1604066 -0.0931186 -0.2270129 0.06103095 -0.387871 0.1694763 188s > 188s > Z0 <- colMeans(X) 188s > stopifnot(identical(drop(Z), Z0)) 188s > 188s > 188s > 188s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 188s > # Use weights 188s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 188s > nbr_of_sets <- 3L 188s > S <- matrix(1:ncol(X), ncol = nbr_of_sets) 188s > colnames(S) <- sprintf("s%d", 1:nbr_of_sets) 188s > print(S) 188s s1 s2 s3 188s [1,] 1 3 5 188s [2,] 2 4 6 188s > 188s > W <- matrix(runif(length(X)), nrow = nrow(X), ncol = ncol(X)) 188s > Z1 <- rowAvgsPerColSet(X, W = W, S = S, FUN = rowWeightedMeans) 188s > print(Z1) 188s s1 s2 s3 188s A 0.788123327 0.09204762 -0.692061197 188s B 0.501160703 1.18795439 -0.999742326 188s C -0.240224513 0.22738029 -1.011053596 188s D -0.006298624 -0.37537015 0.330879255 188s E 0.303872941 -0.52763528 0.461425878 188s F 0.730274140 -0.81307753 -0.888979140 188s G -0.180639624 -1.24672762 0.336638206 188s H 0.014071273 -1.43636053 1.034705783 188s I 0.233638650 -0.05286383 -0.540051160 188s J 0.807456436 1.47355917 -2.173535079 188s K 0.302471942 -0.13961521 -0.105173306 188s L -0.299043146 -0.13922003 -0.137189210 188s M -0.420941660 -0.94868131 0.148565279 188s N -0.092741657 0.03906382 0.205960831 188s O 0.618081517 0.33220579 1.285683565 188s P -1.075503008 -0.48224281 0.167809126 188s Q -1.218110192 -0.45781415 0.337426948 188s R 0.078213320 0.31321069 -0.439224941 188s S -0.378280327 0.20942580 0.499764386 188s T 0.207298289 1.08494184 -0.005796147 188s > Z2 <- colAvgsPerRowSet(X, W = W, S = S, FUN = colWeightedMeans) 188s > print(Z2) 188s a b c d e f 188s s1 0.80357718 0.4857069 -0.05991498 1.3399170 -1.1171337 -0.57466979 188s s2 0.05719488 -0.3037180 0.13052093 -0.2785108 -0.5836005 -0.09657386 188s s3 0.42486103 0.6092861 -0.73889897 -0.6018138 -0.7705564 0.34300315 188s > 188s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 188s > # Result should always be a matrix, including when nrow(X) <= 1 188s > # (https://github.com/HenrikBengtsson/matrixStats/issues/108) 188s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 188s > X <- matrix(1:3, nrow = 1L, ncol = 3L) 188s > S <- matrix(1, nrow = 1L, ncol = 1L) 188s > Z1 <- rowAvgsPerColSet(X, S = S) 188s > stopifnot(is.matrix(Z1)) 188s > Z2 <- rowAvgsPerColSet(X, S = S, rows = 0) 188s > stopifnot(is.matrix(Z2)) 188s > 188s > 188s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 188s > # Works with many, one or zero columns / rows 188s > # (https://github.com/HenrikBengtsson/matrixStats/issues/172) 188s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 188s > S <- cbind(1:2, 3:4, 5:6) 188s > X <- matrix(rnorm(2 * 6), nrow = 6, ncol = 2) 188s > Z2 <- colAvgsPerRowSet(X, S = S, FUN = colSums2) 188s > Z2_ref <- rbind(colSums2(X[S[,1], ,drop=FALSE]), 188s + colSums2(X[S[,2], ,drop=FALSE]), 188s + colSums2(X[S[,3], ,drop=FALSE])) 188s > stopifnot(identical(Z2, Z2_ref)) 188s > X <- matrix(rnorm(6), nrow = 6, ncol = 1) 188s > Z1 <- colAvgsPerRowSet(X, S = S, FUN = colSums2) 188s > Z1_ref <- rbind(colSums2(X[S[,1], ,drop=FALSE]), 188s + colSums2(X[S[,2], ,drop=FALSE]), 188s + colSums2(X[S[,3], ,drop=FALSE])) 188s > stopifnot(identical(Z1, Z1_ref)) 188s > X <- matrix(numeric(0), nrow = 6, ncol = 0) 188s > Z0 <- colAvgsPerRowSet(X, S = S, FUN = colSums2) 188s > Z0_ref <- matrix(numeric(0), nrow = ncol(S), ncol = 0) 188s > stopifnot(identical(Z0, unname(Z0_ref))) 188s > 188s > 188s > S <- rbind(1:4, 5:8) 188s > X <- matrix(rnorm(n = 2 * 8), nrow = 2, ncol = 8) 188s > Z2 <- rowAvgsPerColSet(X, S = S, FUN = rowMeans2) 188s > Z2_ref <- cbind(rowMeans2(X[,S[,1],drop=FALSE]), 188s + rowMeans2(X[,S[,2],drop=FALSE]), 188s + rowMeans2(X[,S[,3],drop=FALSE]), 188s + rowMeans2(X[,S[,4],drop=FALSE])) 188s > stopifnot(identical(Z2, Z2_ref)) 188s > X <- matrix(rnorm(n = 8), nrow = 1, ncol = 8) 188s > Z1 <- rowAvgsPerColSet(X, S = S, FUN = rowMeans2) 188s > Z1_ref <- cbind(rowMeans2(X[,S[,1],drop=FALSE]), 188s + rowMeans2(X[,S[,2],drop=FALSE]), 188s + rowMeans2(X[,S[,3],drop=FALSE]), 188s + rowMeans2(X[,S[,4],drop=FALSE])) 188s > stopifnot(identical(Z1, Z1_ref)) 188s > X <- matrix(numeric(0), nrow = 0, ncol = 8) 188s > Z0 <- rowAvgsPerColSet(X, S = S, FUN = rowMeans2) 188s > Z0_ref <- matrix(numeric(0), nrow = 0, ncol = ncol(S)) 188s > stopifnot(identical(Z0, Z0_ref)) 188s > 188s 188s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 188s Copyright (C) 2024 The R Foundation for Statistical Computing 188s Platform: x86_64-pc-linux-gnu 188s 188s R is free software and comes with ABSOLUTELY NO WARRANTY. 188s You are welcome to redistribute it under certain conditions. 188s Type 'license()' or 'licence()' for distribution details. 188s 188s R is a collaborative project with many contributors. 188s Type 'contributors()' for more information and 188s 'citation()' on how to cite R or R packages in publications. 188s 188s Type 'demo()' for some demos, 'help()' for on-line help, or 188s 'help.start()' for an HTML browser interface to help. 188s Type 'q()' to quit R. 188s 188s > library("matrixStats") 188s > 188s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 188s > # Subsetted tests 188s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 188s > source("utils/validateIndicesFramework.R") 188s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 188s > #W <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 188s > for (rows in index_cases) { 188s + for (cols in index_cases) { 188s + if (is.null(rows)) { 188s + rows <- seq_len(nrow(x)) 188s + rows_finite <- rows 188s + } else { 188s + rows_finite <- rows[is.finite(rows)] 188s + } 188s + 188s + if (is.null(cols)) { 188s + cols <- seq_len(ncol(x)) 188s + cols_finite <- cols 188s + } else { 188s + cols_finite <- cols[is.finite(cols)] 188s + } 188s + 188s + suppressWarnings({ 188s + actual <- tryCatch({ 188s + rowAvgsPerColSet(x, rows = rows, S = matrix(cols, ncol = 1), 188s + FUN = rowMeans) 188s + }, error = function(c) "error") 188s + expect <- tryCatch({ 188s + rowMeans(x[rows, cols_finite, drop = FALSE], na.rm = TRUE) 188s + }, error = function(c) "error") 188s + }) 188s + stopifnot(all.equal(as.vector(actual), expect)) 188s + 188s + suppressWarnings({ 188s + actual <- tryCatch({ 188s + colAvgsPerRowSet(x, cols = cols, S = matrix(rows, ncol = 1), 188s + FUN = colMeans) 188s + }, error = function(c) "error") 188s + expect <- tryCatch({ 188s + colMeans(x[rows_finite, cols, drop = FALSE], na.rm = TRUE) 188s + }, error = function(c) "error") 188s + }) 188s + stopifnot(all.equal(as.vector(actual), expect)) 188s + } 188s + } 189s > 189s 189s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 189s Copyright (C) 2024 The R Foundation for Statistical Computing 189s Platform: x86_64-pc-linux-gnu 189s 189s R is free software and comes with ABSOLUTELY NO WARRANTY. 189s You are welcome to redistribute it under certain conditions. 189s Type 'license()' or 'licence()' for distribution details. 189s 189s R is a collaborative project with many contributors. 189s Type 'contributors()' for more information and 189s 'citation()' on how to cite R or R packages in publications. 189s 189s Type 'demo()' for some demos, 'help()' for on-line help, or 189s 'help.start()' for an HTML browser interface to help. 189s Type 'q()' to quit R. 189s 189s > library("matrixStats") 189s > 189s > x <- matrix(1:27, ncol = 3) 189s > 189s > # To check names attribute 189s > dimnames <- list(letters[1:9], LETTERS[1:3]) 189s > 189s > rowCollapse_R <- function(x, idxs, ..., useNames = NA) { 189s + res <- x[, idxs] 189s + # Preserve names attribute? 189s + if (is.na(useNames) || !useNames) names(res) <- NULL 189s + res 189s + } 189s > 189s > idxs <- 1L 189s > # Test with and without dimnames on x 189s > for (setDimnames in c(TRUE, FALSE)) { 189s + if (setDimnames) dimnames(x) <- dimnames 189s + else dimnames(x) <- NULL 189s + # Check names attribute 189s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 189s + y_truth <- rowCollapse_R(x, idxs, useNames = useNames) 189s + y <- rowCollapse(x, idxs, useNames = useNames) 189s + stopifnot(identical(y, y_truth)) 189s + y2 <- colCollapse(t(x), idxs, useNames = useNames) 189s + stopifnot(identical(y2, y)) 189s + } 189s + } 189s > 189s > idxs <- 2L 189s > # Test with and without dimnames on x 189s > for (setDimnames in c(TRUE, FALSE)) { 189s + if (setDimnames) dimnames(x) <- dimnames 189s + else dimnames(x) <- NULL 189s + # Check names attribute 189s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 189s + y_truth <- rowCollapse_R(x, idxs, useNames = useNames) 189s + y <- rowCollapse(x, idxs, useNames = useNames) 189s + stopifnot(identical(y, y_truth)) 189s + y2 <- colCollapse(t(x), idxs, useNames = useNames) 189s + stopifnot(identical(y2, y)) 189s + } 189s + } 189s > 189s > 189s > rowCollapse_R <- function(x, idxs, ..., useNames = NA) { 189s + res <- c(x[1:5, 1], x[6:9, 3]) 189s + # Preserve names attribute? 189s + if (is.na(useNames) || !useNames) names(res) <- NULL 189s + res 189s + } 189s > 189s > idxs <- c(1, 1, 1, 1, 1, 3, 3, 3, 3) 189s > # Test with and without dimnames on x 189s > for (setDimnames in c(TRUE, FALSE)) { 189s + if (setDimnames) dimnames(x) <- dimnames 189s + else dimnames(x) <- NULL 189s + # Check names attribute 189s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 189s + y_truth <- rowCollapse_R(x, idxs, useNames = useNames) 189s + y <- rowCollapse(x, idxs, useNames = useNames) 189s + stopifnot(identical(y, y_truth)) 189s + y2 <- colCollapse(t(x), idxs, useNames = useNames) 189s + stopifnot(identical(y2, y)) 189s + } 189s + } 189s > 189s > 189s > rowCollapse_R <- function(x, idxs, ..., useNames = NA) { 189s + res <- c(x[1, 1], x[2, 2], x[3, 3], x[4, 1], x[5, 2], 189s + x[6, 3], x[7, 1], x[8, 2], x[9, 3]) 189s + # Preserve names attribute? 189s + if (isTRUE(useNames)) { 189s + names <- rownames(x) 189s + if (!is.null(names)) names(res) <- names 189s + } 189s + res 189s + } 189s > 189s > idxs <- 1:3 189s > # Test with and without dimnames on x 189s > for (setDimnames in c(TRUE, FALSE)) { 189s + if (setDimnames) dimnames(x) <- dimnames 189s + else dimnames(x) <- NULL 189s + # Check names attribute 189s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 189s + y_truth <- rowCollapse_R(x, idxs, useNames = useNames) 189s + y <- rowCollapse(x, idxs, useNames = useNames) 189s + stopifnot(identical(y, y_truth)) 189s + y2 <- colCollapse(t(x), idxs, useNames = useNames) 189s + stopifnot(identical(y2, y)) 189s + } 189s + } 189s > 189s 189s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 189s Copyright (C) 2024 The R Foundation for Statistical Computing 189s Platform: x86_64-pc-linux-gnu 189s 189s R is free software and comes with ABSOLUTELY NO WARRANTY. 189s You are welcome to redistribute it under certain conditions. 189s Type 'license()' or 'licence()' for distribution details. 189s 189s R is a collaborative project with many contributors. 189s Type 'contributors()' for more information and 189s 'citation()' on how to cite R or R packages in publications. 189s 189s Type 'demo()' for some demos, 'help()' for on-line help, or 189s 'help.start()' for an HTML browser interface to help. 189s Type 'q()' to quit R. 189s 189s > library("matrixStats") 189s > 189s > rowCollapse_R <- function(x, idxs, ..., useNames = NA) { 189s + ans <- c() 189s + storage.mode(ans) <- storage.mode(x) 189s + for (ii in seq_len(length(idxs))) { 189s + ans[ii] <- x[ii, idxs[ii]] 189s + } 189s + 189s + # Preserve names attribute 189s + if (isTRUE(useNames)) { 189s + names <- rownames(x) 189s + if (!is.null(names)) names(ans) <- names 189s + } 189s + 189s + ans 189s + } 189s > 189s > 189s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 189s > # Subsetted tests 189s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 189s > source("utils/validateIndicesFramework.R") 189s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 189s > storage.mode(x) <- "integer" 189s > 189s > # To check names attribute 189s > dimnames <- list(letters[1:6], LETTERS[1:6]) 189s > 189s > for (rows in index_cases) { 189s + if (is.null(rows)) rows <- seq_len(nrow(x)) 189s + 189s + for (idxs in list(2L, seq_len(6L))) { 189s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 189s + suppressWarnings({ 189s + actual <- tryCatch(rowCollapse(x, idxs, rows = rows, useNames = useNames), 189s + error = function(c) "error") 189s + expect <- tryCatch({ 189s + idxs_0 <- rep(idxs, length.out = nrow(x))[rows] 189s + rowCollapse_R(x[rows, , drop = FALSE], idxs_0, useNames = useNames) 189s + }, error = function(c) "error") 189s + }) 189s + stopifnot(all.equal(actual, expect)) 189s + 189s + suppressWarnings({ 189s + actual <- tryCatch(colCollapse(t(x), idxs, cols = rows, useNames = useNames), 189s + error = function(c) "error") 189s + }) 189s + stopifnot(all.equal(actual, expect)) 189s + 189s + # Check names attribute 189s + dimnames(x) <- dimnames 189s + suppressWarnings({ 189s + actual <- tryCatch(rowCollapse(x, idxs, rows = rows, useNames = useNames), 189s + error = function(c) "error") 189s + expect <- tryCatch({ 189s + idxs_0 <- rep(idxs, length.out = nrow(x))[rows] 189s + rowCollapse_R(x[rows, , drop = FALSE], idxs_0, useNames = useNames) 189s + }, error = function(c) "error") 189s + }) 189s + stopifnot(all.equal(actual, expect)) 189s + 189s + suppressWarnings({ 189s + actual <- tryCatch(colCollapse(t(x), idxs, cols = rows, useNames = useNames), 189s + error = function(c) "error") 189s + }) 189s + stopifnot(all.equal(actual, expect)) 189s + 189s + dimnames(x) <- NULL 189s + } 189s + } 189s + } 189s > 189s 189s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 189s Copyright (C) 2024 The R Foundation for Statistical Computing 189s Platform: x86_64-pc-linux-gnu 189s 189s R is free software and comes with ABSOLUTELY NO WARRANTY. 189s You are welcome to redistribute it under certain conditions. 189s Type 'license()' or 'licence()' for distribution details. 189s 189s R is a collaborative project with many contributors. 189s Type 'contributors()' for more information and 189s 'citation()' on how to cite R or R packages in publications. 189s 189s Type 'demo()' for some demos, 'help()' for on-line help, or 189s 'help.start()' for an HTML browser interface to help. 189s Type 'q()' to quit R. 189s 189s > library("matrixStats") 189s > 189s > rowCounts_R <- function(x, value = TRUE, na.rm = FALSE, ...) { 189s + if (is.na(value)) { 189s + counts <- apply(x, MARGIN = 1L, FUN = function(x) 189s + sum(is.na(x)) 189s + ) 189s + } else { 189s + counts <- apply(x, MARGIN = 1L, FUN = function(x) 189s + sum(x == value, na.rm = na.rm) 189s + ) 189s + } 189s + # Preserve names attribute 189s + names <- names(counts) 189s + counts <- as.integer(counts) 189s + if (isTRUE(useNames) && !is.null(names)) names(counts) <- names 189s + counts 189s + } 189s > 189s > 189s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 189s > # Data type: integer and numeric 189s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 189s > for (mode in c("integer", "double")) { 189s + x <- matrix(runif(10 * 5, min = -3, max = 3), nrow = 10L, ncol = 5L) 189s + x[sample.int(length(x), size = 7L)] <- 0 189s + storage.mode(x) <- mode 189s + 189s + dimnames = list(letters[1:10], LETTERS[1:5]) 189s + 189s + # Test with and without dimnames on x 189s + for (setDimnames in c(TRUE, FALSE)) { 189s + if (setDimnames) dimnames(x) <- dimnames 189s + else dimnames(x) <- NULL 189s + for (na.rm in c(FALSE, TRUE)) { 189s + # Check names attribute 189s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 189s + # Count zeros 189s + r0 <- rowCounts_R(x, value = 0, na.rm = na.rm, useNames = useNames) 189s + r1 <- rowCounts(x, value = 0, na.rm = na.rm, useNames = useNames) 189s + r2 <- colCounts(t(x), value = 0, na.rm = na.rm, useNames = useNames) 189s + stopifnot(identical(r1, r0)) 189s + stopifnot(identical(r2, r0)) 189s + 189s + # Count NAs 189s + r0 <- rowCounts_R(x, value = NA, na.rm = na.rm, useNames = useNames) 189s + r1 <- rowCounts(x, value = NA, na.rm = na.rm, useNames = useNames) 189s + r2 <- colCounts(t(x), value = NA, na.rm = na.rm, useNames = useNames) 189s + stopifnot(identical(r1, r0)) 189s + stopifnot(identical(r2, r0)) 189s + 189s + if (mode == "integer") { 189s + ux <- unique(as.vector(x)) 189s + r0 <- r1 <- r2 <- integer(nrow(x)) 189s + for (value in ux) { 189s + r0 <- r0 + rowCounts_R(x, value = value, na.rm = na.rm, useNames = useNames) 189s + r1 <- r1 + rowCounts(x, value = value, na.rm = na.rm, useNames = useNames) 189s + r2 <- r2 + colCounts(t(x), value = value, na.rm = na.rm, useNames = useNames) 189s + stopifnot(identical(r1, r0)) 189s + stopifnot(identical(r2, r0)) 189s + } 189s + stopifnot(all(r0 == ncol(x))) 189s + } # if (mode == "integer") 189s + } # for (useNames ...) 189s + } # for (na.rm ...) 189s + } # for (setDimnames ...) 189s + } # for (mode ...) 189s > 189s > 189s > # All NAs 189s > na_list <- list(NA_integer_, NA_real_, NaN) 189s > for (na_value in na_list) { 189s + x <- matrix(na_value, nrow = 10L, ncol = 5L) 189s + # Test with and without dimnames on x 189s + for (setDimnames in c(TRUE, FALSE)) { 189s + if (setDimnames) dimnames(x) <- dimnames 189s + else dimnames(x) <- NULL 189s + for (na.rm in c(FALSE, TRUE)) { 189s + # Check names attribute 189s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 189s + r0 <- rowCounts_R(x, na.rm = na.rm, useNames = useNames) 189s + r1 <- rowCounts(x, na.rm = na.rm, useNames = useNames) 189s + r2 <- colCounts(t(x), na.rm = na.rm, useNames = useNames) 189s + stopifnot(identical(r1, r0)) 189s + stopifnot(identical(r2, r0)) 189s + 189s + # Count NAs 189s + r0 <- rowCounts_R(x, value = NA, na.rm = na.rm, useNames = useNames) 189s + r1 <- rowCounts(x, value = NA, na.rm = na.rm, useNames = useNames) 189s + r2 <- colCounts(t(x), value = NA, na.rm = na.rm, useNames = useNames) 189s + stopifnot(all(r0 == ncol(x))) 189s + stopifnot(identical(r1, r0)) 189s + stopifnot(identical(r2, r0)) 189s + } 189s + } 189s + } 189s + } # for (na_value ...) 189s > 189s > 189s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 189s > # Data type: logical 189s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 189s > x <- matrix(FALSE, nrow = 10L, ncol = 4L) 189s > x[7:8, 2:3] <- TRUE 189s > x[1:3, ] <- TRUE 189s > x[, 1] <- TRUE 189s > x[4, ] <- FALSE 189s > x[, 4] <- FALSE 189s > x[2, ] <- FALSE 189s > x[3, ] <- TRUE 189s > 189s > # To check names attribute 189s > dimnames <- list(letters[1:10], LETTERS[1:4]) 189s > 189s > # Test with and without dimnames on x 189s > for (setDimnames in c(TRUE, FALSE)) { 189s + if (setDimnames) dimnames(x) <- dimnames 189s + else dimnames(x) <- NULL 189s + # Row/column counts 189s + for (na.rm in c(FALSE, TRUE)) { 189s + # Check names attribute 189s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 189s + r0 <- rowCounts_R(x, na.rm = na.rm, useNames = useNames) 189s + r1 <- rowCounts(x, na.rm = na.rm, useNames = useNames) 189s + r2 <- colCounts(t(x), na.rm = na.rm, useNames = useNames) 189s + stopifnot(identical(r1, r0)) 189s + stopifnot(identical(r2, r0)) 189s + 189s + r_true <- rowCounts(x, value = TRUE, na.rm = na.rm, useNames = useNames) 189s + r_false <- rowCounts(x, value = FALSE, na.rm = na.rm, useNames = useNames) 189s + stopifnot(r_true + r_false == ncol(x)) 189s + 189s + c_true <- colCounts(x, value = TRUE, na.rm = na.rm, useNames = useNames) 189s + c_false <- colCounts(x, value = FALSE, na.rm = na.rm, useNames = useNames) 189s + stopifnot(c_true + c_false == nrow(x)) 189s + 189s + # Count NAs 189s + r0 <- rowCounts_R(x, value = NA, na.rm = na.rm, useNames = useNames) 189s + r1 <- rowCounts(x, value = NA, na.rm = na.rm, useNames = useNames) 189s + r2 <- colCounts(t(x), value = NA, na.rm = na.rm, useNames = useNames) 189s + stopifnot(identical(r1, r0)) 189s + stopifnot(identical(r2, r0)) 189s + } 189s + } 189s + } 189s > 189s > 189s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 189s > # Data type: character (not sure if this should be supported) 189s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 189s > x <- matrix(rep(letters, length.out = 10 * 5), nrow = 10L, ncol = 5L) 189s > x[2:3, 3:4] <- NA_character_ 189s > 189s > # Row/column counts 189s > for (na.rm in c(FALSE, TRUE)) { 189s + for (value in c("g", NA_character_)) { 189s + r0 <- rowCounts_R(x, value = value, na.rm = na.rm) 189s + r1 <- rowCounts(x, value = value, na.rm = na.rm) 189s + r2 <- colCounts(t(x), value = value, na.rm = na.rm) 189s + stopifnot(identical(r1, r0)) 189s + stopifnot(identical(r2, r0)) 189s + 189s + c <- count(x[1, ], value = value, na.rm = na.rm) 189s + stopifnot(identical(c, r1[1])) 189s + 189s + c <- count(x[2, ], value = value, na.rm = na.rm) 189s + stopifnot(identical(c, r1[2])) 189s + } 189s + } 189s > 189s > # NA row 189s > x <- matrix(0, nrow = 2L, ncol = 2L) 189s > x[1, ] <- NA_integer_ 189s > 189s > dimnames <- list(letters[1:2], LETTERS[1:2]) 189s > 189s > # Test with and without dimnames on x 189s > for (setDimnames in c(TRUE, FALSE)) { 189s + if (setDimnames) dimnames(x) <- dimnames 189s + else dimnames(x) <- NULL 189s + # Check names attribute 189s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 189s + r0 <- rowCounts(x, value = 0, useNames = useNames) 189s + r1 <- rowCounts_R(x, value = 0, useNames = useNames) 189s + stopifnot(identical(r0, r1)) 189s + } 189s + } 189s > 189s 189s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 189s Copyright (C) 2024 The R Foundation for Statistical Computing 189s Platform: x86_64-pc-linux-gnu 189s 189s R is free software and comes with ABSOLUTELY NO WARRANTY. 189s You are welcome to redistribute it under certain conditions. 189s Type 'license()' or 'licence()' for distribution details. 189s 189s R is a collaborative project with many contributors. 189s Type 'contributors()' for more information and 189s 'citation()' on how to cite R or R packages in publications. 189s 189s Type 'demo()' for some demos, 'help()' for on-line help, or 189s 'help.start()' for an HTML browser interface to help. 189s Type 'q()' to quit R. 189s 189s > library("matrixStats") 189s > 189s > rowCounts_R <- function(x, value = TRUE, na.rm = FALSE, ..., useNames = NA) { 189s + if (is.na(value)) { 189s + counts <- apply(x, MARGIN = 1L, FUN = function(x) 189s + sum(is.na(x)) 189s + ) 189s + } else { 189s + counts <- apply(x, MARGIN = 1L, FUN = function(x) 189s + sum(x == value, na.rm = na.rm) 189s + ) 189s + } 189s + # Preserve names attribute 189s + names <- names(counts) 189s + counts <- as.integer(counts) 189s + if (isTRUE(useNames) && !is.null(names)) names(counts) <- names 189s + counts 189s + } # rowCounts_R() 189s > 189s > 189s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 189s > # Subsetted tests 189s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 189s > source("utils/validateIndicesFramework.R") 189s > x <- matrix(runif(6 * 6, min = -3, max = 3), nrow = 6, ncol = 6) 189s > x[2:3, 3:4] <- NA_real_ 189s > storage.mode(x) <- "integer" 189s > 189s > # To check names attribute 189s > dimnames <- list(letters[1:6], LETTERS[1:6]) 189s > 189s > # Test with and without dimnames on x 189s > for (setDimnames in c(TRUE, FALSE)) { 189s + if (setDimnames) dimnames(x) <- dimnames 189s + else dimnames(x) <- NULL 189s + for (rows in index_cases) { 189s + for (cols in index_cases) { 189s + # Check names attribute 189s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 189s + validateIndicesTestMatrix(x, rows, cols, 189s + ftest = rowCounts, fsure = rowCounts_R, 189s + value = 0, na.rm = TRUE, useNames = useNames) 189s + validateIndicesTestMatrix(x, rows, cols, 189s + fcoltest = colCounts, fsure = rowCounts_R, 189s + value = 0, na.rm = TRUE, useNames = useNames) 189s + for (value in c(0, NA_integer_)) { 189s + validateIndicesTestMatrix(x, rows, cols, 189s + ftest = rowCounts, fsure = rowCounts_R, 189s + value = value, useNames = useNames) 189s + validateIndicesTestMatrix(x, rows, cols, 189s + fcoltest = colCounts, fsure = rowCounts_R, 189s + value = value, useNames = useNames) 189s + } 189s + } 189s + } 189s + } 189s + } 191s > 191s > x <- matrix(rep(letters, length.out = 6 * 6), nrow = 6, ncol = 6) 191s > x[2:3, 3:4] <- NA_character_ 191s > # Test with and without dimnames on x 191s > for (setDimnames in c(TRUE, FALSE)) { 191s + if (setDimnames) dimnames(x) <- dimnames 191s + else dimnames(x) <- NULL 191s + 191s + count <- 0L 191s + for (rows in index_cases) { 191s + for (cols in index_cases) { 191s + count <- count + 1L 191s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 191s + useNames <- c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE) 191s + useNames <- useNames[count %% length(useNames) + 1] 191s + 191s + validateIndicesTestMatrix(x, rows, cols, 191s + ftest = rowCounts, fsure = rowCounts_R, 191s + value = "g", na.rm = TRUE, useNames = useNames) 191s + validateIndicesTestMatrix(x, rows, cols, 191s + fcoltest = colCounts, fsure = rowCounts_R, 191s + value = "g", na.rm = TRUE, useNames = useNames) 191s + for (value in c("g", NA_character_)) { 191s + validateIndicesTestMatrix(x, rows, cols, 191s + ftest = rowCounts, fsure = rowCounts_R, 191s + value = value, useNames = useNames) 191s + validateIndicesTestMatrix(x, rows, cols, 191s + fcoltest = colCounts, fsure = rowCounts_R, 191s + value = value, useNames = useNames) 191s + } 191s + } 191s + } 191s + } 191s > 191s 191s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 191s Copyright (C) 2024 The R Foundation for Statistical Computing 191s Platform: x86_64-pc-linux-gnu 191s 191s R is free software and comes with ABSOLUTELY NO WARRANTY. 191s You are welcome to redistribute it under certain conditions. 191s Type 'license()' or 'licence()' for distribution details. 191s 191s R is a collaborative project with many contributors. 191s Type 'contributors()' for more information and 191s 'citation()' on how to cite R or R packages in publications. 191s 191s Type 'demo()' for some demos, 'help()' for on-line help, or 191s 'help.start()' for an HTML browser interface to help. 191s Type 'q()' to quit R. 191s 191s > library("matrixStats") 191s > 191s > rowCummins_R <- function(x, ..., useNames = NA) { 191s + suppressWarnings({ 191s + y <- t(apply(x, MARGIN = 1L, FUN = cummin)) 191s + }) 191s + 192s + # Preserve dimnames attribute? 192s + dim(y) <- dim(x) 192s + dimnames(y) <- if (isTRUE(useNames)) dimnames(x) else NULL 192s + y 192s + } 192s > 192s > rowCummaxs_R <- function(x, ..., useNames = NA) { 192s + mode <- storage.mode(x) 192s + # Change mode because a bug is detected on cummax for integer in R-3.2.0 192s + storage.mode(x) <- "numeric" 192s + suppressWarnings({ 192s + y <- t(apply(x, MARGIN = 1L, FUN = cummax)) 192s + }) 192s + 192s + # Preserve dimnames attribute? 192s + dim(y) <- dim(x) 192s + dimnames(y) <- if (isTRUE(useNames)) dimnames(x) else NULL 192s + 192s + y 192s + } 192s > 192s > 192s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 192s > # With and without some NAs 192s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 192s > for (mode in c("logical", "integer", "double")) { 192s + for (add_na in c(FALSE, TRUE)) { 192s + cat("add_na = ", add_na, "\n", sep = "") 192s + 192s + x <- matrix(1:50, nrow = 10L, ncol = 5L) 192s + diag(x) <- 0 192s + if (add_na) { 192s + x[3:7, c(2, 4)] <- NA_real_ 192s + } 192s + cat("mode: ", mode, "\n", sep = "") 192s + storage.mode(x) <- mode 192s + str(x) 192s + 192s + # To check dimnames attribute 192s + dimnames <- list(letters[1:10], LETTERS[1:5]) 192s + 192s + # Test with and without dimnames on x 192s + for (setDimnames in c(TRUE, FALSE)) { 192s + if (setDimnames) dimnames(x) <- dimnames 192s + else dimnames(x) <- NULL 192s + # Check names attribute 192s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 192s + # Row/column ranges 192s + r0 <- rowCummins_R(x, useNames = useNames) 192s + r1 <- rowCummins(x, useNames = useNames) 192s + r2 <- t(colCummins(t(x), useNames = useNames)) 192s + stopifnot(all.equal(r1, r2)) 192s + stopifnot(all.equal(r1, r0)) 192s + stopifnot(all.equal(r2, r0)) 192s + 192s + r0 <- rowCummaxs_R(x, useNames = useNames) 192s + r1 <- rowCummaxs(x, useNames = useNames) 192s + r2 <- t(colCummaxs(t(x), useNames = useNames)) 192s + stopifnot(all.equal(r1, r2)) 192s + stopifnot(all.equal(r1, r0)) 192s + stopifnot(all.equal(r2, r0)) 192s + } # for (useNames ...) 192s + } # for (setDimnames ...) 192s + } # for (add_na ...) 192s + } # for (mode ...) 192s add_na = FALSE 192s mode: logical 192s logi [1:10, 1:5] FALSE TRUE TRUE TRUE TRUE TRUE ... 192s add_na = TRUE 192s mode: logical 192s logi [1:10, 1:5] FALSE TRUE TRUE TRUE TRUE TRUE ... 192s add_na = FALSE 192s mode: integer 192s int [1:10, 1:5] 0 2 3 4 5 6 7 8 9 10 ... 192s add_na = TRUE 192s mode: integer 192s int [1:10, 1:5] 0 2 3 4 5 6 7 8 9 10 ... 192s add_na = FALSE 192s mode: double 192s num [1:10, 1:5] 0 2 3 4 5 6 7 8 9 10 ... 192s add_na = TRUE 192s mode: double 192s num [1:10, 1:5] 0 2 3 4 5 6 7 8 9 10 ... 192s > 192s > 192s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 192s > # All NAs 192s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 192s > for (mode in c("logical", "integer", "double")) { 192s + x <- matrix(NA_real_, nrow = 10L, ncol = 5L) 192s + cat("mode: ", mode, "\n", sep = "") 192s + storage.mode(x) <- mode 192s + str(x) 192s + 192s + # Test with and without dimnames on x 192s + for (setDimnames in c(TRUE, FALSE)) { 192s + if (setDimnames) dimnames(x) <- dimnames 192s + else dimnames(x) <- NULL 192s + # Check names attribute 192s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 192s + r0 <- rowCummins_R(x, useNames = useNames) 192s + r1 <- rowCummins(x, useNames = useNames) 192s + r2 <- t(colCummins(t(x), useNames = useNames)) 192s + stopifnot(all.equal(r1, r2)) 192s + stopifnot(all.equal(r1, r0)) 192s + stopifnot(all.equal(r2, r0)) 192s + 192s + r0 <- rowCummaxs_R(x, useNames = useNames) 192s + r1 <- rowCummaxs(x, useNames = useNames) 192s + r2 <- t(colCummaxs(t(x), useNames = useNames)) 192s + stopifnot(all.equal(r1, r2)) 192s + stopifnot(all.equal(r1, r0)) 192s + stopifnot(all.equal(r2, r0)) 192s + } # for (useNames ...) 192s + } # for (setDimnames ...) 192s + } # for (mode ...) 192s mode: logical 192s logi [1:10, 1:5] NA NA NA NA NA NA ... 192s mode: integer 192s int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 192s mode: double 192s num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 192s > 192s > 192s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 192s > # A 1x1 matrix 192s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 192s > for (mode in c("logical", "integer", "double")) { 192s + x <- matrix(0, nrow = 1L, ncol = 1L) 192s + cat("mode: ", mode, "\n", sep = "") 192s + storage.mode(x) <- mode 192s + str(x) 192s + 192s + # To check dimnames attribute 192s + dimnames <- list("a", "A") 192s + 192s + # Test with and without dimnames on x 192s + for (setDimnames in c(TRUE, FALSE)) { 192s + if (setDimnames) dimnames(x) <- dimnames 192s + else dimnames(x) <- NULL 192s + # Check names attribute 192s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 192s + r0 <- rowCummins_R(x, useNames = useNames) 192s + r1 <- rowCummins(x, useNames = useNames) 192s + r2 <- t(colCummins(t(x), useNames = useNames)) 192s + stopifnot(all.equal(r1, r2)) 192s + stopifnot(all.equal(r1, r0)) 192s + stopifnot(all.equal(r2, r0)) 192s + 192s + r0 <- rowCummaxs_R(x, useNames = useNames) 192s + r1 <- rowCummaxs(x, useNames = useNames) 192s + r2 <- t(colCummaxs(t(x), useNames = useNames)) 192s + stopifnot(all.equal(r1, r2)) 192s + stopifnot(all.equal(r1, r0)) 192s + stopifnot(all.equal(r2, r0)) 192s + } # for (useNames ...) 192s + } # for (setDimnames ...) 192s + } # for (mode ...) 192s mode: logical 192s logi [1, 1] FALSE 192s mode: integer 192s int [1, 1] 0 192s mode: double 192s num [1, 1] 0 192s > 192s > 192s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 192s > # Corner cases 192s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 192s > for (mode in c("logical", "integer", "double")) { 192s + cat("mode: ", mode, "\n", sep = "") 192s + value <- 0 192s + storage.mode(value) <- mode 192s + value0 <- if (mode == "logical") 0L else value 192s + 192s + # A 0x0 matrix 192s + x <- matrix(value, nrow = 0L, ncol = 0L) 192s + str(x) 192s + r0 <- matrix(value0, nrow = nrow(x), ncol = ncol(x)) 192s + r1 <- rowCummins(x) 192s + r2 <- t(colCummins(t(x))) 192s + stopifnot(all.equal(r1, r2)) 192s + stopifnot(all.equal(r1, r0)) 192s + stopifnot(all.equal(r2, r0)) 192s + 192s + # A 0xK matrix 192s + x <- matrix(value, nrow = 0L, ncol = 5L) 192s + str(x) 192s + colnames <- LETTERS[1:5] 192s + # Test with and without dimnames on x 192s + for (setDimnames in c(TRUE, FALSE)) { 192s + if (setDimnames) colnames(x) <- colnames 192s + else dimnames(x) <- NULL 192s + # Check names attribute 192s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 192s + r0 <- rowCummins_R(x, useNames = useNames) 192s + r1 <- rowCummins(x, useNames = useNames) 192s + r2 <- t(colCummins(t(x), useNames = useNames)) 192s + stopifnot(all.equal(r1, r2)) 192s + stopifnot(all.equal(r1, r0)) 192s + stopifnot(all.equal(r2, r0)) 192s + r0 <- rowCummaxs_R(x, useNames = useNames) 192s + r1 <- rowCummaxs(x, useNames = useNames) 192s + r2 <- t(colCummaxs(t(x), useNames = useNames)) 192s + stopifnot(all.equal(r1, r2)) 192s + stopifnot(all.equal(r1, r0)) 192s + stopifnot(all.equal(r2, r0)) 192s + } # for (useNames ...) 192s + } # for (setDimnames ...) 192s + 192s + # A Nx0 matrix 192s + x <- matrix(value, nrow = 5L, ncol = 0L) 192s + str(x) 192s + rownames <- LETTERS[1:5] 192s + # Test with and without dimnames on x 192s + for (setDimnames in c(TRUE, FALSE)) { 192s + if (setDimnames) rownames(x) <- rownames 192s + else dimnames(x) <- NULL 192s + # Check names attribute 192s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 192s + r0 <- rowCummins_R(x, useNames = useNames) 192s + r1 <- rowCummins(x, useNames = useNames) 192s + r2 <- t(colCummins(t(x), useNames = useNames)) 192s + stopifnot(all.equal(r1, r2)) 192s + stopifnot(all.equal(r1, r0)) 192s + stopifnot(all.equal(r2, r0)) 192s + 192s + r0 <- rowCummaxs_R(x, useNames = useNames) 192s + r1 <- rowCummaxs(x, useNames = useNames) 192s + r2 <- t(colCummaxs(t(x), useNames = useNames)) 192s + stopifnot(all.equal(r1, r2)) 192s + stopifnot(all.equal(r1, r0)) 192s + stopifnot(all.equal(r2, r0)) 192s + } # for (useNames ...) 192s + } # for (setDimnames ...) 192s + } # for (mode ...) 192s mode: logical 192s logi[0 , 0 ] 192s logi[0 , 1:5] 192s logi[1:5, 0 ] 192s mode: integer 192s int[0 , 0 ] 192s int[0 , 1:5] 192s int[1:5, 0 ] 192s mode: double 192s num[0 , 0 ] 192s num[0 , 1:5] 192s num[1:5, 0 ] 192s > 192s 192s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 192s Copyright (C) 2024 The R Foundation for Statistical Computing 192s Platform: x86_64-pc-linux-gnu 192s 192s R is free software and comes with ABSOLUTELY NO WARRANTY. 192s You are welcome to redistribute it under certain conditions. 192s Type 'license()' or 'licence()' for distribution details. 192s 192s R is a collaborative project with many contributors. 192s Type 'contributors()' for more information and 192s 'citation()' on how to cite R or R packages in publications. 192s 192s Type 'demo()' for some demos, 'help()' for on-line help, or 192s 'help.start()' for an HTML browser interface to help. 192s Type 'q()' to quit R. 192s 192s > library("matrixStats") 192s > 192s > rowCummins_R <- function(x, ..., useNames = NA) { 192s + suppressWarnings({ 192s + y <- t(apply(x, MARGIN = 1L, FUN = cummin)) 192s + }) 192s + 192s + # Preserve dimnames attribute? 192s + dim(y) <- dim(x) 192s + dimnames(y) <- if (isTRUE(useNames)) dimnames(x) else NULL 192s + 192s + y 192s + } 192s > 192s > rowCummaxs_R <- function(x, ..., useNames = NA) { 192s + mode <- storage.mode(x) 192s + # Change mode because a bug is detected on cummax for integer in R-3.2.0 192s + storage.mode(x) <- "numeric" 192s + suppressWarnings({ 192s + y <- t(apply(x, MARGIN = 1L, FUN = cummax)) 192s + }) 192s + 192s + # Preserve dimnames attribute? 192s + dim(y) <- dim(x) 192s + dimnames(y) <- if (isTRUE(useNames)) dimnames(x) else NULL 192s + 192s + storage.mode(y) <- mode 192s + y 192s + } 192s > 192s > 192s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 192s > # Subsetted tests 192s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 192s > source("utils/validateIndicesFramework.R") 192s > x <- matrix(runif(6 * 6, min = -3, max = 3), nrow = 6, ncol = 6) 192s > storage.mode(x) <- "integer" 192s > 192s > # To check dimnames attribute 192s > dimnames <- list(letters[1:6], LETTERS[1:6]) 192s > 192s > # Test with and without dimnames on x 192s > for (setDimnames in c(TRUE, FALSE)) { 192s + if (setDimnames) dimnames(x) <- dimnames 192s + else dimnames(x) <- NULL 192s + for (rows in index_cases) { 192s + for (cols in index_cases) { 192s + # Check names attribute 192s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 192s + validateIndicesTestMatrix(x, rows, cols, 192s + ftest = rowCummins, fsure = rowCummins_R, useNames = useNames,verbose=TRUE) 192s + validateIndicesTestMatrix(x, rows, cols, 192s + ftest = function(x, rows, cols, ..., useNames) { 192s + t(colCummins(t(x), rows = cols, cols = rows, useNames = useNames)) 192s + }, fsure = rowCummins_R, useNames = useNames) 192s + 192s + validateIndicesTestMatrix(x, rows, cols, 192s + ftest = rowCummaxs, fsure = rowCummaxs_R, useNames = useNames) 192s + validateIndicesTestMatrix(x, rows, cols, 192s + ftest = function(x, rows, cols, ..., useNames) { 192s + t(colCummaxs(t(x), rows = cols, cols = rows, useNames = useNames)) 192s + }, fsure = rowCummaxs_R, useNames = useNames) 192s + } 192s + } 192s + } 192s + } 193s > 193s 193s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 193s Copyright (C) 2024 The R Foundation for Statistical Computing 193s Platform: x86_64-pc-linux-gnu 193s 193s R is free software and comes with ABSOLUTELY NO WARRANTY. 193s You are welcome to redistribute it under certain conditions. 193s Type 'license()' or 'licence()' for distribution details. 193s 193s R is a collaborative project with many contributors. 193s Type 'contributors()' for more information and 193s 'citation()' on how to cite R or R packages in publications. 193s 193s Type 'demo()' for some demos, 'help()' for on-line help, or 193s 'help.start()' for an HTML browser interface to help. 193s Type 'q()' to quit R. 193s 194s > library("matrixStats") 194s > 194s > rowCumprods_R <- function(x, ..., useNames = NA) { 194s + suppressWarnings({ 194s + y <- t(apply(x, MARGIN = 1L, FUN = cumprod)) 194s + }) 194s + 194s + # Preserve dimnames attribute? 194s + dim(y) <- dim(x) 194s + dimnames(y) <- if (isTRUE(useNames)) dimnames(x) else NULL 194s + 194s + y 194s + } 194s > 194s > 194s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 194s > # With and without some NAs 194s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 194s > for (mode in c("logical", "integer", "double")) { 194s + for (add_na in c(FALSE, TRUE)) { 194s + cat("add_na = ", add_na, "\n", sep = "") 194s + 194s + x <- matrix(1:50, nrow = 10L, ncol = 5L) 194s + if (add_na) { 194s + x[3:7, c(2, 4)] <- NA_real_ 194s + } 194s + cat("mode: ", mode, "\n", sep = "") 194s + storage.mode(x) <- mode 194s + str(x) 194s + 194s + # To check dimnames attribute 194s + dimnames <- list(letters[1:10], LETTERS[1:5]) 194s + 194s + # Test with and without dimnames on x 194s + for (setDimnames in c(TRUE, FALSE)) { 194s + if (setDimnames) dimnames(x) <- dimnames 194s + else dimnames(x) <- NULL 194s + # Check names attribute 194s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 194s + # Row/column ranges 194s + r0 <- rowCumprods_R(x, useNames = useNames) 194s + r1 <- rowCumprods(x, useNames = useNames) 194s + r2 <- t(colCumprods(t(x), useNames = useNames)) 194s + stopifnot(all.equal(r1, r2)) 194s + stopifnot(all.equal(r1, r0)) 194s + stopifnot(all.equal(r2, r0)) 194s + } # for (useNames ...) 194s + } # for (setDimnames ...) 194s + } # for (add_na ...) 194s + } # for (mode ...) 194s add_na = FALSE 194s mode: logical 194s logi [1:10, 1:5] TRUE TRUE TRUE TRUE TRUE TRUE ... 194s add_na = TRUE 194s mode: logical 194s logi [1:10, 1:5] TRUE TRUE TRUE TRUE TRUE TRUE ... 194s add_na = FALSE 194s mode: integer 194s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 194s add_na = TRUE 194s mode: integer 194s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 194s add_na = FALSE 194s mode: double 194s num [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 194s add_na = TRUE 194s mode: double 194s num [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 194s > 194s > 194s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 194s > # All NAs 194s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 194s > for (mode in c("logical", "integer", "double")) { 194s + x <- matrix(NA_real_, nrow = 10L, ncol = 5L) 194s + cat("mode: ", mode, "\n", sep = "") 194s + storage.mode(x) <- mode 194s + str(x) 194s + 194s + # Test with and without dimnames on x 194s + for (setDimnames in c(TRUE, FALSE)) { 194s + if (setDimnames) dimnames(x) <- dimnames 194s + else dimnames(x) <- NULL 194s + # Check names attribute 194s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 194s + # Row/column ranges 194s + r0 <- rowCumprods_R(x, useNames = useNames) 194s + r1 <- rowCumprods(x, useNames = useNames) 194s + r2 <- t(colCumprods(t(x), useNames = useNames)) 194s + stopifnot(all.equal(r1, r2)) 194s + stopifnot(all.equal(r1, r0)) 194s + stopifnot(all.equal(r2, r0)) 194s + } # for (useNames ...) 194s + } # for (setDimnames ...) 194s + } # for (mode ...) 194s mode: logical 194s logi [1:10, 1:5] NA NA NA NA NA NA ... 194s mode: integer 194s int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 194s mode: double 194s num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 194s > 194s > 194s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 194s > # A 1x1 matrix 194s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 194s > for (mode in c("logical", "integer", "double")) { 194s + x <- matrix(0, nrow = 1L, ncol = 1L) 194s + cat("mode: ", mode, "\n", sep = "") 194s + storage.mode(x) <- mode 194s + str(x) 194s + 194s + dimnames <- list("a", "A") 194s + # Test with and without dimnames on x 194s + for (setDimnames in c(TRUE, FALSE)) { 194s + if (setDimnames) dimnames(x) <- dimnames 194s + else dimnames(x) <- NULL 194s + # Check names attribute 194s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 194s + # Row/column ranges 194s + r0 <- rowCumprods_R(x, useNames = useNames) 194s + r1 <- rowCumprods(x, useNames = useNames) 194s + r2 <- t(colCumprods(t(x), useNames = useNames)) 194s + stopifnot(all.equal(r1, r2)) 194s + stopifnot(all.equal(r1, r0)) 194s + stopifnot(all.equal(r2, r0)) 194s + } # for (useNames ...) 194s + } # for (setDimnames ...) 194s + } 194s mode: logical 194s logi [1, 1] FALSE 194s mode: integer 194s int [1, 1] 0 194s mode: double 194s num [1, 1] 0 194s > 194s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 194s > # BUG FIX TEST: Assert zeros don't trump NAs in integer matrices 194s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 194s > for (mode in c("logical", "integer", "double")) { 194s + x <- matrix(NA_real_, nrow = 3L, ncol = 2L) 194s + x[1, 2] <- 0 194s + x[2, 2] <- 1 194s + x[3, 1] <- 0 194s + storage.mode(x) <- mode 194s + cat("mode: ", mode, "\n", sep = "") 194s + str(x) 194s + 194s + dimnames <- list(letters[1:3], LETTERS[1:2]) 194s + # Test with and without dimnames on x 194s + for (setDimnames in c(TRUE, FALSE)) { 194s + if (setDimnames) dimnames(x) <- dimnames 194s + else dimnames(x) <- NULL 194s + # Check names attribute 194s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 194s + # Row/column ranges 194s + r0 <- rowCumprods_R(x, useNames = useNames) 194s + r1 <- rowCumprods(x, useNames = useNames) 194s + r2 <- t(colCumprods(t(x), useNames = useNames)) 194s + stopifnot(all.equal(r1, r2)) 194s + stopifnot(all.equal(r1, r0)) 194s + stopifnot(all.equal(r2, r0)) 194s + } # for (useNames ...) 194s + } # for (setDimnames ...) 194s + } 194s mode: logical 194s logi [1:3, 1:2] NA NA FALSE FALSE TRUE NA 194s mode: integer 194s int [1:3, 1:2] NA NA 0 0 1 NA 194s mode: double 194s num [1:3, 1:2] NA NA 0 0 1 NA 194s > 194s > 194s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 194s > # Corner cases 194s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 194s > for (mode in c("logical", "integer", "double")) { 194s + cat("mode: ", mode, "\n", sep = "") 194s + value <- 0 194s + storage.mode(value) <- mode 194s + if (mode == "logical") value2 <- 0L 194s + 194s + # A 0x0 matrix 194s + x <- matrix(value, nrow = 0L, ncol = 0L) 194s + str(x) 194s + r0 <- matrix(value2, nrow = nrow(x), ncol = ncol(x)) 194s + r1 <- rowCumprods(x) 194s + r2 <- t(colCumprods(t(x))) 194s + stopifnot(all.equal(r1, r2)) 194s + stopifnot(all.equal(r1, r0)) 194s + stopifnot(all.equal(r2, r0)) 194s + 194s + # A 0xK matrix 194s + x <- matrix(value, nrow = 0L, ncol = 5L) 194s + str(x) 194s + colnames <- LETTERS[1:5] 194s + # Test with and without dimnames on x 194s + for (setDimnames in c(TRUE, FALSE)) { 194s + if (setDimnames) colnames(x) <- colnames 194s + else dimnames(x) <- NULL 194s + # Check names attribute 194s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 194s + r0 <- rowCumprods_R(x, useNames = useNames) 194s + r1 <- rowCumprods(x, useNames = useNames) 194s + r2 <- t(rowCumprods(t(x), useNames = useNames)) 194s + stopifnot(all.equal(r1, r2)) 194s + stopifnot(all.equal(r1, r0)) 194s + stopifnot(all.equal(r2, r0)) 194s + } # for (useNames ...) 194s + } # for (setDimnames ...) 194s + 194s + # A Nx0 matrix 194s + x <- matrix(value, nrow = 5L, ncol = 0L) 194s + str(x) 194s + rownames <- LETTERS[1:5] 194s + # Test with and without dimnames on x 194s + for (setDimnames in c(TRUE, FALSE)) { 194s + if (setDimnames) rownames(x) <- rownames 194s + else dimnames(x) <- NULL 194s + # Check names attribute 194s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 194s + r0 <- rowCumprods_R(x, useNames = useNames) 194s + r1 <- rowCumprods(x, useNames = useNames) 194s + r2 <- t(rowCumprods(t(x), useNames = useNames)) 194s + stopifnot(all.equal(r1, r2)) 194s + stopifnot(all.equal(r1, r0)) 194s + stopifnot(all.equal(r2, r0)) 194s + } # for (useNames ...) 194s + } # for (setDimnames ...) 194s + } # for (mode ...) 194s mode: logical 194s logi[0 , 0 ] 194s logi[0 , 1:5] 194s logi[1:5, 0 ] 194s mode: integer 194s int[0 , 0 ] 194s int[0 , 1:5] 194s int[1:5, 0 ] 194s mode: double 194s num[0 , 0 ] 194s num[0 , 1:5] 194s num[1:5, 0 ] 194s > 194s 194s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 194s Copyright (C) 2024 The R Foundation for Statistical Computing 194s Platform: x86_64-pc-linux-gnu 194s 194s R is free software and comes with ABSOLUTELY NO WARRANTY. 194s You are welcome to redistribute it under certain conditions. 194s Type 'license()' or 'licence()' for distribution details. 194s 194s R is a collaborative project with many contributors. 194s Type 'contributors()' for more information and 194s 'citation()' on how to cite R or R packages in publications. 194s 194s Type 'demo()' for some demos, 'help()' for on-line help, or 194s 'help.start()' for an HTML browser interface to help. 194s Type 'q()' to quit R. 194s 194s > library("matrixStats") 194s > 194s > rowCumprods_R <- function(x, ..., useNames = NA) { 194s + suppressWarnings({ 194s + y <- t(apply(x, MARGIN = 1L, FUN = cumprod)) 194s + }) 194s + 194s + # Preserve dimnames attribute? 194s + dim(y) <- dim(x) 194s + dimnames(y) <- if (isTRUE(useNames)) dimnames(x) else NULL 194s + 194s + y 194s + } 194s > 194s > 194s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 194s > # Subsetted tests 194s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 194s > source("utils/validateIndicesFramework.R") 194s > x <- matrix(runif(6 * 6, min = -3, max = 3), nrow = 6, ncol = 6) 194s > storage.mode(x) <- "integer" 194s > 194s > # To check dimnames attribute 194s > dimnames <- list(letters[1:6], LETTERS[1:6]) 194s > 194s > # Test with and without dimnames on x 194s > for (setDimnames in c(TRUE, FALSE)) { 194s + if (setDimnames) dimnames(x) <- dimnames 194s + else dimnames(x) <- NULL 194s + for (rows in index_cases) { 194s + for (cols in index_cases) { 194s + # Check names attribute 194s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 194s + validateIndicesTestMatrix(x, rows, cols, 194s + ftest = rowCumprods, fsure = rowCumprods_R, useNames = useNames) 194s + validateIndicesTestMatrix(x, rows, cols, 194s + ftest = function(x, rows, cols, ..., useNames) { 194s + t(colCumprods(t(x), rows = cols, cols = rows, useNames = useNames)) 194s + }, fsure = rowCumprods_R, useNames = useNames) 194s + } 194s + } 194s + } 194s + } 195s > 195s 195s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 195s Copyright (C) 2024 The R Foundation for Statistical Computing 195s Platform: x86_64-pc-linux-gnu 195s 195s R is free software and comes with ABSOLUTELY NO WARRANTY. 195s You are welcome to redistribute it under certain conditions. 195s Type 'license()' or 'licence()' for distribution details. 195s 195s R is a collaborative project with many contributors. 195s Type 'contributors()' for more information and 195s 'citation()' on how to cite R or R packages in publications. 195s 195s Type 'demo()' for some demos, 'help()' for on-line help, or 195s 'help.start()' for an HTML browser interface to help. 195s Type 'q()' to quit R. 195s 195s > library("matrixStats") 195s > 195s > rowCumsums_R <- function(x, ..., useNames = NA) { 195s + suppressWarnings({ 195s + y <- t(apply(x, MARGIN = 1L, FUN = cumsum)) 195s + }) 195s + 195s + # Preserve dimnames attribute? 195s + dim(y) <- dim(x) 195s + dimnames(y) <- if (isTRUE(useNames)) dimnames(x) else NULL 195s + 195s + y 195s + } 195s > 195s > 195s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 195s > # With and without some NAs 195s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 195s > dimnames <- list(letters[1:10], LETTERS[1:5]) # to check dimnames attribute 195s > for (mode in c("logical", "integer", "double")) { 195s + for (add_na in c(FALSE, TRUE)) { 195s + cat("add_na = ", add_na, "\n", sep = "") 195s + 195s + x <- matrix(1:50, nrow = 10L, ncol = 5L) 195s + if (add_na) { 195s + x[3:7, c(2, 4)] <- NA_real_ 195s + } 195s + cat("mode: ", mode, "\n", sep = "") 195s + storage.mode(x) <- mode 195s + str(x) 195s + 195s + # Test with and without dimnames on x 195s + for (setDimnames in c(TRUE, FALSE)) { 195s + if (setDimnames) dimnames(x) <- dimnames 195s + else dimnames(x) <- NULL 195s + # Check names attribute 195s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 195s + # Row/column ranges 195s + r0 <- rowCumsums_R(x, useNames = useNames) 195s + r1 <- rowCumsums(x, useNames = useNames) 195s + r2 <- t(colCumsums(t(x), useNames = useNames)) 195s + stopifnot(all.equal(r1, r2)) 195s + stopifnot(all.equal(r1, r0)) 195s + stopifnot(all.equal(r2, r0)) 195s + } # for (useNames ...) 195s + } # for (setDimnames ...) 195s + } # for (add_na ...) 195s + } 195s add_na = FALSE 195s mode: logical 195s logi [1:10, 1:5] TRUE TRUE TRUE TRUE TRUE TRUE ... 195s add_na = TRUE 195s mode: logical 195s logi [1:10, 1:5] TRUE TRUE TRUE TRUE TRUE TRUE ... 195s add_na = FALSE 195s mode: integer 195s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 195s add_na = TRUE 195s mode: integer 195s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 195s add_na = FALSE 195s mode: double 195s num [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 195s add_na = TRUE 195s mode: double 195s num [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 195s > 195s > 195s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 195s > # All NAs 195s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 195s > for (mode in c("logical", "integer", "double")) { 195s + x <- matrix(NA_real_, nrow = 10L, ncol = 5L) 195s + cat("mode: ", mode, "\n", sep = "") 195s + storage.mode(x) <- mode 195s + str(x) 195s + 195s + # Test with and without dimnames on x 195s + for (setDimnames in c(TRUE, FALSE)) { 195s + if (setDimnames) dimnames(x) <- dimnames 195s + else dimnames(x) <- NULL 195s + # Check names attribute 195s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 195s + # Row/column ranges 195s + r0 <- rowCumsums_R(x, useNames = useNames) 195s + r1 <- rowCumsums(x, useNames = useNames) 195s + r2 <- t(colCumsums(t(x), useNames = useNames)) 195s + stopifnot(all.equal(r1, r2)) 195s + stopifnot(all.equal(r1, r0)) 195s + stopifnot(all.equal(r2, r0)) 195s + } # for (useNames ...) 195s + } # for (setDimnames ...) 195s + } # for (mode ...) 195s mode: logical 195s logi [1:10, 1:5] NA NA NA NA NA NA ... 195s mode: integer 195s int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 195s mode: double 195s num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 195s > 195s > 195s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 195s > # A 1x1 matrix 195s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 195s > dimnames <- list("a", "A") # to check dimnames attribute 195s > for (mode in c("logical", "integer", "double")) { 195s + x <- matrix(0, nrow = 1L, ncol = 1L) 195s + cat("mode: ", mode, "\n", sep = "") 195s + storage.mode(x) <- mode 195s + str(x) 195s + 195s + r0 <- rowCumsums_R(x) 195s + r1 <- rowCumsums(x) 195s + r2 <- t(colCumsums(t(x))) 195s + stopifnot(all.equal(r1, r2)) 195s + stopifnot(all.equal(r1, r0)) 195s + stopifnot(all.equal(r2, r0)) 195s + 195s + # Check dimnames attribute 195s + dimnames(x) <- dimnames 195s + # r0 <- rowCumsums_R(x) 195s + # > r0 195s + # a 195s + # [1,] 0 195s + r1 <- rowCumsums(x, useNames = TRUE) 195s + r2 <- t(colCumsums(t(x), useNames = TRUE)) 195s + stopifnot(identical(dimnames(r1), dimnames)) 195s + stopifnot(identical(dimnames(r2), dimnames)) 195s + dimnames(x) <- NULL 195s + } 195s mode: logical 195s logi [1, 1] FALSE 195s mode: integer 195s int [1, 1] 0 195s mode: double 195s num [1, 1] 0 195s > 195s > 195s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 195s > # Corner cases 195s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 195s > names <- LETTERS[1:5] # to check dimnames attribute 195s > for (mode in c("logical", "integer", "double")) { 195s + cat("mode: ", mode, "\n", sep = "") 195s + value <- 0 195s + storage.mode(value) <- mode 195s + value2 <- value 195s + if (mode == "logical") value2 <- 0L 195s + 195s + # A 0x0 matrix 195s + x <- matrix(value, nrow = 0L, ncol = 0L) 195s + str(x) 195s + r0 <- matrix(value2, nrow = nrow(x), ncol = ncol(x)) 195s + r1 <- rowCumsums(x) 195s + r2 <- t(colCumsums(t(x))) 195s + stopifnot(all.equal(r1, r2)) 195s + stopifnot(all.equal(r1, r0)) 195s + stopifnot(all.equal(r2, r0)) 195s + 195s + # A 0xK matrix 195s + x <- matrix(value, nrow = 0L, ncol = 5L) 195s + str(x) 195s + colnames <- LETTERS[1:5] 195s + # Test with and without dimnames on x 195s + for (setDimnames in c(TRUE, FALSE)) { 195s + if (setDimnames) colnames(x) <- colnames 195s + else dimnames(x) <- NULL 195s + # Check names attribute 195s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 195s + r0 <- rowCumsums_R(x, useNames = useNames) 195s + r1 <- rowCumsums(x, useNames = useNames) 195s + r2 <- t(rowCumsums(t(x), useNames = useNames)) 195s + stopifnot(all.equal(r1, r2)) 195s + stopifnot(all.equal(r1, r0)) 195s + stopifnot(all.equal(r2, r0)) 195s + } # for (useNames ...) 195s + } # for (setDimnames ...) 195s + 195s + # A Nx0 matrix 195s + x <- matrix(value, nrow = 5L, ncol = 0L) 195s + str(x) 195s + rownames <- LETTERS[1:5] 195s + # Test with and without dimnames on x 195s + for (setDimnames in c(TRUE, FALSE)) { 195s + if (setDimnames) rownames(x) <- rownames 195s + else dimnames(x) <- NULL 195s + # Check names attribute 195s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 195s + r0 <- rowCumsums_R(x, useNames = useNames) 195s + r1 <- rowCumsums(x, useNames = useNames) 195s + r2 <- t(rowCumsums(t(x), useNames = useNames)) 195s + stopifnot(all.equal(r1, r2)) 195s + stopifnot(all.equal(r1, r0)) 195s + stopifnot(all.equal(r2, r0)) 195s + } # for (useNames ...) 195s + } # for (setDimnames ...) 195s + } # for (mode ...) 195s mode: logical 195s logi[0 , 0 ] 195s logi[0 , 1:5] 195s logi[1:5, 0 ] 195s mode: integer 195s int[0 , 0 ] 195s int[0 , 1:5] 195s int[1:5, 0 ] 195s mode: double 195s num[0 , 0 ] 195s num[0 , 1:5] 195s num[1:5, 0 ] 195s > 195s 195s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 195s Copyright (C) 2024 The R Foundation for Statistical Computing 195s Platform: x86_64-pc-linux-gnu 195s 195s R is free software and comes with ABSOLUTELY NO WARRANTY. 195s You are welcome to redistribute it under certain conditions. 195s Type 'license()' or 'licence()' for distribution details. 195s 195s R is a collaborative project with many contributors. 195s Type 'contributors()' for more information and 195s 'citation()' on how to cite R or R packages in publications. 195s 195s Type 'demo()' for some demos, 'help()' for on-line help, or 195s 'help.start()' for an HTML browser interface to help. 195s Type 'q()' to quit R. 195s 195s > library("matrixStats") 195s > 195s > rowCumsums_R <- function(x, ..., useNames = NA) { 195s + suppressWarnings({ 195s + y <- t(apply(x, MARGIN = 1L, FUN = cumsum)) 195s + }) 195s + 195s + # Preserve dimnames attribute? 195s + dim(y) <- dim(x) 195s + dimnames(y) <- if (isTRUE(useNames)) dimnames(x) else NULL 195s + 195s + y 195s + } 195s > 195s > 195s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 195s > # Subsetted tests 195s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 195s > source("utils/validateIndicesFramework.R") 195s > x <- matrix(runif(6 * 6, min = -3, max = 3), nrow = 6, ncol = 6) 195s > storage.mode(x) <- "integer" 195s > 195s > # To check dimnames attribute 195s > dimnames <- list(letters[1:6], LETTERS[1:6]) 195s > 195s > # Test with and without dimnames on x 195s > for (setDimnames in c(TRUE, FALSE)) { 195s + if (setDimnames) dimnames(x) <- dimnames 195s + else dimnames(x) <- NULL 195s + for (rows in index_cases) { 195s + for (cols in index_cases) { 195s + # Check names attribute 195s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 195s + validateIndicesTestMatrix(x, rows, cols, 195s + ftest = rowCumsums, fsure = rowCumsums_R, useNames = useNames) 195s + validateIndicesTestMatrix(x, rows, cols, 195s + ftest = function(x, rows, cols, ..., useNames) { 195s + t(colCumsums(t(x), rows = cols, cols = rows, useNames = useNames)) 195s + }, fsure = rowCumsums_R, useNames = useNames) 195s + } 195s + } 195s + } 195s + } 196s > 196s 196s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 196s Copyright (C) 2024 The R Foundation for Statistical Computing 196s Platform: x86_64-pc-linux-gnu 196s 196s R is free software and comes with ABSOLUTELY NO WARRANTY. 196s You are welcome to redistribute it under certain conditions. 196s Type 'license()' or 'licence()' for distribution details. 196s 196s R is a collaborative project with many contributors. 196s Type 'contributors()' for more information and 196s 'citation()' on how to cite R or R packages in publications. 196s 196s Type 'demo()' for some demos, 'help()' for on-line help, or 196s 'help.start()' for an HTML browser interface to help. 196s Type 'q()' to quit R. 196s 196s > library("matrixStats") 196s > 196s > rowDiffs_R <- function(x, lag = 1L, differences = 1L, ..., useNames = NA) { 196s + ncol2 <- ncol(x) - lag * differences 196s + if (ncol2 <= 0) { 196s + y <- matrix(x[integer(0L)], nrow = nrow(x), ncol = 0L) 196s + # Preserve names attribute 196s + if (isTRUE(useNames) && !is.null(rownames(x))) rownames(y) <- rownames(x) 196s + return(y) 196s + } 196s + suppressWarnings({ 196s + y <- apply(x, MARGIN = 1L, FUN = diff, lag = lag, differences = differences) 196s + }) 196s + y <- t(y) 196s + 196s + # Preserve dimnames attribute 196s + dim(y) <- c(nrow(x), ncol2) 196s + if (isTRUE(useNames) && !is.null(dimnames(x))) { 196s + colnames <- colnames(x) 196s + if (!is.null(colnames)) { 196s + len <- length(colnames) 196s + colnames <- colnames[(len - ncol2 + 1):len] 196s + } 196s + dimnames(y) <- list(rownames(x), colnames) 196s + } 196s + else dimnames(y) <- NULL 196s + 196s + y 196s + } 196s > 196s > 196s > set.seed(0x42) 196s > 196s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 196s > # With and without some NAs 196s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 196s > for (mode in c("integer", "double")) { 196s + cat("mode: ", mode, "\n", sep = "") 196s + 196s + for (add_na in c(FALSE, TRUE)) { 196s + cat("add_na = ", add_na, "\n", sep = "") 196s + 196s + x <- matrix(sample(10 * 8) + 0.1, nrow = 10L, ncol = 8L) 196s + if (add_na) { 196s + x[3:7, c(2, 4)] <- NA_real_ 196s + } 196s + storage.mode(x) <- mode 196s + str(x) 196s + 196s + dimnames <- list(letters[1:10], LETTERS[1:8]) 196s + 196s + # Test with and without dimnames on x 196s + for (setDimnames in c(TRUE, FALSE)) { 196s + if (setDimnames) dimnames(x) <- dimnames 196s + else dimnames(x) <- NULL 196s + # Check dimnames attribute 196s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 196s + for (lag in 1:4) { 196s + for (differences in 1:3) { 196s + cat(sprintf("mode: %s, lag = %d, differences = %d\n", 196s + mode, lag, differences)) 196s + # Row/column ranges 196s + r0 <- rowDiffs_R(x, lag = lag, differences = differences, useNames = useNames) 196s + r1 <- rowDiffs(x, lag = lag, differences = differences, useNames = useNames) 196s + r2 <- t(colDiffs(t(x), lag = lag, differences = differences, useNames = useNames)) 196s + stopifnot(all.equal(r1, r0)) 196s + stopifnot(all.equal(r2, r0)) 196s + stopifnot(all.equal(r1, r2)) 196s + } 196s + } 196s + } # for (useNames ...) 196s + } # for (setDimnames ...) 196s + } # for (add_na ...) 196s + } # for (mode ...) 196s mode: integer 196s add_na = FALSE 196s int [1:10, 1:8] 68 26 29 47 48 10 1 38 16 40 ... 196s mode: integer, lag = 1, differences = 1 196s mode: integer, lag = 1, differences = 2 196s mode: integer, lag = 1, differences = 3 196s mode: integer, lag = 2, differences = 1 196s mode: integer, lag = 2, differences = 2 196s mode: integer, lag = 2, differences = 3 196s mode: integer, lag = 3, differences = 1 196s mode: integer, lag = 3, differences = 2 196s mode: integer, lag = 3, differences = 3 196s mode: integer, lag = 4, differences = 1 196s mode: integer, lag = 4, differences = 2 196s mode: integer, lag = 4, differences = 3 196s mode: integer, lag = 1, differences = 1 196s mode: integer, lag = 1, differences = 2 196s mode: integer, lag = 1, differences = 3 196s mode: integer, lag = 2, differences = 1 196s mode: integer, lag = 2, differences = 2 196s mode: integer, lag = 2, differences = 3 196s mode: integer, lag = 3, differences = 1 196s mode: integer, lag = 3, differences = 2 196s mode: integer, lag = 3, differences = 3 196s mode: integer, lag = 4, differences = 1 196s mode: integer, lag = 4, differences = 2 196s mode: integer, lag = 4, differences = 3 196s mode: integer, lag = 1, differences = 1 196s mode: integer, lag = 1, differences = 2 196s mode: integer, lag = 1, differences = 3 196s mode: integer, lag = 2, differences = 1 196s mode: integer, lag = 2, differences = 2 196s mode: integer, lag = 2, differences = 3 196s mode: integer, lag = 3, differences = 1 196s mode: integer, lag = 3, differences = 2 196s mode: integer, lag = 3, differences = 3 196s mode: integer, lag = 4, differences = 1 196s mode: integer, lag = 4, differences = 2 196s mode: integer, lag = 4, differences = 3 196s mode: integer, lag = 1, differences = 1 196s mode: integer, lag = 1, differences = 2 196s mode: integer, lag = 1, differences = 3 196s mode: integer, lag = 2, differences = 1 196s mode: integer, lag = 2, differences = 2 196s mode: integer, lag = 2, differences = 3 196s mode: integer, lag = 3, differences = 1 196s mode: integer, lag = 3, differences = 2 196s mode: integer, lag = 3, differences = 3 196s mode: integer, lag = 4, differences = 1 196s mode: integer, lag = 4, differences = 2 196s mode: integer, lag = 4, differences = 3 196s add_na = TRUE 196s int [1:10, 1:8] 80 71 7 52 79 22 31 10 29 63 ... 196s mode: integer, lag = 1, differences = 1 196s mode: integer, lag = 1, differences = 2 196s mode: integer, lag = 1, differences = 3 196s mode: integer, lag = 2, differences = 1 196s mode: integer, lag = 2, differences = 2 196s mode: integer, lag = 2, differences = 3 196s mode: integer, lag = 3, differences = 1 196s mode: integer, lag = 3, differences = 2 196s mode: integer, lag = 3, differences = 3 196s mode: integer, lag = 4, differences = 1 196s mode: integer, lag = 4, differences = 2 196s mode: integer, lag = 4, differences = 3 196s mode: integer, lag = 1, differences = 1 196s mode: integer, lag = 1, differences = 2 196s mode: integer, lag = 1, differences = 3 196s mode: integer, lag = 2, differences = 1 196s mode: integer, lag = 2, differences = 2 196s mode: integer, lag = 2, differences = 3 196s mode: integer, lag = 3, differences = 1 196s mode: integer, lag = 3, differences = 2 196s mode: integer, lag = 3, differences = 3 196s mode: integer, lag = 4, differences = 1 196s mode: integer, lag = 4, differences = 2 196s mode: integer, lag = 4, differences = 3 196s mode: integer, lag = 1, differences = 1 196s mode: integer, lag = 1, differences = 2 196s mode: integer, lag = 1, differences = 3 196s mode: integer, lag = 2, differences = 1 196s mode: integer, lag = 2, differences = 2 196s mode: integer, lag = 2, differences = 3 196s mode: integer, lag = 3, differences = 1 196s mode: integer, lag = 3, differences = 2 196s mode: integer, lag = 3, differences = 3 196s mode: integer, lag = 4, differences = 1 196s mode: integer, lag = 4, differences = 2 196s mode: integer, lag = 4, differences = 3 196s mode: integer, lag = 1, differences = 1 196s mode: integer, lag = 1, differences = 2 196s mode: integer, lag = 1, differences = 3 196s mode: integer, lag = 2, differences = 1 196s mode: integer, lag = 2, differences = 2 196s mode: integer, lag = 2, differences = 3 196s mode: integer, lag = 3, differences = 1 196s mode: integer, lag = 3, differences = 2 196s mode: integer, lag = 3, differences = 3 196s mode: integer, lag = 4, differences = 1 196s mode: integer, lag = 4, differences = 2 196s mode: integer, lag = 4, differences = 3 196s mode: double 196s add_na = FALSE 196s num [1:10, 1:8] 36.1 15.1 27.1 63.1 62.1 58.1 28.1 19.1 41.1 3.1 ... 196s mode: double, lag = 1, differences = 1 196s mode: double, lag = 1, differences = 2 196s mode: double, lag = 1, differences = 3 196s mode: double, lag = 2, differences = 1 196s mode: double, lag = 2, differences = 2 196s mode: double, lag = 2, differences = 3 196s mode: double, lag = 3, differences = 1 196s mode: double, lag = 3, differences = 2 196s mode: double, lag = 3, differences = 3 196s mode: double, lag = 4, differences = 1 196s mode: double, lag = 4, differences = 2 196s mode: double, lag = 4, differences = 3 196s mode: double, lag = 1, differences = 1 196s mode: double, lag = 1, differences = 2 196s mode: double, lag = 1, differences = 3 196s mode: double, lag = 2, differences = 1 196s mode: double, lag = 2, differences = 2 196s mode: double, lag = 2, differences = 3 196s mode: double, lag = 3, differences = 1 196s mode: double, lag = 3, differences = 2 196s mode: double, lag = 3, differences = 3 196s mode: double, lag = 4, differences = 1 196s mode: double, lag = 4, differences = 2 196s mode: double, lag = 4, differences = 3 196s mode: double, lag = 1, differences = 1 196s mode: double, lag = 1, differences = 2 196s mode: double, lag = 1, differences = 3 196s mode: double, lag = 2, differences = 1 196s mode: double, lag = 2, differences = 2 196s mode: double, lag = 2, differences = 3 196s mode: double, lag = 3, differences = 1 196s mode: double, lag = 3, differences = 2 196s mode: double, lag = 3, differences = 3 196s mode: double, lag = 4, differences = 1 196s mode: double, lag = 4, differences = 2 196s mode: double, lag = 4, differences = 3 196s mode: double, lag = 1, differences = 1 196s mode: double, lag = 1, differences = 2 196s mode: double, lag = 1, differences = 3 196s mode: double, lag = 2, differences = 1 196s mode: double, lag = 2, differences = 2 196s mode: double, lag = 2, differences = 3 196s mode: double, lag = 3, differences = 1 196s mode: double, lag = 3, differences = 2 196s mode: double, lag = 3, differences = 3 196s mode: double, lag = 4, differences = 1 196s mode: double, lag = 4, differences = 2 196s mode: double, lag = 4, differences = 3 196s add_na = TRUE 196s num [1:10, 1:8] 67.1 80.1 45.1 8.1 39.1 66.1 27.1 71.1 47.1 46.1 ... 196s mode: double, lag = 1, differences = 1 196s mode: double, lag = 1, differences = 2 196s mode: double, lag = 1, differences = 3 196s mode: double, lag = 2, differences = 1 196s mode: double, lag = 2, differences = 2 196s mode: double, lag = 2, differences = 3 196s mode: double, lag = 3, differences = 1 196s mode: double, lag = 3, differences = 2 196s mode: double, lag = 3, differences = 3 196s mode: double, lag = 4, differences = 1 196s mode: double, lag = 4, differences = 2 196s mode: double, lag = 4, differences = 3 196s mode: double, lag = 1, differences = 1 196s mode: double, lag = 1, differences = 2 196s mode: double, lag = 1, differences = 3 196s mode: double, lag = 2, differences = 1 196s mode: double, lag = 2, differences = 2 196s mode: double, lag = 2, differences = 3 196s mode: double, lag = 3, differences = 1 196s mode: double, lag = 3, differences = 2 196s mode: double, lag = 3, differences = 3 196s mode: double, lag = 4, differences = 1 196s mode: double, lag = 4, differences = 2 196s mode: double, lag = 4, differences = 3 196s mode: double, lag = 1, differences = 1 196s mode: double, lag = 1, differences = 2 196s mode: double, lag = 1, differences = 3 196s mode: double, lag = 2, differences = 1 196s mode: double, lag = 2, differences = 2 196s mode: double, lag = 2, differences = 3 196s mode: double, lag = 3, differences = 1 196s mode: double, lag = 3, differences = 2 196s mode: double, lag = 3, differences = 3 196s mode: double, lag = 4, differences = 1 196s mode: double, lag = 4, differences = 2 196s mode: double, lag = 4, differences = 3 196s mode: double, lag = 1, differences = 1 196s mode: double, lag = 1, differences = 2 196s mode: double, lag = 1, differences = 3 196s mode: double, lag = 2, differences = 1 196s mode: double, lag = 2, differences = 2 196s mode: double, lag = 2, differences = 3 196s mode: double, lag = 3, differences = 1 196s mode: double, lag = 3, differences = 2 196s mode: double, lag = 3, differences = 3 196s mode: double, lag = 4, differences = 1 196s mode: double, lag = 4, differences = 2 196s mode: double, lag = 4, differences = 3 196s > 196s > 196s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 196s > # All NAs 196s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 196s > for (mode in c("integer", "double")) { 196s + cat("mode: ", mode, "\n", sep = "") 196s + x <- matrix(NA_real_, nrow = 10L, ncol = 5L) 196s + storage.mode(x) <- mode 196s + str(x) 196s + 196s + dimnames <- list(letters[1:10], LETTERS[1:5]) 196s + 196s + # Test with and without dimnames on x 196s + for (setDimnames in c(TRUE, FALSE)) { 196s + if (setDimnames) dimnames(x) <- dimnames 196s + else dimnames(x) <- NULL 196s + # Check dimnames attribute 196s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 196s + r0 <- rowDiffs_R(x, useNames = useNames) 196s + r1 <- rowDiffs(x, useNames = useNames) 196s + r2 <- t(colDiffs(t(x), useNames = useNames)) 196s + stopifnot(all.equal(r1, r0)) 196s + stopifnot(all.equal(r2, r0)) 196s + stopifnot(all.equal(r1, r2)) 196s + } # for (useNames ...) 196s + } # for (setDimnames ...) 196s + } # for (mode ...) 196s mode: integer 196s int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 196s mode: double 196s num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 196s > 196s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 196s > # A 1x1 matrix 196s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 196s > x <- matrix(0, nrow = 1L, ncol = 1L) 196s > dimnames <- list("a", "A") 196s > # Test with and without dimnames on x 196s > for (setDimnames in c(TRUE, FALSE)) { 196s + if (setDimnames) dimnames(x) <- dimnames 196s + else dimnames(x) <- NULL 196s + # Check dimnames attribute 196s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 196s + r0 <- rowDiffs_R(x, useNames = useNames) 196s + r1 <- rowDiffs(x, useNames = useNames) 196s + r2 <- t(colDiffs(t(x), useNames = useNames)) 196s + stopifnot(all.equal(r1, r0)) 196s + stopifnot(all.equal(r2, r0)) 196s + stopifnot(all.equal(r1, r2)) 196s + } # for (useNames ...) 196s + } # for (setDimnames ...) 196s > 196s 196s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 196s Copyright (C) 2024 The R Foundation for Statistical Computing 196s Platform: x86_64-pc-linux-gnu 196s 196s R is free software and comes with ABSOLUTELY NO WARRANTY. 196s You are welcome to redistribute it under certain conditions. 196s Type 'license()' or 'licence()' for distribution details. 196s 196s R is a collaborative project with many contributors. 196s Type 'contributors()' for more information and 196s 'citation()' on how to cite R or R packages in publications. 196s 196s Type 'demo()' for some demos, 'help()' for on-line help, or 196s 'help.start()' for an HTML browser interface to help. 196s Type 'q()' to quit R. 196s 196s > library("matrixStats") 196s > 196s > rowDiffs_R <- function(x, lag = 1L, differences = 1L, ..., useNames = NA) { 196s + ncol2 <- ncol(x) - lag * differences 196s + if (ncol2 <= 0) { 196s + y <- matrix(x[integer(0L)], nrow = nrow(x), ncol = 0L) 196s + # Preserve names attribute 196s + if (isTRUE(useNames) && !is.null(rownames(x))) rownames(y) <- rownames(x) 196s + return(y) 196s + } 196s + suppressWarnings({ 196s + y <- apply(x, MARGIN = 1L, FUN = diff, lag = lag, differences = differences) 196s + }) 196s + y <- t(y) 196s + 196s + # Preserve dimnames attribute 196s + dim(y) <- c(nrow(x), ncol2) 196s + if (isTRUE(useNames) && !is.null(dimnames(x))) { 196s + colnames <- colnames(x) 196s + if (!is.null(colnames)) { 196s + len <- length(colnames) 196s + colnames <- colnames[(len - ncol2 + 1):len] 196s + } 196s + dimnames(y) <- list(rownames(x), colnames) 196s + } 196s + else dimnames(y) <- NULL 196s + 196s + y 196s + } 196s > 196s > 196s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 196s > # Subsetted tests 196s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 196s > source("utils/validateIndicesFramework.R") 196s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 196s > storage.mode(x) <- "integer" 196s > 196s > # To check dimnames attribute 196s > dimnames <- list(letters[1:6], LETTERS[1:6]) 196s > 196s > # Test with and without dimnames on x 196s > for (setDimnames in c(TRUE, FALSE)) { 196s + if (setDimnames) dimnames(x) <- dimnames 196s + else dimnames(x) <- NULL 196s + 196s + count <- 0L 196s + for (rows in index_cases) { 196s + for (cols in index_cases) { 196s + count <- count + 1L 196s + for (lag in 1:2) { 196s + for (differences in 1:3) { 196s + # Check dimnames attribute 196s + useNames <- c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE) 196s + useNames <- useNames[count %% length(useNames) + 1] 196s + validateIndicesTestMatrix(x, rows, cols, 196s + ftest = rowDiffs, fsure = rowDiffs_R, 196s + lag = lag, differences = differences, useNames = useNames) 196s + validateIndicesTestMatrix(x, rows, cols, 196s + ftest = function(x, rows, cols, ..., useNames) { 196s + t(colDiffs(t(x), rows = cols, cols = rows, ..., useNames = useNames)) 196s + }, fsure = rowDiffs_R, 196s + lag = lag, differences = differences, useNames = useNames) 196s + } 196s + } 196s + } 196s + } 196s + } 199s > 199s 199s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 199s Copyright (C) 2024 The R Foundation for Statistical Computing 199s Platform: x86_64-pc-linux-gnu 199s 199s R is free software and comes with ABSOLUTELY NO WARRANTY. 199s You are welcome to redistribute it under certain conditions. 199s Type 'license()' or 'licence()' for distribution details. 199s 199s R is a collaborative project with many contributors. 199s Type 'contributors()' for more information and 199s 'citation()' on how to cite R or R packages in publications. 199s 199s Type 'demo()' for some demos, 'help()' for on-line help, or 199s 'help.start()' for an HTML browser interface to help. 199s Type 'q()' to quit R. 199s 199s > library("matrixStats") 199s > 199s > rowIQRs_R <- function(x, na.rm = FALSE, ..., useNames = NA) { 199s + quantile_na <- function(x, ..., na.rm = FALSE) { 199s + if (!na.rm && anyMissing(x)) 199s + return(c(NA_real_, NA_real_)) 199s + quantile(x, ..., na.rm = na.rm) 199s + } 199s + q <- apply(x, MARGIN = 1L, FUN = quantile_na, 199s + probs = c(0.25, 0.75), na.rm = na.rm) 199s + rownames(q) <- NULL # Not needed anymore 199s + 199s + # Preserve names attribute 199s + dim(q) <- c(2L, nrow(x)) 199s + colnames(q) <- if (isTRUE(useNames)) rownames(x) else NULL 199s + 199s + q[2L, , drop = TRUE] - q[1L, , drop = TRUE] 199s + } 199s > 199s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 199s > # Test with multiple quantiles 199s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 199s > for (mode in c("integer", "double")) { 199s + cat("mode: ", mode, "\n", sep = "") 199s + x <- matrix(1:100 + 0.1, nrow = 10, ncol = 10) 199s + storage.mode(x) <- mode 199s + str(x) 199s + 199s + # To check names attribute 199s + dimnames <- list(letters[1:10], LETTERS[1:10]) 199s + 199s + for (add_na in c(FALSE, TRUE)) { 199s + if (add_na) { 199s + x[3:5, 6:9] <- NA 199s + } 199s + # Test with and without dimnames on x 199s + for (setDimnames in c(TRUE, FALSE)) { 199s + if (setDimnames) dimnames(x) <- dimnames 199s + else dimnames(x) <- NULL 199s + for (na.rm in c(FALSE, TRUE)) { 199s + # Check names attribute 199s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 199s + probs <- c(0, 0.5, 1) 199s + q0 <- rowIQRs_R(x, na.rm = na.rm, useNames = useNames) 199s + print(q0) 199s + q1 <- rowIQRs(x, na.rm = na.rm, useNames = useNames) 199s + print(q1) 199s + stopifnot(all.equal(q1, q0)) 199s + q2 <- colIQRs(t(x), na.rm = na.rm, useNames = useNames) 199s + stopifnot(all.equal(q2, q0)) 199s + 199s + q <- iqr(x[3, ], na.rm = na.rm) 199s + print(q) 199s + } # for (useNames ...) 199s + } # for (na.rm ...) 199s + } # for (setDimnames ...) 199s + } # for (add_na ...) 199s + } # for (mode ...) 199s mode: integer 199s int [1:10, 1:10] 1 2 3 4 5 6 7 8 9 10 ... 199s a b c d e f g h i j 199s 45 45 45 45 45 45 45 45 45 45 199s a b c d e f g h i j 199s 45 45 45 45 45 45 45 45 45 45 199s [1] 45 199s [1] 45 45 45 45 45 45 45 45 45 45 199s [1] 45 45 45 45 45 45 45 45 45 45 199s [1] 45 199s a b c d e f g h i j 199s 45 45 45 45 45 45 45 45 45 45 199s a b c d e f g h i j 199s 45 45 45 45 45 45 45 45 45 45 199s [1] 45 199s [1] 45 45 45 45 45 45 45 45 45 45 199s [1] 45 45 45 45 45 45 45 45 45 45 199s [1] 45 199s [1] 45 45 45 45 45 45 45 45 45 45 199s [1] 45 45 45 45 45 45 45 45 45 45 199s [1] 45 199s [1] 45 45 45 45 45 45 45 45 45 45 199s [1] 45 45 45 45 45 45 45 45 45 45 199s [1] 45 199s [1] 45 45 45 45 45 45 45 45 45 45 199s [1] 45 45 45 45 45 45 45 45 45 45 199s [1] 45 199s [1] 45 45 45 45 45 45 45 45 45 45 199s [1] 45 45 45 45 45 45 45 45 45 45 199s [1] 45 199s a b c d e f g h i j 199s 45 45 NA NA NA 45 45 45 45 45 199s a b c d e f g h i j 199s 45 45 NA NA NA 45 45 45 45 45 199s [1] NA 199s [1] 45 45 NA NA NA 45 45 45 45 45 199s [1] 45 45 NA NA NA 45 45 45 45 45 199s [1] NA 199s a b c d e f g h i j 199s 45 45 25 25 25 45 45 45 45 45 199s a b c d e f g h i j 199s 45 45 25 25 25 45 45 45 45 45 199s [1] 25 199s [1] 45 45 25 25 25 45 45 45 45 45 199s [1] 45 45 25 25 25 45 45 45 45 45 199s [1] 25 199s [1] 45 45 NA NA NA 45 45 45 45 45 199s [1] 45 45 NA NA NA 45 45 45 45 45 199s [1] NA 199s [1] 45 45 NA NA NA 45 45 45 45 45 199s [1] 45 45 NA NA NA 45 45 45 45 45 199s [1] NA 199s [1] 45 45 25 25 25 45 45 45 45 45 199s [1] 45 45 25 25 25 45 45 45 45 45 199s [1] 25 199s [1] 45 45 25 25 25 45 45 45 45 45 199s [1] 45 45 25 25 25 45 45 45 45 45 199s [1] 25 199s mode: double 199s num [1:10, 1:10] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ... 199s a b c d e f g h i j 199s 45 45 45 45 45 45 45 45 45 45 199s a b c d e f g h i j 199s 45 45 45 45 45 45 45 45 45 45 199s [1] 45 199s [1] 45 45 45 45 45 45 45 45 45 45 199s [1] 45 45 45 45 45 45 45 45 45 45 199s [1] 45 199s a b c d e f g h i j 199s 45 45 45 45 45 45 45 45 45 45 199s a b c d e f g h i j 199s 45 45 45 45 45 45 45 45 45 45 199s [1] 45 199s [1] 45 45 45 45 45 45 45 45 45 45 199s [1] 45 45 45 45 45 45 45 45 45 45 199s [1] 45 199s [1] 45 45 45 45 45 45 45 45 45 45 199s [1] 45 45 45 45 45 45 45 45 45 45 199s [1] 45 199s [1] 45 45 45 45 45 45 45 45 45 45 199s [1] 45 45 45 45 45 45 45 45 45 45 199s [1] 45 199s [1] 45 45 45 45 45 45 45 45 45 45 199s [1] 45 45 45 45 45 45 45 45 45 45 199s [1] 45 199s [1] 45 45 45 45 45 45 45 45 45 45 199s [1] 45 45 45 45 45 45 45 45 45 45 199s [1] 45 199s a b c d e f g h i j 199s 45 45 NA NA NA 45 45 45 45 45 199s a b c d e f g h i j 199s 45 45 NA NA NA 45 45 45 45 45 199s [1] NA 199s [1] 45 45 NA NA NA 45 45 45 45 45 199s [1] 45 45 NA NA NA 45 45 45 45 45 199s [1] NA 199s a b c d e f g h i j 199s 45 45 25 25 25 45 45 45 45 45 199s a b c d e f g h i j 199s 45 45 25 25 25 45 45 45 45 45 199s [1] 25 199s [1] 45 45 25 25 25 45 45 45 45 45 199s [1] 45 45 25 25 25 45 45 45 45 45 199s [1] 25 199s [1] 45 45 NA NA NA 45 45 45 45 45 199s [1] 45 45 NA NA NA 45 45 45 45 45 199s [1] NA 199s [1] 45 45 NA NA NA 45 45 45 45 45 199s [1] 45 45 NA NA NA 45 45 45 45 45 199s [1] NA 199s [1] 45 45 25 25 25 45 45 45 45 45 199s [1] 45 45 25 25 25 45 45 45 45 45 199s [1] 25 199s [1] 45 45 25 25 25 45 45 45 45 45 199s [1] 45 45 25 25 25 45 45 45 45 45 199s [1] 25 199s > 199s > 199s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 199s > # Test corner cases 199s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 199s > for (mode in c("integer", "double")) { 199s + cat("mode: ", mode, "\n", sep = "") 199s + # Empty vectors 199s + x <- integer(0L) 199s + storage.mode(x) <- mode 199s + str(x) 199s + q <- iqr(x) 199s + print(q) 199s + stopifnot(identical(q, NA_real_)) 199s + 199s + # Scalar 199s + x <- 1L 199s + storage.mode(x) <- mode 199s + str(x) 199s + q <- iqr(x) 199s + str(q) 199s + stopifnot(identical(q, 0)) 199s + } 199s mode: integer 199s int(0) 199s [1] NA 199s int 1 199s num 0 199s mode: double 199s num(0) 199s [1] NA 199s num 1 199s num 0 199s > 199s > 199s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 199s > # Single row matrices 199s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 199s > x <- matrix(1, nrow = 1L, ncol = 2L) 199s > dimnames <- list("a", LETTERS[1:2]) 199s > # Test with and without dimnames on x 199s > for (setDimnames in c(TRUE, FALSE)) { 199s + if (setDimnames) dimnames(x) <- dimnames 199s + else dimnames(x) <- NULL 199s + # Check names attribute 199s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 199s + q0 <- rowIQRs_R(x, useNames = useNames) 199s + q1 <- rowIQRs(x, useNames = useNames) 199s + q2 <- colIQRs(t(x), useNames = useNames) 199s + stopifnot(all.equal(q0, q1)) 199s + stopifnot(all.equal(q0, q2)) 199s + } 199s + } 199s > 199s > x <- matrix(1, nrow = 2L, ncol = 1L) 199s > q <- colIQRs(x) 199s > stopifnot(identical(q, 0)) 199s > 199s 199s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 199s Copyright (C) 2024 The R Foundation for Statistical Computing 199s Platform: x86_64-pc-linux-gnu 199s 199s R is free software and comes with ABSOLUTELY NO WARRANTY. 199s You are welcome to redistribute it under certain conditions. 199s Type 'license()' or 'licence()' for distribution details. 199s 199s R is a collaborative project with many contributors. 199s Type 'contributors()' for more information and 199s 'citation()' on how to cite R or R packages in publications. 199s 199s Type 'demo()' for some demos, 'help()' for on-line help, or 199s 'help.start()' for an HTML browser interface to help. 199s Type 'q()' to quit R. 199s 199s > library("matrixStats") 199s > 199s > rowIQRs_R <- function(x, na.rm = FALSE, ..., useNames = NA) { 199s + quantile_na <- function(x, ..., na.rm = FALSE) { 199s + if (!na.rm && anyMissing(x)) 199s + return(c(NA_real_, NA_real_)) 199s + quantile(x, ..., na.rm = na.rm) 199s + } 199s + q <- apply(x, MARGIN = 1L, FUN = quantile_na, 199s + probs = c(0.25, 0.75), na.rm = na.rm) 199s + rownames(q) <- NULL # Not needed anymore 199s + 199s + # Preserve names attribute 199s + dim(q) <- c(2L, nrow(x)) 199s + colnames(q) <- if (isTRUE(useNames)) rownames(x) else NULL 199s + 199s + q[2L, , drop = TRUE] - q[1L, , drop = TRUE] 199s + } 199s > 199s > 199s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 199s > # Subsetted tests 199s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 199s > source("utils/validateIndicesFramework.R") 199s > x <- runif(6, min = -6, max = 6) 199s > for (idxs in index_cases) { 199s + for (na.rm in c(TRUE, FALSE)) { 199s + validateIndicesTestVector(x, idxs, ftest = iqr, fsure = function(x, na.rm) { 199s + dim(x) <- c(1L, length(x)) 199s + rowIQRs_R(x, na.rm = na.rm) 199s + }, na.rm = na.rm) 199s + } 199s + } 199s > 199s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 199s > 199s > # To check names attribute 199s > dimnames <- list(letters[1:6], LETTERS[1:6]) 199s > 199s > # Test with and without dimnames on x 199s > for (setDimnames in c(TRUE, FALSE)) { 199s + if (setDimnames) dimnames(x) <- dimnames 199s + else dimnames(x) <- NULL 199s + 199s + count <- 0L 199s + for (rows in index_cases) { 199s + for (cols in index_cases) { 199s + count <- count + 1L 199s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 199s + useNames <- c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE) 199s + useNames <- useNames[count %% length(useNames) + 1] 199s + 199s + validateIndicesTestMatrix(x, rows, cols, 199s + ftest = rowIQRs, fsure = rowIQRs_R, 199s + na.rm = na.rm, useNames = useNames) 199s + validateIndicesTestMatrix(x, rows, cols, 199s + fcoltest = colIQRs, fsure = rowIQRs_R, 199s + na.rm = na.rm, useNames = useNames) 199s + } 199s + } 199s + } 200s > 200s 200s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 200s Copyright (C) 2024 The R Foundation for Statistical Computing 200s Platform: x86_64-pc-linux-gnu 200s 200s R is free software and comes with ABSOLUTELY NO WARRANTY. 200s You are welcome to redistribute it under certain conditions. 200s Type 'license()' or 'licence()' for distribution details. 200s 200s R is a collaborative project with many contributors. 200s Type 'contributors()' for more information and 200s 'citation()' on how to cite R or R packages in publications. 200s 200s Type 'demo()' for some demos, 'help()' for on-line help, or 200s 'help.start()' for an HTML browser interface to help. 200s Type 'q()' to quit R. 200s 200s > # Test inspired by the harmonic mean example in R-help 200s > # thread '[R] Beyond double-precision?' on May 9, 2009. 200s > 200s > library("matrixStats") 200s > library("stats") 200s > 200s > logSumExp0 <- function(lx) { 200s + idx_max <- which.max(lx) 200s + log1p(sum(exp(lx[-idx_max] - lx[idx_max]))) + lx[idx_max] 200s + } 200s > 200s > n <- 200L 200s > set.seed(1) 200s > 200s > for (mode in c("integer", "double")) { 200s + cat("mode: ", mode, "\n", sep = "") 200s + x <- matrix(runif(n, min = 1.0, max = 3.0), nrow = 20L) 200s + storage.mode(x) <- mode 200s + str(x) 200s + 200s + # The logarithm of the harmonic mean by rows 200s + y_h <- log(1 / rowMeans(1 / x)) 200s + str(y_h) 200s + 200s + lx_neg <- -log(x) 200s + 200s + y0 <- log(ncol(x)) - apply(lx_neg, MARGIN = 1L, FUN = logSumExp0) 200s + stopifnot(all.equal(y0, y_h)) 200s + 200s + y1 <- log(ncol(x)) - apply(lx_neg, MARGIN = 1L, FUN = logSumExp) 200s + stopifnot(all.equal(y1, y0)) 200s + 200s + y2 <- log(ncol(x)) - rowLogSumExps(lx_neg) 200s + stopifnot(all.equal(y2, y0)) 200s + 200s + y3 <- log(ncol(x)) - colLogSumExps(t(lx_neg)) 200s + stopifnot(all.equal(y3, y0)) 200s + 200s + 200s + # The logarithm of the harmonic mean by columns 200s + y_h <- log(1 / colMeans(1 / x)) 200s + str(y_h) 200s + 200s + y0 <- log(nrow(x)) - apply(lx_neg, MARGIN = 2L, FUN = logSumExp0) 200s + stopifnot(all.equal(y0, y_h)) 200s + 200s + y1 <- log(nrow(x)) - apply(lx_neg, MARGIN = 2L, FUN = logSumExp) 200s + stopifnot(all.equal(y1, y0)) 200s + 200s + y2 <- log(nrow(x)) - colLogSumExps(lx_neg) 200s + stopifnot(all.equal(y2, y0)) 200s + 200s + y3 <- log(nrow(x)) - rowLogSumExps(t(lx_neg)) 200s + stopifnot(all.equal(y3, y0)) 200s + 200s + # Testing names 200s + rownames(lx_neg) <- seq_len(nrow(x)) 200s + colnames(lx_neg) <- seq_len(ncol(x)) 200s + y2 <- rowLogSumExps(lx_neg, useNames = TRUE) 200s + stopifnot(identical(names(y2), rownames(lx_neg))) 200s + y3 <- colLogSumExps(t(lx_neg), useNames = TRUE) 200s + stopifnot(identical(names(y3), rownames(lx_neg))) 200s + } # for (mode ...) 200s mode: integer 200s int [1:20, 1:10] 1 1 2 2 1 2 2 2 2 1 ... 200s num [1:20] 0.357 0.223 0.223 0.288 0.511 ... 200s num [1:10] 0.322 0.223 0.322 0.255 0.255 ... 200s mode: double 200s num [1:20, 1:10] 1.54 1.44 2.03 1.54 1.36 ... 200s num [1:20] 0.526 0.466 0.734 0.638 0.604 ... 200s num [1:10] 0.627 0.582 0.617 0.474 0.418 ... 200s > 200s > 200s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 200s > # Corner cases 200s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 200s > ## Zero-size matrices 200s > lx <- matrix(numeric(0L), nrow = 0L, ncol = 0L) 200s > y <- rowLogSumExps(lx) 200s > print(y) 200s numeric(0) 200s > stopifnot(length(y) == nrow(lx)) 200s > 200s > y <- colLogSumExps(lx) 200s > print(y) 200s numeric(0) 200s > stopifnot(length(y) == ncol(lx)) 200s > 200s > ## Zero-height matrices 200s > lx <- matrix(numeric(0L), nrow = 0L, ncol = 5L) 200s > y <- rowLogSumExps(lx) 200s > print(y) 200s numeric(0) 200s > stopifnot(length(y) == nrow(lx)) 200s > 200s > y <- colLogSumExps(lx) 200s > print(y) 200s [1] -Inf -Inf -Inf -Inf -Inf 200s > stopifnot(length(y) == ncol(lx)) 200s > stopifnot(all(y == -Inf)) 200s > 200s > ## Zero-width matrices 200s > lx <- matrix(numeric(0L), nrow = 5L, ncol = 0L) 200s > y <- colLogSumExps(lx) 200s > print(y) 200s numeric(0) 200s > stopifnot(length(y) == ncol(lx)) 200s > 200s > y <- rowLogSumExps(lx) 200s > print(y) 200s [1] -Inf -Inf -Inf -Inf -Inf 200s > stopifnot(length(y) == nrow(lx)) 200s > stopifnot(all(y == -Inf)) 200s > 200s > 200s > ## Matrices with one element 200s > lx <- matrix(1.0, nrow = 1L, ncol = 1L) 200s > y <- rowLogSumExps(lx) 200s > print(y) 200s [1] 1 200s > stopifnot(length(y) == nrow(lx)) 200s > stopifnot(all(y == lx)) 200s > 200s > y <- colLogSumExps(lx) 200s > print(y) 200s [1] 1 200s > stopifnot(length(y) == ncol(lx)) 200s > stopifnot(all(y == lx)) 200s > 200s > ## All missing values 200s > lx <- matrix(NA_real_, nrow = 1L, ncol = 1L) 200s > y <- rowLogSumExps(lx, na.rm = TRUE) 200s > print(y) 200s [1] -Inf 200s > stopifnot(length(y) == nrow(lx)) 200s > stopifnot(identical(y, -Inf)) 200s > 200s > lx <- matrix(NA_real_, nrow = 1L, ncol = 1L) 200s > y <- colLogSumExps(lx, na.rm = TRUE) 200s > print(y) 200s [1] -Inf 200s > stopifnot(length(y) == ncol(lx)) 200s > stopifnot(identical(y, -Inf)) 200s > 200s > lx <- matrix(NA_real_, nrow = 2L, ncol = 2L) 200s > y <- rowLogSumExps(lx, na.rm = TRUE) 200s > print(y) 200s [1] -Inf -Inf 200s > stopifnot(length(y) == nrow(lx)) 200s > stopifnot(all(y == -Inf)) 200s > 200s > y <- rowLogSumExps(lx, na.rm = FALSE) 200s > print(y) 200s [1] NA NA 200s > stopifnot(length(y) == nrow(lx)) 200s > stopifnot(all(is.na(y) & !is.nan(y))) 200s > 200s > lx <- matrix(NA_real_, nrow = 2L, ncol = 2L) 200s > y <- colLogSumExps(lx, na.rm = TRUE) 200s > print(y) 200s [1] -Inf -Inf 200s > stopifnot(length(y) == ncol(lx)) 200s > stopifnot(all(y == -Inf)) 200s > 200s > y <- colLogSumExps(lx, na.rm = FALSE) 200s > print(y) 200s [1] NA NA 200s > stopifnot(length(y) == ncol(lx)) 200s > stopifnot(all(is.na(y) & !is.nan(y))) 200s > 200s > ## +Inf values 200s > lx <- matrix(c(1, 2, +Inf), nrow = 3L, ncol = 2L) 200s > y <- colLogSumExps(lx, na.rm = TRUE) 200s > print(y) 200s [1] Inf Inf 200s > stopifnot(length(y) == ncol(lx)) 200s > stopifnot(all(y == +Inf)) 200s > 200s > ## multiple -Inf values 200s > lx <- matrix(c(-Inf, -Inf), nrow = 2L, ncol = 3L) 200s > y <- rowLogSumExps(lx) 200s > print(y) 200s [1] -Inf -Inf 200s > stopifnot(length(y) == nrow(lx)) 200s > stopifnot(all(y == -Inf)) 200s > 200s > lx <- matrix(c(-Inf, 5, -Inf), nrow = 2L, ncol = 3L, byrow = TRUE) 200s > y <- rowLogSumExps(lx) 200s > print(y) 200s [1] 5 5 200s > stopifnot(length(y) == nrow(lx)) 200s > stopifnot(all(y == 5)) 200s > 200s > ## Bug report #104 (https://github.com/HenrikBengtsson/matrixStats/issues/104) 200s > ## (This would core dump on Windows) 200s > x <- matrix(0.0, nrow = 2L, ncol = 32762L) 200s > y <- colLogSumExps(x) 200s > str(y) 200s num [1:32762] 0.693 0.693 0.693 0.693 0.693 ... 200s > 200s > ## Bug report #120 (https://github.com/HenrikBengtsson/matrixStats/issues/120) 200s > ## (This would error if x had rownames/colnames and non-NULL rows/cols were 200s > ## used) 200s > x <- matrix(runif(6), nrow = 2L, ncol = 3L, 200s + dimnames = list(c("A", "B"), c("a", "b", "c"))) 200s > y <- colLogSumExps(x, cols = 3:1, useNames = TRUE) 200s > stopifnot(names(y) == c("c", "b", "a")) 200s > y <- rowLogSumExps(x, rows = 2, useNames = TRUE) 200s > stopifnot(names(y) == "B") 200s > 200s > 200s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 200s > # Check names attributes 200s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 200s > 200s > ## Create isFALSE() if running on an old version of R 200s > if (!exists("isFALSE", mode="function")) { 200s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 200s + } 200s > 200s > rowLogSumExps_R <- function(x, ..., useNames = NA) { 200s + res <- apply(x, MARGIN = 1L, FUN = function(rx, ...) { 200s + log(sum(exp(rx), ...)) 200s + }, ...) 200s + if (isFALSE(useNames)) names(res) <- NULL 200s + res 200s + } 200s > 200s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6L, ncol = 6L) 200s > 200s > # To check names attribute 200s > dimnames <- list(letters[1:6], LETTERS[1:6]) 200s > 200s > # Test with and without dimnames on x 200s > for (setDimnames in c(TRUE, FALSE)) { 200s + if (setDimnames) dimnames(x) <- dimnames 200s + else dimnames(x) <- NULL 200s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 200s + y0 <- rowLogSumExps_R(x, useNames = useNames) 200s + y1 <- rowLogSumExps(x, useNames = useNames) 200s + y2 <- colLogSumExps(t(x), useNames = useNames) 200s + stopifnot(all.equal(y1, y0)) 200s + stopifnot(all.equal(y2, y0)) 200s + } 200s + } 200s > 200s 200s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 200s Copyright (C) 2024 The R Foundation for Statistical Computing 200s Platform: x86_64-pc-linux-gnu 200s 200s R is free software and comes with ABSOLUTELY NO WARRANTY. 200s You are welcome to redistribute it under certain conditions. 200s Type 'license()' or 'licence()' for distribution details. 200s 200s R is a collaborative project with many contributors. 200s Type 'contributors()' for more information and 200s 'citation()' on how to cite R or R packages in publications. 200s 200s Type 'demo()' for some demos, 'help()' for on-line help, or 200s 'help.start()' for an HTML browser interface to help. 200s Type 'q()' to quit R. 200s 200s > library("matrixStats") 200s > 200s > ## Create isFALSE() if running on an old version of R 200s > if (!exists("isFALSE", mode="function")) { 200s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 200s + } 200s > 200s > rowLogSumExps_R <- function(x, ..., useNames = NA) { 200s + res <- apply(x, MARGIN = 1L, FUN = function(rx, ...) { 200s + log(sum(exp(rx), ...)) 200s + }, ...) 200s + if (isFALSE(useNames)) names(res) <- NULL 200s + res 200s + } 200s > 200s > 200s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 200s > # Subsetted tests 200s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 200s > source("utils/validateIndicesFramework.R") 200s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 200s > 200s > # To check names attribute 200s > dimnames <- list(letters[1:6], LETTERS[1:6]) 200s > 200s > # Test with and without dimnames on x 200s > for (setDimnames in c(TRUE, FALSE)) { 200s + if (setDimnames) dimnames(x) <- dimnames 200s + else dimnames(x) <- NULL 200s + for (rows in index_cases) { 200s + for (cols in index_cases) { 200s + for (na.rm in c(TRUE, FALSE)) { 200s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 200s + validateIndicesTestMatrix(x, rows, cols, 200s + ftest = rowLogSumExps, 200s + fsure = rowLogSumExps_R, 200s + na.rm = na.rm, useNames = useNames) 200s + validateIndicesTestMatrix(x, rows, cols, 200s + fcoltest = colLogSumExps, 200s + fsure = rowLogSumExps_R, 200s + na.rm = na.rm, useNames = useNames) 200s + } 200s + } 200s + } 200s + } 200s + } 201s > 201s 201s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 201s Copyright (C) 2024 The R Foundation for Statistical Computing 201s Platform: x86_64-pc-linux-gnu 201s 201s R is free software and comes with ABSOLUTELY NO WARRANTY. 201s You are welcome to redistribute it under certain conditions. 201s Type 'license()' or 'licence()' for distribution details. 201s 201s R is a collaborative project with many contributors. 201s Type 'contributors()' for more information and 201s 'citation()' on how to cite R or R packages in publications. 201s 201s Type 'demo()' for some demos, 'help()' for on-line help, or 201s 'help.start()' for an HTML browser interface to help. 201s Type 'q()' to quit R. 201s 201s > library("matrixStats") 201s > 201s > ## Always allow testing of the 'center' argument (as long as it's not defunct) 201s > options(matrixStats.center.onUse = "ignore") 201s > 201s > rowMads_R <- function(x, na.rm = FALSE, ..., useNames = NA) { 201s + suppressWarnings({ 201s + res <- apply(x, MARGIN = 1L, FUN = mad, na.rm = na.rm) 201s + }) 201s + if (is.na(useNames) || !useNames) names(res) <- NULL 201s + res 201s + } 201s > 201s > colMads_R <- function(x, na.rm = FALSE, ..., useNames = NA) { 201s + suppressWarnings({ 201s + res <- apply(x, MARGIN = 2L, FUN = mad, na.rm = na.rm) 201s + }) 201s + if (is.na(useNames) || !useNames) names(res) <- NULL 201s + res 201s + } 201s > 201s > rowMads_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = NA) { 201s + center <- rowMedians(x, cols = cols, na.rm = na.rm, useNames = FALSE) 201s + rowMads(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 201s + } 201s > 201s > colMads_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = NA) { 201s + center <- colMedians(x, rows = rows, na.rm = na.rm, useNames = FALSE) 201s + colMads(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 201s + } 201s > 201s > 201s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 201s > # A 3x3 matrix (no ties) 201s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 201s > for (mode in c("integer", "double")) { 201s + x <- matrix(c(1, 2, 3, 2, 3, 4, 3, 4, 5) + 0.1, nrow = 3, ncol = 3) 201s + cat("mode: ", mode, "\n", sep = "") 201s + storage.mode(x) <- mode 201s + str(x) 201s + 201s + # To check name attribute 201s + dimnames <- list(letters[1:3], LETTERS[1:3]) 201s + 201s + # Test with and without dimnames on x 201s + for (setDimnames in c(TRUE, FALSE)) { 201s + if (setDimnames) dimnames(x) <- dimnames 201s + else dimnames(x) <- NULL 201s + tx <- t(x) 201s + # Check names attribute 201s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 201s + cat("rowMads():\n") 201s + center <- rowMedians(x, na.rm = TRUE, useNames = useNames) 201s + r0 <- rowMads_R(x, na.rm = TRUE, useNames = useNames) 201s + r1 <- rowMads(x, na.rm = TRUE, useNames = useNames) 201s + r1b <- rowMads_center(x, na.rm = TRUE, useNames = useNames) 201s + r1c <- rowMads(x, center = center, na.rm = TRUE, useNames = useNames) 201s + r2 <- colMads(tx, na.rm = TRUE, useNames = useNames) 201s + r2b <- colMads_center(tx, na.rm = TRUE, useNames = useNames) 201s + stopifnot(all.equal(r1, r2)) 201s + stopifnot(all.equal(r1, r0)) 201s + stopifnot(all.equal(r1b, r1)) 201s + stopifnot(all.equal(r1c, r1)) 201s + stopifnot(all.equal(r2, r0)) 201s + stopifnot(all.equal(r2b, r2)) 201s + 201s + cat("colMads():\n") 201s + center <- colMedians(x, na.rm = TRUE, useNames = useNames) 201s + r0 <- colMads_R(x, na.rm = TRUE, useNames = useNames) 201s + r1 <- colMads(x, na.rm = TRUE, useNames = useNames) 201s + r1b <- colMads_center(x, na.rm = TRUE, useNames = useNames) 201s + r1c <- colMads(x, center = center, na.rm = TRUE, useNames = useNames) 201s + r2 <- rowMads(tx, na.rm = TRUE, useNames = useNames) 201s + r2b <- rowMads_center(tx, na.rm = TRUE, useNames = useNames) 201s + stopifnot(all.equal(r1, r2)) 201s + stopifnot(all.equal(r1, r0)) 201s + stopifnot(all.equal(r1b, r1)) 201s + stopifnot(all.equal(r1c, r1)) 201s + stopifnot(all.equal(r2, r0)) 201s + stopifnot(all.equal(r2b, r2)) 201s + } 201s + } 201s + } 201s mode: integer 201s int [1:3, 1:3] 1 2 3 2 3 4 3 4 5 201s rowMads(): 201s colMads(): 201s rowMads(): 201s colMads(): 201s rowMads(): 201s colMads(): 201s rowMads(): 201s colMads(): 201s mode: double 201s num [1:3, 1:3] 1.1 2.1 3.1 2.1 3.1 4.1 3.1 4.1 5.1 201s rowMads(): 201s colMads(): 201s rowMads(): 201s colMads(): 201s rowMads(): 201s colMads(): 201s rowMads(): 201s colMads(): 201s > 201s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 201s > # Ties: a 4x4 matrix 201s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 201s > for (mode in c("integer", "double")) { 201s + x <- matrix(c(1:4, 2:5, 3:6, 4:7) + 0.1, nrow = 4, ncol = 4) 201s + cat("mode: ", mode, "\n", sep = "") 201s + storage.mode(x) <- mode 201s + str(x) 201s + tx <- t(x) 201s + 201s + # To check name attribute 201s + dimnames <- list(letters[1:4], LETTERS[1:4]) 201s + 201s + # Test with and without dimnames on x 201s + for (setDimnames in c(TRUE, FALSE)) { 201s + if (setDimnames) dimnames(x) <- dimnames 201s + else dimnames(x) <- NULL 201s + tx <- t(x) 201s + # Check names attribute 201s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 201s + cat("rowMads():\n") 201s + r0 <- rowMads_R(x, na.rm = TRUE, useNames = useNames) 201s + r1 <- rowMads(x, na.rm = TRUE, useNames = useNames) 201s + r2 <- colMads(tx, na.rm = TRUE, useNames = useNames) 201s + stopifnot(all.equal(r1, r2)) 201s + stopifnot(all.equal(r1, r0)) 201s + stopifnot(all.equal(r2, r0)) 201s + 201s + cat("colMads():\n") 201s + r0 <- colMads_R(x, na.rm = TRUE, useNames = useNames) 201s + r1 <- colMads(x, na.rm = TRUE, useNames = useNames) 201s + r2 <- rowMads(tx, na.rm = TRUE, useNames = useNames) 201s + stopifnot(all.equal(r1, r2)) 201s + stopifnot(all.equal(r1, r0)) 201s + stopifnot(all.equal(r2, r0)) 201s + } 201s + } 201s + } 201s mode: integer 201s int [1:4, 1:4] 1 2 3 4 2 3 4 5 3 4 ... 201s rowMads(): 201s colMads(): 201s rowMads(): 201s colMads(): 201s rowMads(): 201s colMads(): 201s rowMads(): 201s colMads(): 201s mode: double 201s num [1:4, 1:4] 1.1 2.1 3.1 4.1 2.1 3.1 4.1 5.1 3.1 4.1 ... 201s rowMads(): 201s colMads(): 201s rowMads(): 201s colMads(): 201s rowMads(): 201s colMads(): 201s rowMads(): 201s colMads(): 201s > tx <- NULL 201s > 201s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 201s > # No ties: a 3x3 matrix with an NA value 201s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 201s > for (mode in c("integer", "double")) { 201s + x <- matrix(c(1, 2, 3, 2, 3, 4, 3, 4, 5) + 0.1, nrow = 3, ncol = 3) 201s + x[2, 2] <- NA_real_ 201s + 201s + cat("mode: ", mode, "\n", sep = "") 201s + storage.mode(x) <- mode 201s + str(x) 201s + tx <- t(x) 201s + 201s + # To check name attribute 201s + dimnames <- list(letters[1:3], LETTERS[1:3]) 201s + 201s + # Test with and without dimnames on x 201s + for (setDimnames in c(TRUE, FALSE)) { 201s + if (setDimnames) dimnames(x) <- dimnames 201s + else dimnames(x) <- NULL 201s + tx <- t(x) 201s + # Check names attribute 201s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 201s + cat("rowMads():\n") 201s + r0 <- rowMads_R(x, na.rm = TRUE, useNames = useNames) 201s + r1 <- rowMads(x, na.rm = TRUE, useNames = useNames) 201s + r2 <- colMads(tx, na.rm = TRUE, useNames = useNames) 201s + stopifnot(all.equal(r1, r2)) 201s + stopifnot(all.equal(r1, r0)) 201s + stopifnot(all.equal(r2, r0)) 201s + 201s + cat("colMads():\n") 201s + r0 <- colMads_R(x, na.rm = TRUE, useNames = useNames) 201s + r1 <- colMads(x, na.rm = TRUE, useNames = useNames) 201s + r2 <- rowMads(tx, na.rm = TRUE, useNames = useNames) 201s + stopifnot(all.equal(r1, r2)) 201s + stopifnot(all.equal(r1, r0)) 201s + stopifnot(all.equal(r2, r0)) 201s + } 201s + } 201s + } 202s mode: integer 202s int [1:3, 1:3] 1 2 3 2 NA 4 3 4 5 202s rowMads(): 202s colMads(): 202s rowMads(): 202s colMads(): 202s rowMads(): 202s colMads(): 202s rowMads(): 202s colMads(): 202s mode: double 202s num [1:3, 1:3] 1.1 2.1 3.1 2.1 NA 4.1 3.1 4.1 5.1 202s rowMads(): 202s colMads(): 202s rowMads(): 202s colMads(): 202s rowMads(): 202s colMads(): 202s rowMads(): 202s colMads(): 202s > tx <- NULL 202s > 202s > 202s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 202s > # With and without some NAs 202s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 202s > for (add_na in c(FALSE, TRUE)) { 202s + cat("add_na = ", add_na, "\n", sep = "") 202s + 202s + x <- matrix(1:50, nrow = 10L, ncol = 5L) 202s + if (add_na) { 202s + x[3:7, c(2, 4)] <- NA_real_ 202s + } 202s + 202s + # To check name attribute 202s + dimnames <- list(letters[1:10], LETTERS[1:5]) 202s + 202s + # Test with and without dimnames on x 202s + for (setDimnames in c(TRUE, FALSE)) { 202s + if (setDimnames) dimnames(x) <- dimnames 202s + else dimnames(x) <- NULL 202s + tx <- t(x) 202s + # Row/column ranges 202s + for (na.rm in c(FALSE, TRUE)) { 202s + # Check names attribute 202s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 202s + cat("na.rm = ", na.rm, "\n", sep = "") 202s + cat("rowMads():\n") 202s + center <- rowMedians(x, na.rm = na.rm, useNames = useNames) 202s + r0 <- rowMads_R(x, na.rm = na.rm, useNames = useNames) 202s + r1 <- rowMads(x, na.rm = na.rm, useNames = useNames) 202s + r2 <- rowMads(x, center = center, na.rm = na.rm, useNames = useNames) 202s + r3 <- colMads(tx, na.rm = na.rm, useNames = useNames) 202s + stopifnot(all.equal(r1, r0)) 202s + stopifnot(all.equal(r2, r0)) 202s + stopifnot(all.equal(r2, r1)) 202s + stopifnot(all.equal(r3, r0)) 202s + stopifnot(all.equal(r3, r1)) 202s + stopifnot(all.equal(r3, r2)) 202s + 202s + cat("colMads():\n") 202s + center <- colMedians(x, na.rm = na.rm, useNames = useNames) 202s + r0 <- colMads_R(x, na.rm = na.rm, useNames = useNames) 202s + r1 <- colMads(x, na.rm = na.rm, useNames = useNames) 202s + r2 <- colMads(x, center = center, na.rm = na.rm, useNames = useNames) 202s + r3 <- rowMads(tx, na.rm = na.rm, useNames = useNames) 202s + stopifnot(all.equal(r1, r0)) 202s + stopifnot(all.equal(r2, r0)) 202s + stopifnot(all.equal(r2, r1)) 202s + stopifnot(all.equal(r3, r0)) 202s + stopifnot(all.equal(r3, r1)) 202s + stopifnot(all.equal(r3, r2)) 202s + } 202s + } 202s + } 202s + tx <- NULL 202s + } # for (add_na ...) 202s add_na = FALSE 202s na.rm = FALSE 202s rowMads(): 202s colMads(): 202s na.rm = FALSE 202s rowMads(): 202s colMads(): 202s na.rm = TRUE 202s rowMads(): 202s colMads(): 202s na.rm = TRUE 202s rowMads(): 202s colMads(): 202s na.rm = FALSE 202s rowMads(): 202s colMads(): 202s na.rm = FALSE 202s rowMads(): 202s colMads(): 202s na.rm = TRUE 202s rowMads(): 202s colMads(): 202s na.rm = TRUE 202s rowMads(): 202s colMads(): 202s add_na = TRUE 202s na.rm = FALSE 202s rowMads(): 202s colMads(): 202s na.rm = FALSE 202s rowMads(): 202s colMads(): 202s na.rm = TRUE 202s rowMads(): 202s colMads(): 202s na.rm = TRUE 202s rowMads(): 202s colMads(): 202s na.rm = FALSE 202s rowMads(): 202s colMads(): 202s na.rm = FALSE 202s rowMads(): 202s colMads(): 202s na.rm = TRUE 202s rowMads(): 202s colMads(): 202s na.rm = TRUE 202s rowMads(): 202s colMads(): 202s > 202s > 202s > 202s > 202s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 202s > # All NAs 202s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 202s > x <- matrix(NA_real_, nrow = 10L, ncol = 5L) 202s > # Test with and without dimnames on x 202s > for (setDimnames in c(TRUE, FALSE)) { 202s + if (setDimnames) dimnames(x) <- dimnames 202s + else dimnames(x) <- NULL 202s + tx <- t(x) 202s + # Row/column ranges 202s + for (na.rm in c(FALSE, TRUE)) { 202s + # Check names attribute 202s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 202s + cat("na.rm = ", na.rm, "\n", sep = "") 202s + r0 <- rowMads_R(x, na.rm = na.rm, useNames = useNames) 202s + if (na.rm) r0[is.na(r0)] <- NaN 202s + r1 <- rowMads(x, na.rm = na.rm, useNames = useNames) 202s + r2 <- colMads(tx, na.rm = na.rm, useNames = useNames) 202s + stopifnot(all.equal(r1, r0)) 202s + stopifnot(all.equal(r2, r0)) 202s + stopifnot(all.equal(r1, r2)) 202s + } 202s + } 202s + } 202s na.rm = FALSE 202s na.rm = FALSE 202s na.rm = TRUE 202s na.rm = TRUE 202s na.rm = FALSE 202s na.rm = FALSE 202s na.rm = TRUE 202s na.rm = TRUE 202s > tx <- NULL 202s > 202s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 202s > # A 1x1 matrix 202s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 202s > x <- matrix(0, nrow = 1L, ncol = 1L) 202s > dimnames <- list("a", "A") 202s > # Test with and without dimnames on x 202s > for (setDimnames in c(TRUE, FALSE)) { 202s + if (setDimnames) dimnames(x) <- dimnames 202s + else dimnames(x) <- NULL 202s + tx <- t(x) 202s + # Row/column ranges 202s + for (na.rm in c(FALSE, TRUE)) { 202s + # Check names attribute 202s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 202s + cat("na.rm = ", na.rm, "\n", sep = "") 202s + r0 <- rowMads_R(x, na.rm = na.rm, useNames = useNames) 202s + r1 <- rowMads(x, na.rm = na.rm, useNames = useNames) 202s + r2 <- colMads(tx, na.rm = na.rm, useNames = useNames) 202s + stopifnot(all.equal(r1, r0)) 202s + stopifnot(all.equal(r2, r0)) 202s + stopifnot(all.equal(r1, r2)) 202s + } 202s + } 202s + } 202s na.rm = FALSE 202s na.rm = FALSE 202s na.rm = TRUE 202s na.rm = TRUE 202s na.rm = FALSE 202s na.rm = FALSE 202s na.rm = TRUE 202s na.rm = TRUE 202s > 202s > 202s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 202s > # A 0x0 matrix 202s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 202s > x <- matrix(double(0), nrow = 0, ncol = 0) 202s > tx <- t(x) 202s > for (na.rm in c(FALSE, TRUE)) { 202s + cat("na.rm = ", na.rm, "\n", sep = "") 202s + r0 <- rowMads_R(x, na.rm = na.rm) 202s + r1 <- rowMads(x, na.rm = na.rm) 202s + r2 <- colMads(tx, na.rm = na.rm) 202s + stopifnot(all.equal(r1, r2)) 202s + stopifnot(all.equal(r1, r0)) 202s + stopifnot(all.equal(r2, r0)) 202s + } 202s na.rm = FALSE 202s na.rm = TRUE 202s > 202s 202s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 202s Copyright (C) 2024 The R Foundation for Statistical Computing 202s Platform: x86_64-pc-linux-gnu 202s 202s R is free software and comes with ABSOLUTELY NO WARRANTY. 202s You are welcome to redistribute it under certain conditions. 202s Type 'license()' or 'licence()' for distribution details. 202s 202s R is a collaborative project with many contributors. 202s Type 'contributors()' for more information and 202s 'citation()' on how to cite R or R packages in publications. 202s 202s Type 'demo()' for some demos, 'help()' for on-line help, or 202s 'help.start()' for an HTML browser interface to help. 202s Type 'q()' to quit R. 202s 202s > library("matrixStats") 202s > 202s > ## Always allow testing of the 'center' argument (as long as it's not defunct) 202s > options(matrixStats.center.onUse = "ignore") 202s > 202s > rowMads_R <- function(x, na.rm = FALSE, ..., useNames = NA) { 202s + suppressWarnings({ 202s + res <- apply(x, MARGIN = 1L, FUN = mad, na.rm = na.rm) 202s + }) 202s + if (is.na(useNames) || !useNames) names(res) <- NULL 202s + res 202s + } 202s > 202s > colMads_R <- function(x, na.rm = FALSE, ..., useNames = NA) { 202s + suppressWarnings({ 202s + res <- apply(x, MARGIN = 2L, FUN = mad, na.rm = na.rm) 202s + }) 202s + if (is.na(useNames) || !useNames) names(res) <- NULL 202s + res 202s + } 202s > 202s > rowMads_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = NA) { 202s + center <- rowMedians(x, cols = cols, na.rm = na.rm, useNames = FALSE) 202s + rowMads(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 202s + } 202s > 202s > colMads_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = NA) { 202s + center <- colMedians(x, rows = rows, na.rm = na.rm, useNames = FALSE) 202s + colMads(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 202s + } 202s > 202s > 202s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 202s > # Subsetted tests 202s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 202s > source("utils/validateIndicesFramework.R") 202s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 202s > storage.mode(x) <- "integer" 202s > 202s > # To check names attribute 202s > dimnames <- list(letters[1:6], LETTERS[1:6]) 202s > 202s > # Test with and without dimnames on x 202s > for (setDimnames in c(TRUE, FALSE)) { 202s + if (setDimnames) dimnames(x) <- dimnames 202s + else dimnames(x) <- NULL 202s + 202s + count <- 0L 202s + for (rows in index_cases) { 202s + for (cols in index_cases) { 202s + count <- count + 1L 202s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 202s + useNames <- c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE) 202s + useNames <- useNames[count %% length(useNames) + 1] 202s + 202s + validateIndicesTestMatrix(x, rows, cols, 202s + ftest = rowMads, fsure = rowMads_R, 202s + na.rm = na.rm, useNames = useNames) 202s + validateIndicesTestMatrix(x, rows, cols, 202s + ftest = rowMads_center, fsure = rowMads_R, 202s + na.rm = na.rm, useNames = useNames) 202s + 202s + validateIndicesTestMatrix(x, rows, cols, 202s + fcoltest = colMads, fsure = rowMads_R, 202s + na.rm = na.rm, useNames = useNames) 202s + validateIndicesTestMatrix(x, rows, cols, 202s + fcoltest = colMads_center, fsure = rowMads_R, 202s + na.rm = na.rm, useNames = useNames) 202s + } 202s + } 202s + } 203s > 203s 203s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 203s Copyright (C) 2024 The R Foundation for Statistical Computing 203s Platform: x86_64-pc-linux-gnu 203s 203s R is free software and comes with ABSOLUTELY NO WARRANTY. 203s You are welcome to redistribute it under certain conditions. 203s Type 'license()' or 'licence()' for distribution details. 203s 203s R is a collaborative project with many contributors. 203s Type 'contributors()' for more information and 203s 'citation()' on how to cite R or R packages in publications. 203s 203s Type 'demo()' for some demos, 'help()' for on-line help, or 203s 'help.start()' for an HTML browser interface to help. 203s Type 'q()' to quit R. 203s 203s > library("matrixStats") 203s > 203s > rowMeans_R <- function(x, na.rm = FALSE, ..., useNames = NA) { 203s + res <- rowMeans(x, na.rm = na.rm) 203s + if (is.na(useNames) || !useNames) names(res) <- NULL 203s + res 203s + } 203s > 203s > colMeans_R <- function(x, na.rm = FALSE, ..., useNames = NA) { 203s + res <- colMeans(x, na.rm = na.rm) 203s + if (is.na(useNames) || !useNames) names(res) <- NULL 203s + res 203s + } 203s > 203s > for (mode in c("integer", "logical", "double")) { 203s + x <- matrix(-4:4, nrow = 3, ncol = 3) 203s + storage.mode(x) <- mode 203s + if (mode == "double") x <- x + 0.1 203s + 203s + # To check names attribute 203s + dimnames <- list(letters[1:3], LETTERS[1:3]) 203s + 203s + # Test with and without dimnames on x 203s + for (setDimnames in c(TRUE, FALSE)) { 203s + if (setDimnames) dimnames(x) <- dimnames 203s + else dimnames(x) <- NULL 203s + # Check names attribute 203s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 203s + y0 <- rowMeans_R(x, na.rm = FALSE, useNames = useNames) 203s + y1 <- rowMeans2(x, na.rm = FALSE, useNames = useNames) 203s + stopifnot(all.equal(y1, y0)) 203s + 203s + y0 <- colMeans_R(x, na.rm = FALSE, useNames = useNames) 203s + y1 <- colMeans2(x, na.rm = FALSE, useNames = useNames) 203s + stopifnot(all.equal(y1, y0)) 203s + } 203s + } 203s + } 203s > 203s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 203s > # Special case: Single-element matrix 203s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 203s > cat("Special case: Single-element matrix:\n") 203s Special case: Single-element matrix: 203s > for (mode in c("integer", "logical", "double")) { 203s + x <- matrix(1, nrow = 1, ncol = 1) 203s + storage.mode(x) <- mode 203s + 203s + # To check names attribute 203s + dimnames <- list("a", "A") 203s + 203s + # Test with and without dimnames on x 203s + for (setDimnames in c(TRUE, FALSE)) { 203s + if (setDimnames) dimnames(x) <- dimnames 203s + else dimnames(x) <- NULL 203s + # Check names attribute 203s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 203s + y0 <- rowMeans_R(x, na.rm = FALSE, useNames = useNames) 203s + y1 <- rowMeans2(x, na.rm = FALSE, useNames = useNames) 203s + stopifnot(all.equal(y1, y0)) 203s + 203s + y0 <- colMeans_R(x, na.rm = FALSE, useNames = useNames) 203s + y1 <- colMeans2(x, na.rm = FALSE, useNames = useNames) 203s + stopifnot(all.equal(y1, y0)) 203s + } 203s + } 203s + } 203s > 203s > 203s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 203s > # Special case: Empty matrix 203s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 203s > cat("Special case: Empty matrix:\n") 203s Special case: Empty matrix: 203s > for (mode in c("integer", "logical", "double")) { 203s + x <- matrix(integer(0), nrow = 0, ncol = 0) 203s + storage.mode(x) <- mode 203s + 203s + y0 <- rowMeans(x, na.rm = FALSE) 203s + y1 <- rowMeans2(x, na.rm = FALSE) 203s + stopifnot(all.equal(y1, y0)) 203s + 203s + y0 <- colMeans(x, na.rm = FALSE) 203s + y1 <- colMeans2(x, na.rm = FALSE) 203s + stopifnot(all.equal(y1, y0)) 203s + } 203s > 203s > 203s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 203s > # Special case: All NAs 203s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 203s > cat("Special case: All NAs:\n") 203s Special case: All NAs: 203s > for (mode in c("integer", "logical", "double")) { 203s + x <- matrix(NA_integer_, nrow = 3, ncol = 3) 203s + storage.mode(x) <- mode 203s + 203s + # To check names attribute 203s + dimnames <- list(letters[1:3], LETTERS[1:3]) 203s + 203s + # Test with and without dimnames on x 203s + for (setDimnames in c(TRUE, FALSE)) { 203s + if (setDimnames) dimnames(x) <- dimnames 203s + else dimnames(x) <- NULL 203s + # Check names attribute 203s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 203s + y0 <- rowMeans_R(x, na.rm = TRUE, useNames = useNames) 203s + y1 <- rowMeans2(x, na.rm = TRUE, useNames = useNames) 203s + stopifnot(all.equal(y1, y0)) 203s + 203s + y0 <- colMeans_R(x, na.rm = TRUE, useNames = useNames) 203s + y1 <- colMeans2(x, na.rm = TRUE, useNames = useNames) 203s + stopifnot(all.equal(y1, y0)) 203s + } 203s + } 203s + } 203s > 203s > 203s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 203s > # Special case: All NaNs 203s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 203s > cat("Special case: All NaNs:\n") 203s Special case: All NaNs: 203s > x <- matrix(NA_real_, nrow = 3, ncol = 3) 203s > 203s > # Test with and without dimnames on x 203s > for (setDimnames in c(TRUE, FALSE)) { 203s + if (setDimnames) dimnames(x) <- dimnames 203s + else dimnames(x) <- NULL 203s + # Check names attribute 203s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 203s + y0 <- rowMeans_R(x, na.rm = TRUE, useNames = useNames) 203s + y1 <- rowMeans2(x, na.rm = TRUE, useNames = useNames) 203s + stopifnot(all.equal(y1, y0)) 203s + 203s + y0 <- colMeans_R(x, na.rm = TRUE, useNames = useNames) 203s + y1 <- colMeans2(x, na.rm = TRUE, useNames = useNames) 203s + stopifnot(all.equal(y1, y0)) 203s + } 203s + } 203s > 203s > 203s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 203s > # Special case: All Infs 203s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 203s > cat("Special case: All Infs:\n") 203s Special case: All Infs: 203s > x <- matrix(Inf, nrow = 3, ncol = 3) 203s > 203s > # Test with and without dimnames on x 203s > for (setDimnames in c(TRUE, FALSE)) { 203s + if (setDimnames) dimnames(x) <- dimnames 203s + else dimnames(x) <- NULL 203s + # Check names attribute 203s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 203s + y0 <- rowMeans_R(x, na.rm = FALSE, useNames = useNames) 203s + y1 <- rowMeans2(x, na.rm = FALSE, useNames = useNames) 203s + stopifnot(all.equal(y1, y0)) 203s + 203s + y0 <- colMeans_R(x, na.rm = FALSE, useNames = useNames) 203s + y1 <- colMeans2(x, na.rm = FALSE, useNames = useNames) 203s + stopifnot(all.equal(y1, y0)) 203s + } 203s + } 203s > 203s > 203s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 203s > # Special case: All -Infs 203s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 203s > cat("Special case: All -Infs:\n") 203s Special case: All -Infs: 203s > x <- matrix(-Inf, nrow = 3, ncol = 3) 203s > 203s > # Test with and without dimnames on x 203s > for (setDimnames in c(TRUE, FALSE)) { 203s + if (setDimnames) dimnames(x) <- dimnames 203s + else dimnames(x) <- NULL 203s + # Check names attribute 203s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 203s + y0 <- rowMeans_R(x, na.rm = FALSE, useNames = useNames) 203s + y1 <- rowMeans2(x, na.rm = FALSE, useNames = useNames) 203s + stopifnot(all.equal(y1, y0)) 203s + 203s + y0 <- colMeans_R(x, na.rm = FALSE, useNames = useNames) 203s + y1 <- colMeans2(x, na.rm = FALSE, useNames = useNames) 203s + stopifnot(all.equal(y1, y0)) 203s + } 203s + } 203s > 203s > 203s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 203s > # Special case: Infs and -Infs 203s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 203s > cat("Special case: Infs and -Infs:\n") 203s Special case: Infs and -Infs: 203s > x <- matrix(c(-Inf, +Inf), nrow = 4, ncol = 4) 203s > 203s > # To check names attribute 203s > dimnames <- list(letters[1:4], LETTERS[1:4]) 203s > 203s > # Test with and without dimnames on x 203s > for (setDimnames in c(TRUE, FALSE)) { 203s + if (setDimnames) dimnames(x) <- dimnames 203s + else dimnames(x) <- NULL 203s + # Check names attribute 203s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 203s + y0 <- rowMeans_R(x, na.rm = FALSE, useNames = useNames) 203s + y1 <- rowMeans2(x, na.rm = FALSE, useNames = useNames) 203s + stopifnot(all.equal(y1, y0)) 203s + 203s + y0 <- colMeans_R(x, na.rm = FALSE, useNames = useNames) 203s + y1 <- colMeans2(x, na.rm = FALSE, useNames = useNames) 203s + stopifnot(all.equal(y1, y0)) 203s + } 203s + } 203s > 203s > 203s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 203s > # Special case: NaNs and NAs 203s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 203s > cat("Special case: NaNs and NAs:\n") 203s Special case: NaNs and NAs: 203s > x <- matrix(c(NaN, NA_real_), nrow = 4, ncol = 4) 203s > 203s > # Test with and without dimnames on x 203s > for (setDimnames in c(TRUE, FALSE)) { 203s + if (setDimnames) dimnames(x) <- dimnames 203s + else dimnames(x) <- NULL 203s + # Check names attribute 203s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 203s + y0 <- rowMeans_R(x, na.rm = FALSE, useNames = useNames) 203s + str(y0) 203s + stopifnot(all(is.na(y0)), length(unique(y0)) >= 1L) 203s + y1 <- rowMeans2(x, na.rm = FALSE, useNames = useNames) 203s + str(y1) 203s + stopifnot(all(is.na(y1)), length(unique(y1)) >= 1L) 203s + stopifnot(all.equal(y1, y0)) 203s + 203s + y0 <- colMeans_R(x, na.rm = FALSE, useNames = useNames) 203s + stopifnot(all(is.na(y0)), length(unique(y0)) == 1L) 203s + y1 <- colMeans2(x, na.rm = FALSE, useNames = useNames) 203s + stopifnot(all(is.na(y1)), length(unique(y1)) == 1L) 203s + stopifnot(all.equal(y1, y0)) 203s + } 203s + } 203s Named num [1:4] NaN NA NaN NA 203s - attr(*, "names")= chr [1:4] "a" "b" "c" "d" 203s Named num [1:4] NaN NA NaN NA 203s - attr(*, "names")= chr [1:4] "a" "b" "c" "d" 203s num [1:4] NaN NA NaN NA 203s num [1:4] NaN NA NaN NA 203s num [1:4] NaN NA NaN NA 203s num [1:4] NaN NA NaN NA 203s num [1:4] NaN NA NaN NA 203s num [1:4] NaN NA NaN NA 203s > ## NOTE, due to compiler optimization, it is not guaranteed that NA is 203s > ## returned here (as one would expect). NaN might very well be returned, 203s > ## when both NA and NaN are involved. This is an accepted feature in R, 203s > ## which is documented in help("is.nan"). See also 203s > ## https://stat.ethz.ch/pipermail/r-devel/2017-April/074009.html. 203s > ## Thus, we cannot guarantee that y1 is identical to y0. 203s > 203s > 203s > 203s > 203s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 203s > # Special case: Integer overflow with ties 203s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 203s > cat("Special case: Integer overflow with ties:\n") 203s Special case: Integer overflow with ties: 203s > x <- matrix(.Machine$integer.max, nrow = 4, ncol = 4) 203s > 203s > # Test with and without dimnames on x 203s > for (setDimnames in c(TRUE, FALSE)) { 203s + if (setDimnames) dimnames(x) <- dimnames 203s + else dimnames(x) <- NULL 203s + # Check names attribute 203s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 203s + y0 <- rowMeans_R(x, na.rm = FALSE, useNames = useNames) 203s + y1 <- rowMeans2(x, na.rm = FALSE, useNames = useNames) 203s + stopifnot(all.equal(y1, y0)) 203s + 203s + y0 <- colMeans_R(x, na.rm = FALSE, useNames = useNames) 203s + y1 <- colMeans2(x, na.rm = FALSE, useNames = useNames) 203s + stopifnot(all.equal(y1, y0)) 203s + } 203s + } 203s > 203s > 203s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 203s > # Consistency checks 203s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 203s > set.seed(1) 203s > 203s > cat("Consistency checks:\n") 203s Consistency checks: 203s > n_sims <- if (Sys.getenv("_R_CHECK_USE_VALGRIND_") != "") 4L else 20L 203s > for (kk in seq_len(n_sims)) { 203s + cat("Random test #", kk, "\n", sep = "") 203s + 203s + # Simulate data in a matrix of any shape 203s + dim <- sample(50:200, size = 2) 203s + n <- prod(dim) 203s + x <- rnorm(n, sd = 100) 203s + dim(x) <- dim 203s + 203s + # Add NAs? 203s + if ((kk %% 4) %in% c(3, 0)) { 203s + cat("Adding NAs\n") 203s + nna <- sample(n, size = 1) 203s + na_values <- c(NA_real_, NaN) 203s + t <- sample(na_values, size = nna, replace = TRUE) 203s + x[sample(length(x), size = nna)] <- t 203s + } 203s + 203s + # Mode? 203s + modes <- "double" 203s + if ((kk %% 4) %in% c(2, 0)) { 203s + modes <- c("integer", "logical") 203s + } 203s + 203s + for (mode in modes) { 203s + if (mode != "double") { 203s + cat(sprintf("Coercing from %s to %s\n", storage.mode(x), mode)) 203s + storage.mode(x) <- mode 203s + } 203s + 203s + na.rm <- sample(c(TRUE, FALSE), size = 1) 203s + 203s + # rowMeans2(): 203s + y0 <- rowMeans(x, na.rm = na.rm) 203s + y1 <- rowMeans2(x, na.rm = na.rm) 203s + stopifnot(all.equal(y1, y0)) 203s + y2 <- colMeans2(t(x), na.rm = na.rm) 203s + stopifnot(all.equal(y2, y0)) 203s + 203s + # colMeans2(): 203s + y0 <- colMeans(x, na.rm = na.rm) 203s + y1 <- colMeans2(x, na.rm = na.rm) 203s + stopifnot(all.equal(y1, y0)) 203s + y2 <- rowMeans2(t(x), na.rm = na.rm) 203s + stopifnot(all.equal(y2, y0)) 203s + } 203s + } # for (kk ...) 203s Random test #1 203s Random test #2 203s Coercing from double to integer 203s Coercing from integer to logical 203s Random test #3 203s Adding NAs 203s Random test #4 203s Adding NAs 203s Coercing from double to integer 203s Coercing from integer to logical 203s Random test #5 203s Random test #6 203s Coercing from double to integer 203s Coercing from integer to logical 203s Random test #7 203s Adding NAs 203s Random test #8 203s Adding NAs 203s Coercing from double to integer 203s Coercing from integer to logical 203s Random test #9 203s Random test #10 203s Coercing from double to integer 203s Coercing from integer to logical 203s Random test #11 203s Adding NAs 203s Random test #12 203s Adding NAs 203s Coercing from double to integer 203s Coercing from integer to logical 203s Random test #13 203s Random test #14 203s Coercing from double to integer 203s Coercing from integer to logical 203s Random test #15 203s Adding NAs 203s Random test #16 203s Adding NAs 203s Coercing from double to integer 203s Coercing from integer to logical 203s Random test #17 203s Random test #18 203s Coercing from double to integer 203s Coercing from integer to logical 203s Random test #19 203s Adding NAs 203s Random test #20 203s Adding NAs 203s Coercing from double to integer 203s Coercing from integer to logical 203s > 203s 203s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 203s Copyright (C) 2024 The R Foundation for Statistical Computing 203s Platform: x86_64-pc-linux-gnu 203s 203s R is free software and comes with ABSOLUTELY NO WARRANTY. 203s You are welcome to redistribute it under certain conditions. 203s Type 'license()' or 'licence()' for distribution details. 203s 203s R is a collaborative project with many contributors. 203s Type 'contributors()' for more information and 203s 'citation()' on how to cite R or R packages in publications. 203s 203s Type 'demo()' for some demos, 'help()' for on-line help, or 203s 'help.start()' for an HTML browser interface to help. 203s Type 'q()' to quit R. 203s 203s > library("matrixStats") 203s > 203s > rowMeans_R <- function(x, na.rm = FALSE, ..., useNames = NA) { 203s + res <- rowMeans(x, na.rm = na.rm) 203s + if (is.na(useNames) || !useNames) names(res) <- NULL 203s + res 203s + } 203s > 203s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 203s > # Subsetted tests 203s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 203s > source("utils/validateIndicesFramework.R") 203s > x <- matrix(runif(6 * 6, min = -3, max = 3), nrow = 6, ncol = 6) 203s > storage.mode(x) <- "integer" 203s > 203s > # To check names attribute 203s > dimnames <- list(letters[1:6], LETTERS[1:6]) 203s > 203s > # Test with and without dimnames on x 203s > for (setDimnames in c(TRUE, FALSE)) { 203s + if (setDimnames) dimnames(x) <- dimnames 203s + else dimnames(x) <- NULL 203s + 203s + count <- 0L 203s + for (rows in index_cases) { 203s + for (cols in index_cases) { 203s + count <- count + 1L 203s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 203s + useNames <- c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE) 203s + useNames <- useNames[count %% length(useNames) + 1] 203s + 203s + validateIndicesTestMatrix(x, rows, cols, 203s + ftest = rowMeans2, fsure = rowMeans_R, 203s + na.rm = na.rm, useNames = useNames) 203s + validateIndicesTestMatrix(x, rows, cols, 203s + fcoltest = colMeans2, fsure = rowMeans_R, 203s + na.rm = na.rm, useNames = useNames) 203s + } 203s + } 203s + } 203s > 203s 203s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 203s Copyright (C) 2024 The R Foundation for Statistical Computing 203s Platform: x86_64-pc-linux-gnu 203s 203s R is free software and comes with ABSOLUTELY NO WARRANTY. 203s You are welcome to redistribute it under certain conditions. 203s Type 'license()' or 'licence()' for distribution details. 203s 203s R is a collaborative project with many contributors. 203s Type 'contributors()' for more information and 203s 'citation()' on how to cite R or R packages in publications. 203s 203s Type 'demo()' for some demos, 'help()' for on-line help, or 203s 'help.start()' for an HTML browser interface to help. 203s Type 'q()' to quit R. 203s 204s > library("matrixStats") 204s > 204s > rowMedians_R <- function(x, na.rm = FALSE, ..., useNames = NA) { 204s + res <- apply(x, MARGIN = 1L, FUN = median, na.rm = na.rm) 204s + if (is.na(useNames) || !useNames) names(res) <- NULL 204s + res 204s + } 204s > 204s > colMedians_R <- function(x, na.rm = FALSE, ..., useNames = NA) { 204s + res <- apply(x, MARGIN = 2L, FUN = median, na.rm = na.rm) 204s + if (is.na(useNames) || !useNames) names(res) <- NULL 204s + res 204s + } 204s > 204s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 204s > # Special case: Non-ties 204s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 204s > cat("Special case: Non-ties:\n") 204s Special case: Non-ties: 204s > for (mode in c("integer", "double")) { 204s + x <- matrix(1:9 + 0.1, nrow = 3, ncol = 3) 204s + storage.mode(x) <- mode 204s + 204s + # To check names attribute 204s + dimnames <- list(letters[1:3], LETTERS[1:3]) 204s + 204s + # Test with and without dimnames on x 204s + for (setDimnames in c(TRUE, FALSE)) { 204s + if (setDimnames) dimnames(x) <- dimnames 204s + else dimnames(x) <- NULL 204s + # Check names attribute 204s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 204s + y0 <- rowMedians_R(x, na.rm = FALSE, useNames = useNames) 204s + y1 <- rowMedians(x, na.rm = FALSE, useNames = useNames) 204s + stopifnot(all.equal(y1, y0)) 204s + 204s + y0 <- colMedians_R(x, na.rm = FALSE, useNames = useNames) 204s + y1 <- colMedians(x, na.rm = FALSE, useNames = useNames) 204s + stopifnot(all.equal(y1, y0)) 204s + } 204s + } 204s + } 204s > 204s > 204s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 204s > # Special case: Ties 204s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 204s > cat("Special case: Ties:\n") 204s Special case: Ties: 204s > for (mode in c("integer", "double")) { 204s + x <- matrix(1:16 + 0.1, nrow = 4, ncol = 4) 204s + storage.mode(x) <- mode 204s + 204s + # To check names attribute 204s + dimnames <- list(letters[1:4], LETTERS[1:4]) 204s + 204s + # Test with and without dimnames on x 204s + for (setDimnames in c(TRUE, FALSE)) { 204s + if (setDimnames) dimnames(x) <- dimnames 204s + else dimnames(x) <- NULL 204s + # Check names attribute 204s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 204s + y0 <- rowMedians_R(x, na.rm = FALSE, useNames = useNames) 204s + y1 <- rowMedians(x, na.rm = FALSE, useNames = useNames) 204s + stopifnot(all.equal(y1, y0)) 204s + 204s + y0 <- colMedians_R(x, na.rm = FALSE, useNames = useNames) 204s + y1 <- colMedians(x, na.rm = FALSE, useNames = useNames) 204s + stopifnot(all.equal(y1, y0)) 204s + } 204s + } 204s + } 204s > 204s > 204s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 204s > # Special case: Single-element matrix 204s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 204s > cat("Special case: Single-element matrix:\n") 204s Special case: Single-element matrix: 204s > for (mode in c("integer", "double")) { 204s + x <- matrix(1, nrow = 1, ncol = 1) 204s + storage.mode(x) <- mode 204s + 204s + # To check names attribute 204s + dimnames <- list("a", "A") 204s + 204s + # Test with and without dimnames on x 204s + for (setDimnames in c(TRUE, FALSE)) { 204s + if (setDimnames) dimnames(x) <- dimnames 204s + else dimnames(x) <- NULL 204s + # Check names attribute 204s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 204s + y0 <- rowMedians_R(x, na.rm = FALSE, useNames = useNames) 204s + y1 <- rowMedians(x, na.rm = FALSE, useNames = useNames) 204s + stopifnot(all.equal(y1, y0)) 204s + 204s + y0 <- colMedians_R(x, na.rm = FALSE, useNames = useNames) 204s + y1 <- colMedians(x, na.rm = FALSE, useNames = useNames) 204s + stopifnot(all.equal(y1, y0)) 204s + } 204s + } 204s + } 204s > 204s > 204s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 204s > # Special case: Empty matrix 204s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 204s > cat("Special case: Empty matrix:\n") 204s Special case: Empty matrix: 204s > for (mode in c("integer", "double")) { 204s + x <- matrix(integer(0), nrow = 0, ncol = 0) 204s + storage.mode(x) <- mode 204s + 204s + y0 <- rowMedians_R(x, na.rm = FALSE) 204s + y1 <- rowMedians(x, na.rm = FALSE) 204s + stopifnot(all.equal(y1, y0)) 204s + 204s + y0 <- colMedians_R(x, na.rm = FALSE) 204s + y1 <- colMedians(x, na.rm = FALSE) 204s + stopifnot(all.equal(y1, y0)) 204s + } 204s > 204s > 204s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 204s > # Special case: All NAs 204s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 204s > cat("Special case: All NAs:\n") 204s Special case: All NAs: 204s > for (mode in c("integer", "double")) { 204s + x <- matrix(NA_integer_, nrow = 3, ncol = 3) 204s + storage.mode(x) <- mode 204s + 204s + # To check names attribute 204s + dimnames <- list(letters[1:3], LETTERS[1:3]) 204s + 204s + # Test with and without dimnames on x 204s + for (setDimnames in c(TRUE, FALSE)) { 204s + if (setDimnames) dimnames(x) <- dimnames 204s + else dimnames(x) <- NULL 204s + # Check names attribute 204s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 204s + y0 <- rowMedians_R(x, na.rm = TRUE, useNames = useNames) 204s + y1 <- rowMedians(x, na.rm = TRUE, useNames = useNames) 204s + stopifnot(all.equal(y1, y0)) 204s + 204s + y0 <- colMedians_R(x, na.rm = TRUE, useNames = useNames) 204s + y1 <- colMedians(x, na.rm = TRUE, useNames = useNames) 204s + stopifnot(all.equal(y1, y0)) 204s + } 204s + } 204s + } 204s > 204s > 204s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 204s > # Special case: All NaNs 204s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 204s > cat("Special case: All NaNs:\n") 204s Special case: All NaNs: 204s > x <- matrix(NA_real_, nrow = 3, ncol = 3) 204s > 204s > # Test with and without dimnames on x 204s > for (setDimnames in c(TRUE, FALSE)) { 204s + if (setDimnames) dimnames(x) <- dimnames 204s + else dimnames(x) <- NULL 204s + # Check names attribute 204s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 204s + y0 <- rowMedians_R(x, na.rm = TRUE, useNames = useNames) 204s + y1 <- rowMedians(x, na.rm = TRUE, useNames = useNames) 204s + stopifnot(all.equal(y1, y0)) 204s + 204s + y0 <- colMedians_R(x, na.rm = TRUE, useNames = useNames) 204s + y1 <- colMedians(x, na.rm = TRUE, useNames = useNames) 204s + stopifnot(all.equal(y1, y0)) 204s + } 204s + } 204s > 204s > 204s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 204s > # Special case: All Infs 204s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 204s > cat("Special case: All Infs:\n") 204s Special case: All Infs: 204s > x <- matrix(Inf, nrow = 3, ncol = 3) 204s > 204s > # Test with and without dimnames on x 204s > for (setDimnames in c(TRUE, FALSE)) { 204s + if (setDimnames) dimnames(x) <- dimnames 204s + else dimnames(x) <- NULL 204s + # Check names attribute 204s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 204s + y0 <- rowMedians_R(x, na.rm = FALSE, useNames = useNames) 204s + y1 <- rowMedians(x, na.rm = FALSE, useNames = useNames) 204s + stopifnot(all.equal(y1, y0)) 204s + 204s + y0 <- colMedians_R(x, na.rm = FALSE, useNames = useNames) 204s + y1 <- colMedians(x, na.rm = FALSE, useNames = useNames) 204s + stopifnot(all.equal(y1, y0)) 204s + } 204s + } 204s > 204s > 204s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 204s > # Special case: All -Infs 204s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 204s > cat("Special case: All -Infs:\n") 204s Special case: All -Infs: 204s > x <- matrix(-Inf, nrow = 3, ncol = 3) 204s > 204s > # Test with and without dimnames on x 204s > for (setDimnames in c(TRUE, FALSE)) { 204s + if (setDimnames) dimnames(x) <- dimnames 204s + else dimnames(x) <- NULL 204s + # Check names attribute 204s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 204s + y0 <- rowMedians_R(x, na.rm = FALSE, useNames = useNames) 204s + y1 <- rowMedians(x, na.rm = FALSE, useNames = useNames) 204s + stopifnot(all.equal(y1, y0)) 204s + 204s + y0 <- colMedians_R(x, na.rm = FALSE, useNames = useNames) 204s + y1 <- colMedians(x, na.rm = FALSE, useNames = useNames) 204s + stopifnot(all.equal(y1, y0)) 204s + } 204s + } 204s > 204s > 204s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 204s > # Special case: Infs and -Infs 204s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 204s > cat("Special case: Infs and -Infs:\n") 204s Special case: Infs and -Infs: 204s > x <- matrix(c(-Inf, +Inf), nrow = 4, ncol = 4) 204s > 204s > # To check names attribute 204s > dimnames <- list(letters[1:4], LETTERS[1:4]) 204s > 204s > # Test with and without dimnames on x 204s > for (setDimnames in c(TRUE, FALSE)) { 204s + if (setDimnames) dimnames(x) <- dimnames 204s + else dimnames(x) <- NULL 204s + # Check names attribute 204s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 204s + y0 <- rowMedians_R(x, na.rm = FALSE, useNames = useNames) 204s + y1 <- rowMedians(x, na.rm = FALSE, useNames = useNames) 204s + stopifnot(all.equal(y1, y0)) 204s + 204s + y0 <- colMedians_R(x, na.rm = FALSE, useNames = useNames) 204s + y1 <- colMedians(x, na.rm = FALSE, useNames = useNames) 204s + stopifnot(all.equal(y1, y0)) 204s + } 204s + } 204s > 204s > 204s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 204s > # Special case: Integer overflow with ties 204s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 204s > cat("Special case: Integer overflow with ties:\n") 204s Special case: Integer overflow with ties: 204s > x <- matrix(.Machine$integer.max, nrow = 4, ncol = 4) 204s > 204s > # Test with and without dimnames on x 204s > for (setDimnames in c(TRUE, FALSE)) { 204s + if (setDimnames) dimnames(x) <- dimnames 204s + else dimnames(x) <- NULL 204s + # Check names attribute 204s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 204s + y0 <- rowMedians_R(x, na.rm = FALSE, useNames = useNames) 204s + y1 <- rowMedians(x, na.rm = FALSE, useNames = useNames) 204s + stopifnot(all.equal(y1, y0)) 204s + 204s + y0 <- colMedians_R(x, na.rm = FALSE, useNames = useNames) 204s + y1 <- colMedians(x, na.rm = FALSE, useNames = useNames) 204s + stopifnot(all.equal(y1, y0)) 204s + } 204s + } 204s > 204s > 204s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 204s > # Consistency checks 204s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 204s > set.seed(1) 204s > 204s > cat("Consistency checks:\n") 204s Consistency checks: 204s > n_sims <- if (Sys.getenv("_R_CHECK_USE_VALGRIND_") != "") 4L else 20L 204s > for (kk in seq_len(n_sims)) { 204s + cat("Random test #", kk, "\n", sep = "") 204s + 204s + # Simulate data in a matrix of any shape 204s + dim <- sample(50:200, size = 2) 204s + n <- prod(dim) 204s + x <- rnorm(n, sd = 100) 204s + dim(x) <- dim 204s + 204s + # Add NAs? 204s + if ((kk %% 4) %in% c(3, 0)) { 204s + cat("Adding NAs\n") 204s + nna <- sample(n, size = 1) 204s + na_values <- c(NA_real_, NaN) 204s + t <- sample(na_values, size = nna, replace = TRUE) 204s + x[sample(length(x), size = nna)] <- t 204s + } 204s + 204s + # Integer or double? 204s + if ((kk %% 4) %in% c(2, 0)) { 204s + cat("Coercing to integers\n") 204s + storage.mode(x) <- "integer" 204s + } 204s + 204s + na.rm <- sample(c(TRUE, FALSE), size = 1) 204s + 204s + # rowMedians(): 204s + y0 <- rowMedians_R(x, na.rm = na.rm) 204s + y1 <- rowMedians(x, na.rm = na.rm) 204s + stopifnot(all.equal(y1, y0)) 204s + y2 <- colMedians(t(x), na.rm = na.rm) 204s + stopifnot(all.equal(y2, y0)) 204s + 204s + # colMedians(): 204s + y0 <- colMedians_R(x, na.rm = na.rm) 204s + y1 <- colMedians(x, na.rm = na.rm) 204s + stopifnot(all.equal(y1, y0)) 204s + y2 <- rowMedians(t(x), na.rm = na.rm) 204s + stopifnot(all.equal(y2, y0)) 204s + } # for (kk ...) 204s Random test #1 204s Random test #2 204s Coercing to integers 204s Random test #3 204s Adding NAs 204s Random test #4 204s Adding NAs 204s Coercing to integers 204s Random test #5 204s Random test #6 204s Coercing to integers 204s Random test #7 204s Adding NAs 204s Random test #8 204s Adding NAs 204s Coercing to integers 204s Random test #9 204s Random test #10 204s Coercing to integers 204s Random test #11 204s Adding NAs 204s Random test #12 204s Adding NAs 204s Coercing to integers 204s Random test #13 204s Random test #14 204s Coercing to integers 204s Random test #15 204s Adding NAs 204s Random test #16 204s Adding NAs 204s Coercing to integers 204s Random test #17 204s Random test #18 204s Coercing to integers 204s Random test #19 204s Adding NAs 204s Random test #20 204s Adding NAs 204s Coercing to integers 204s > 204s 204s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 204s Copyright (C) 2024 The R Foundation for Statistical Computing 204s Platform: x86_64-pc-linux-gnu 204s 204s R is free software and comes with ABSOLUTELY NO WARRANTY. 204s You are welcome to redistribute it under certain conditions. 204s Type 'license()' or 'licence()' for distribution details. 204s 204s R is a collaborative project with many contributors. 204s Type 'contributors()' for more information and 204s 'citation()' on how to cite R or R packages in publications. 204s 204s Type 'demo()' for some demos, 'help()' for on-line help, or 204s 'help.start()' for an HTML browser interface to help. 204s Type 'q()' to quit R. 204s 204s > library("matrixStats") 204s > 204s > rowMedians_R <- function(x, na.rm = FALSE, ..., useNames = NA) { 204s + res <- apply(x, MARGIN = 1L, FUN = median, na.rm = na.rm) 204s + if (is.na(useNames) || !useNames) names(res) <- NULL 204s + res 204s + } 204s > 204s > colMedians_R <- function(x, na.rm = FALSE, ..., useNames = NA) { 204s + res <- apply(x, MARGIN = 2L, FUN = median, na.rm = na.rm) 204s + if (is.na(useNames) || !useNames) names(res) <- NULL 204s + res 204s + } 204s > 204s > 204s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 204s > # Subsetted tests 204s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 204s > source("utils/validateIndicesFramework.R") 204s > x <- matrix(runif(6 * 6, min = -3, max = 3), nrow = 6, ncol = 6) 204s > storage.mode(x) <- "integer" 204s > 204s > # To check names attribute 204s > dimnames <- list(letters[1:6], LETTERS[1:6]) 204s > 204s > # Test with and without dimnames on x 204s > for (setDimnames in c(TRUE, FALSE)) { 204s + if (setDimnames) dimnames(x) <- dimnames 204s + else dimnames(x) <- NULL 204s + 204s + count <- 0L 204s + for (rows in index_cases) { 204s + for (cols in index_cases) { 204s + count <- count + 1L 204s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 204s + useNames <- c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE) 204s + useNames <- useNames[count %% length(useNames) + 1] 204s + 204s + validateIndicesTestMatrix(x, rows, cols, 204s + ftest = rowMedians, fsure = rowMedians_R, 204s + na.rm = na.rm, useNames = useNames) 204s + validateIndicesTestMatrix(x, rows, cols, 204s + fcoltest = colMedians, fsure = rowMedians_R, 204s + na.rm = na.rm, useNames = useNames) 204s + } 204s + } 204s + } 204s > 204s 204s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 204s Copyright (C) 2024 The R Foundation for Statistical Computing 204s Platform: x86_64-pc-linux-gnu 204s 204s R is free software and comes with ABSOLUTELY NO WARRANTY. 204s You are welcome to redistribute it under certain conditions. 204s Type 'license()' or 'licence()' for distribution details. 204s 204s R is a collaborative project with many contributors. 204s Type 'contributors()' for more information and 204s 'citation()' on how to cite R or R packages in publications. 204s 204s Type 'demo()' for some demos, 'help()' for on-line help, or 204s 'help.start()' for an HTML browser interface to help. 204s Type 'q()' to quit R. 204s 205s > library("matrixStats") 205s > library("stats") 205s > 205s > asWhich <- function(probs, max) { 205s + idx <- as.integer(round(probs * max)) 205s + if (idx < 1L) { 205s + idx <- 1L 205s + } else if (idx > max) { 205s + idx <- max 205s + } 205s + idx 205s + } # asWhich() 205s > 205s > rowOrderStats_R <- function(x, probs, ..., useNames = NA) { 205s + ans <- apply(x, MARGIN = 1L, FUN = quantile, probs = probs, type = 3L) 205s + 205s + # Remove Attributes 205s + if (is.na(useNames) || !useNames || length(ans) == 0L) attributes(ans) <- NULL 205s + ans 205s + } # rowOrderStats_R() 205s > 205s > 205s > set.seed(1) 205s > 205s > 205s > # Simulate data in a matrix of any shape 205s > nrow <- 60L 205s > ncol <- 30L 205s > x <- rnorm(nrow * ncol) 205s > dim(x) <- c(nrow, ncol) 205s > probs <- 0.3 205s > which <- asWhich(probs, max = ncol) 205s > 205s > y0 <- rowOrderStats_R(x, probs = probs) 205s > y1 <- rowOrderStats(x, which = which) 205s > stopifnot(all.equal(y1, y0)) 205s > y2 <- colOrderStats(t(x), which = which) 205s > stopifnot(all.equal(y2, y0)) 205s > 205s > 205s > 205s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 205s > # Consistency checks 205s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 205s > for (mode in c("integer", "double")) { 205s + cat("Consistency checks without NAs:\n") 205s + for (kk in 1:3) { 205s + cat("Random test #", kk, "\n", sep = "") 205s + 205s + # Simulate data in a matrix of any shape 205s + nrow <- sample(20L, size = 1L) 205s + ncol <- sample(20L, size = 1L) 205s + x <- rnorm(nrow * ncol) 205s + dim(x) <- c(nrow, ncol) 205s + 205s + cat("mode: ", mode, "\n", sep = "") 205s + storage.mode(x) <- mode 205s + str(x) 205s + 205s + probs <- runif(1) 205s + which <- asWhich(probs, max = ncol) 205s + 205s + y0 <- rowOrderStats_R(x, probs = probs) 205s + y1 <- rowOrderStats(x, which = which) 205s + stopifnot(all.equal(y1, y0)) 205s + y2 <- colOrderStats(t(x), which = which) 205s + stopifnot(all.equal(y2, y0)) 205s + } # for (kk in ...) 205s + } # for (mode ...) 205s Consistency checks without NAs: 205s Random test #1 205s mode: integer 205s int [1:14, 1:6] 0 0 1 0 2 -1 1 0 0 0 ... 205s Random test #2 205s mode: integer 205s int [1:8, 1:13] 0 0 1 -2 0 0 0 0 1 0 ... 205s Random test #3 205s mode: integer 205s int [1:20, 1:17] 0 0 0 0 1 0 1 0 0 -1 ... 205s Consistency checks without NAs: 205s Random test #1 205s mode: double 205s num [1:9, 1:5] -1.4286 -0.00386 -0.70456 -0.29242 -0.49607 ... 205s Random test #2 205s mode: double 205s num [1:11, 1:20] -0.796 0.482 -0.952 0.5 1.242 ... 205s Random test #3 205s mode: double 205s num [1:7, 1:18] 1.553 -2.405 0.167 -0.403 -1.746 ... 205s > 205s > 205s > # Check names attribute 205s > x <- matrix(1:9 + 0.1, nrow = 3L, ncol = 3L) 205s > 205s > probs <- runif(1) 205s > which <- asWhich(probs, max = ncol(x)) 205s > 205s > dimnames <- list(letters[1:3], LETTERS[1:3]) 205s > 205s > # Test with and without dimnames on x 205s > for (setDimnames in c(TRUE, FALSE)) { 205s + if (setDimnames) dimnames(x) <- dimnames 205s + else dimnames(x) <- NULL 205s + # Check names attribute 205s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 205s + y0 <- rowOrderStats_R(x, probs = probs, useNames = useNames) 205s + y1 <- rowOrderStats(x, which = which, useNames = useNames) 205s + stopifnot(all.equal(y1, y0)) 205s + y2 <- colOrderStats(t(x), which = which, useNames = useNames) 205s + stopifnot(all.equal(y2, y0)) 205s + } 205s + } 205s > 205s 205s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 205s Copyright (C) 2024 The R Foundation for Statistical Computing 205s Platform: x86_64-pc-linux-gnu 205s 205s R is free software and comes with ABSOLUTELY NO WARRANTY. 205s You are welcome to redistribute it under certain conditions. 205s Type 'license()' or 'licence()' for distribution details. 205s 205s R is a collaborative project with many contributors. 205s Type 'contributors()' for more information and 205s 'citation()' on how to cite R or R packages in publications. 205s 205s Type 'demo()' for some demos, 'help()' for on-line help, or 205s 'help.start()' for an HTML browser interface to help. 205s Type 'q()' to quit R. 205s 205s > library("matrixStats") 205s > 205s > rowOrderStats_R <- function(x, probs, ..., useNames = NA) { 205s + ans <- apply(x, MARGIN = 1L, FUN = quantile, probs = probs, type = 3L) 205s + 205s + # Remove Attributes 205s + if (is.na(useNames) || !useNames || length(ans) == 0L) attributes(ans) <- NULL 205s + ans 205s + } # rowOrderStats_R() 205s > 205s > 205s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 205s > # Subsetted tests 205s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 205s > source("utils/validateIndicesFramework.R") 205s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 205s > storage.mode(x) <- "integer" 205s > 205s > # To check names attribute 205s > dimnames <- list(letters[1:6], LETTERS[1:6]) 205s > 205s > probs <- 0.3 205s > # Test with and without dimnames on x 205s > for (setDimnames in c(TRUE, FALSE)) { 205s + if (setDimnames) dimnames(x) <- dimnames 205s + else dimnames(x) <- NULL 205s + for (rows in index_cases) { 205s + for (cols in index_cases) { 205s + # Check names attribute 205s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 205s + if (is.null(cols)) which <- round(probs * ncol(x)) 205s + else { 205s + xxrows <- rows 205s + suppressWarnings({ 205s + xx <- tryCatch(x[, cols, drop = FALSE], error = function(c) "error") 205s + if (identical(xx, "error")) which <- 0L 205s + else which <- round(probs * ncol(xx)) 205s + }) 205s + } 205s + if (which == 0L) next 205s + 205s + validateIndicesTestMatrix(x, rows, cols, 205s + ftest = rowOrderStats, fsure = rowOrderStats_R, 205s + which = which, probs = probs, useNames = useNames) 205s + validateIndicesTestMatrix(x, rows, cols, 205s + fcoltest = colOrderStats, fsure = rowOrderStats_R, 205s + which = which, probs = probs, useNames = useNames) 205s + } 205s + } 205s + } 205s + } 206s > 206s 206s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 206s Copyright (C) 2024 The R Foundation for Statistical Computing 206s Platform: x86_64-pc-linux-gnu 206s 206s R is free software and comes with ABSOLUTELY NO WARRANTY. 206s You are welcome to redistribute it under certain conditions. 206s Type 'license()' or 'licence()' for distribution details. 206s 206s R is a collaborative project with many contributors. 206s Type 'contributors()' for more information and 206s 'citation()' on how to cite R or R packages in publications. 206s 206s Type 'demo()' for some demos, 'help()' for on-line help, or 206s 'help.start()' for an HTML browser interface to help. 206s Type 'q()' to quit R. 206s 206s > library("matrixStats") 206s > 206s > rowProds_R <- function(x, FUN = prod, na.rm = FALSE, ..., useNames = NA) { 206s + res <- apply(x, MARGIN = 1L, FUN = FUN, na.rm = na.rm) 206s + if (is.na(useNames) || !useNames) names(res) <- NULL 206s + res 206s + } 206s > 206s > all.equal.na <- function(target, current, ...) { 206s + # Computations involving NaN may return NaN or NA, cf. ?is.nan 206s + current[is.nan(current)] <- NA_real_ 206s + target[is.nan(target)] <- NA_real_ 206s + all.equal(target, current, ...) 206s + } 206s > 206s > for (mode in c("integer", "double")) { 206s + # Missing values 206s + x <- matrix(c(1, NA, NaN, 1, 1, 0, 1, 0), nrow = 4, ncol = 2) 206s + cat("mode: ", mode, "\n", sep = "") 206s + storage.mode(x) <- mode 206s + str(x) 206s + 206s + # To check names attribute 206s + dimnames <- list(letters[1:4], LETTERS[1:2]) 206s + 206s + # Test with and without dimnames on x 206s + for (setDimnames in c(TRUE, FALSE)) { 206s + if (setDimnames) dimnames(x) <- dimnames 206s + else dimnames(x) <- NULL 206s + # Check names attribute 206s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 206s + y0 <- rowProds_R(x, na.rm = TRUE, useNames = useNames) 206s + print(y0) 206s + y1 <- rowProds(x, na.rm = TRUE, useNames = useNames) 206s + print(y1) 206s + y2 <- colProds(t(x), na.rm = TRUE, useNames = useNames) 206s + print(y2) 206s + stopifnot(all.equal(y1, y0)) 206s + stopifnot(all.equal(y2, y1)) 206s + 206s + # Missing values 206s + y0 <- rowProds_R(x, na.rm = FALSE, useNames = useNames) 206s + print(y0) 206s + y1 <- rowProds(x, na.rm = FALSE, useNames = useNames) 206s + print(y1) 206s + y2 <- colProds(t(x), na.rm = FALSE, useNames = useNames) 206s + print(y2) 206s + stopifnot(all.equal(y1, y0)) 206s + stopifnot(all.equal(y2, y1)) 206s + 206s + # "Empty" rows 206s + y0 <- rowProds_R(x[integer(0), , drop = FALSE], na.rm = FALSE, useNames = useNames) 206s + print(y0) 206s + y1 <- rowProds(x[integer(0), , drop = FALSE], na.rm = FALSE, useNames = useNames) 206s + print(y1) 206s + y2 <- colProds(t(x[integer(0), , drop = FALSE]), na.rm = FALSE, useNames = useNames) 206s + print(y2) 206s + stopifnot(all.equal.na(y1, y0)) 206s + stopifnot(all.equal(y2, y1)) 206s + stopifnot(length(y1) == 0L) 206s + 206s + # Using product() 206s + y1 <- rowProds(x, method = "expSumLog", na.rm = FALSE, useNames = useNames) 206s + print(y1) 206s + y2 <- colProds(t(x), method = "expSumLog", na.rm = FALSE, useNames = useNames) 206s + print(y2) 206s + stopifnot(all.equal(y2, y1)) 206s + } 206s + } 206s + } # for (mode ...) 206s mode: integer 206s int [1:4, 1:2] 1 NA NA 1 1 0 1 0 206s a b c d 206s 1 0 1 0 206s a b c d 206s 1 0 1 0 206s a b c d 206s 1 0 1 0 206s a b c d 206s 1 NA NA 0 206s a b c d 206s 1 NA NA 0 206s a b c d 206s 1 NA NA 0 206s numeric(0) 206s numeric(0) 206s numeric(0) 206s a b c d 206s 1 NA NA 0 206s a b c d 206s 1 NA NA 0 206s [1] 1 0 1 0 206s [1] 1 0 1 0 206s [1] 1 0 1 0 206s [1] 1 NA NA 0 206s [1] 1 NA NA 0 206s [1] 1 NA NA 0 206s numeric(0) 206s numeric(0) 206s numeric(0) 206s [1] 1 NA NA 0 206s [1] 1 NA NA 0 206s [1] 1 0 1 0 206s [1] 1 0 1 0 206s [1] 1 0 1 0 206s [1] 1 NA NA 0 206s [1] 1 NA NA 0 206s [1] 1 NA NA 0 206s numeric(0) 206s numeric(0) 206s numeric(0) 206s [1] 1 NA NA 0 206s [1] 1 NA NA 0 206s [1] 1 0 1 0 206s [1] 1 0 1 0 206s [1] 1 0 1 0 206s [1] 1 NA NA 0 206s [1] 1 NA NA 0 206s [1] 1 NA NA 0 206s numeric(0) 206s numeric(0) 206s numeric(0) 206s [1] 1 NA NA 0 206s [1] 1 NA NA 0 206s mode: double 206s num [1:4, 1:2] 1 NA NaN 1 1 0 1 0 206s a b c d 206s 1 0 1 0 206s a b c d 206s 1 0 1 0 206s a b c d 206s 1 0 1 0 206s a b c d 206s 1 NA NaN 0 206s a b c d 206s 1 NA NaN 0 206s a b c d 206s 1 NA NaN 0 206s numeric(0) 206s numeric(0) 206s numeric(0) 206s a b c d 206s 1 NA NA 0 206s a b c d 206s 1 NA NA 0 206s [1] 1 0 1 0 206s [1] 1 0 1 0 206s [1] 1 0 1 0 206s [1] 1 NA NaN 0 206s [1] 1 NA NaN 0 206s [1] 1 NA NaN 0 206s numeric(0) 206s numeric(0) 206s numeric(0) 206s [1] 1 NA NA 0 206s [1] 1 NA NA 0 206s [1] 1 0 1 0 206s [1] 1 0 1 0 206s [1] 1 0 1 0 206s [1] 1 NA NaN 0 206s [1] 1 NA NaN 0 206s [1] 1 NA NaN 0 206s numeric(0) 206s numeric(0) 206s numeric(0) 206s [1] 1 NA NA 0 206s [1] 1 NA NA 0 206s [1] 1 0 1 0 206s [1] 1 0 1 0 206s [1] 1 0 1 0 206s [1] 1 NA NaN 0 206s [1] 1 NA NaN 0 206s [1] 1 NA NaN 0 206s numeric(0) 206s numeric(0) 206s numeric(0) 206s [1] 1 NA NA 0 206s [1] 1 NA NA 0 206s > 206s > 206s > # Bug report 2012-06-25 206s > x <- matrix(c(1, 1, 1, 1, 1, 0, 1, 0), nrow = 4, ncol = 2) 206s > y0 <- rowProds_R(x) 206s > print(y0) 206s [1] 1 0 1 0 206s > y1 <- rowProds(x) 206s > print(y1) 206s [1] 1 0 1 0 206s > y2 <- colProds(t(x)) 206s > print(y2) 206s [1] 1 0 1 0 206s > stopifnot(all.equal.na(y1, y0)) 206s > stopifnot(all.equal.na(y1, x[, 1] * x[, 2])) 206s > stopifnot(all.equal.na(y2, y1)) 206s > # Check names attribute 206s > dimnames(x) <- dimnames 206s > y0 <- rowProds_R(x, useNames = TRUE) 206s > print(y0) 206s a b c d 206s 1 0 1 0 206s > y1 <- rowProds(x, useNames = TRUE) 206s > print(y1) 206s a b c d 206s 1 0 1 0 206s > y2 <- colProds(t(x), useNames = TRUE) 206s > print(y2) 206s a b c d 206s 1 0 1 0 206s > stopifnot(all.equal.na(y1, y0)) 206s > stopifnot(all.equal.na(y1, x[, 1] * x[, 2])) 206s > stopifnot(all.equal.na(y2, y1)) 206s > 206s > # Bug report 2014-03-25 ("all rows contains a zero") 206s > x <- matrix(c(0, 1, 1, 0), nrow = 2, ncol = 2) 206s > # To check names attribute 206s > dimnames <- list(letters[1:2], LETTERS[1:2]) 206s > y0 <- rowProds_R(x) 206s > print(y0) 206s [1] 0 0 206s > y1 <- rowProds(x) 206s > print(y1) 206s [1] 0 0 206s > y2 <- colProds(t(x)) 206s > print(y2) 206s [1] 0 0 206s > stopifnot(all.equal.na(y1, y0)) 206s > stopifnot(all.equal.na(y1, c(0, 0))) 206s > stopifnot(all.equal.na(y2, y1)) 206s > # Check names attribute 206s > dimnames(x) <- dimnames 206s > y0 <- rowProds_R(x, useNames = TRUE) 206s > print(y0) 206s a b 206s 0 0 206s > y1 <- rowProds(x, useNames = TRUE) 206s > print(y1) 206s a b 206s 0 0 206s > y2 <- colProds(t(x), useNames = TRUE) 206s > print(y2) 206s a b 206s 0 0 206s > stopifnot(all.equal.na(y1, y0)) 206s > stopifnot(all.equal.na(y2, y1)) 206s > 206s 206s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 206s Copyright (C) 2024 The R Foundation for Statistical Computing 206s Platform: x86_64-pc-linux-gnu 206s 206s R is free software and comes with ABSOLUTELY NO WARRANTY. 206s You are welcome to redistribute it under certain conditions. 206s Type 'license()' or 'licence()' for distribution details. 206s 206s R is a collaborative project with many contributors. 206s Type 'contributors()' for more information and 206s 'citation()' on how to cite R or R packages in publications. 206s 206s Type 'demo()' for some demos, 'help()' for on-line help, or 206s 'help.start()' for an HTML browser interface to help. 206s Type 'q()' to quit R. 206s 206s > library("matrixStats") 206s > 206s > rowProds_R <- function(x, FUN = prod, na.rm = FALSE, ..., useNames = NA) { 206s + res <- apply(x, MARGIN = 1L, FUN = FUN, na.rm = na.rm) 206s + if (is.na(useNames) || !useNames) names(res) <- NULL 206s + res 206s + } 206s > 206s > 206s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 206s > # Subsetted tests 206s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 206s > source("utils/validateIndicesFramework.R") 206s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 206s > storage.mode(x) <- "integer" 206s > 206s > # To check names attribute 206s > dimnames <- list(letters[1:6], LETTERS[1:6]) 206s > 206s > # Test with and without dimnames on x 206s > for (setDimnames in c(TRUE, FALSE)) { 206s + if (setDimnames) dimnames(x) <- dimnames 206s + else dimnames(x) <- NULL 206s + for (rows in index_cases) { 206s + for (cols in index_cases) { 206s + for (na.rm in c(TRUE, FALSE)) { 206s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 206s + validateIndicesTestMatrix(x, rows, cols, 206s + ftest = rowProds, fsure = rowProds_R, 206s + method = "expSumLog", 206s + FUN = product, na.rm = na.rm, useNames = useNames) 206s + validateIndicesTestMatrix(x, rows, cols, 206s + fcoltest = colProds, fsure = rowProds_R, 206s + method = "expSumLog", 206s + FUN = product, na.rm = na.rm, useNames = useNames) 206s + } 206s + } 206s + } 206s + } 206s + } 207s > 207s 207s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 207s Copyright (C) 2024 The R Foundation for Statistical Computing 207s Platform: x86_64-pc-linux-gnu 207s 207s R is free software and comes with ABSOLUTELY NO WARRANTY. 207s You are welcome to redistribute it under certain conditions. 207s Type 'license()' or 'licence()' for distribution details. 207s 207s R is a collaborative project with many contributors. 207s Type 'contributors()' for more information and 207s 'citation()' on how to cite R or R packages in publications. 207s 207s Type 'demo()' for some demos, 'help()' for on-line help, or 207s 'help.start()' for an HTML browser interface to help. 207s Type 'q()' to quit R. 207s 207s > library("matrixStats") 207s > 207s > ## Create isFALSE() if running on an old version of R 207s > if (!exists("isFALSE", mode="function")) { 207s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 207s + } 207s > 207s > rowQuantiles_R <- function(x, probs = c(0, 0.25, 0.50, 0.75, 1), na.rm = FALSE, drop = TRUE, type = 7L, ..., useNames = NA) { 207s + q <- apply(x, MARGIN = 1L, FUN = function(x, probs, na.rm) { 207s + if (!na.rm && any(is.na(x))) { 207s + na_value <- NA_real_ 207s + if (type != 7L) storage.mode(na_value) <- storage.mode(x) 207s + rep(na_value, times = length(probs)) 207s + } else { 207s + as.vector(quantile(x, probs = probs, na.rm = na.rm, type = type, names = FALSE, ...)) 207s + } 207s + }, probs = probs, na.rm = na.rm) 207s + 207s + if (!is.null(dim(q))) q <- t(q) 207s + else dim(q) <- c(nrow(x), length(probs)) 207s + 207s + colnames(q) <- matrixStats:::quantile_probs_names(probs) 207s + rownames(q) <- rownames(x) 207s + if (isFALSE(useNames)) dimnames(q) <- NULL 207s + 207s + if (drop) q <- drop(q) 207s + q 207s + } 207s > 207s > 207s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 207s > # Test with multiple quantiles 207s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 207s > for (mode in c("logical", "integer", "double")) { 207s + cat("mode: ", mode, "\n", sep = "") 207s + x <- matrix(1:40 + 0.1, nrow = 8, ncol = 5) 207s + storage.mode(x) <- mode 207s + dimnames <- lapply(dim(x), FUN = function(n) letters[seq_len(n)]) 207s + str(x) 207s + 207s + probs <- c(0, 0.5, 1) 207s + # Test with and without dimnames on x 207s + for (setDimnames in c(TRUE, FALSE)) { 207s + if (setDimnames) dimnames(x) <- dimnames 207s + else dimnames(x) <- NULL 207s + # Check names attribute 207s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 207s + q0 <- rowQuantiles_R(x, probs = probs, useNames = useNames) 207s + print(q0) 207s + q1 <- rowQuantiles(x, probs = probs, useNames = useNames) 207s + print(q1) 207s + ## FIXME: Workaround for R (< 3.0.0) 207s + if (getRversion() < "3.0.0" && mode == "logical") storage.mode(q1) <- storage.mode(q0) 207s + stopifnot(all.equal(q1, q0)) 207s + q2 <- colQuantiles(t(x), probs = probs, useNames = useNames) 207s + ## FIXME: Workaround for R (< 3.0.0) 207s + if (getRversion() < "3.0.0" && mode == "logical") storage.mode(q2) <- storage.mode(q0) 207s + stopifnot(all.equal(q2, q0)) 207s + } 207s + } 207s + } # for (mode ...) 207s mode: logical 207s logi [1:8, 1:5] TRUE TRUE TRUE TRUE TRUE TRUE ... 207s 0% 50% 100% 207s a 1 1 1 207s b 1 1 1 207s c 1 1 1 207s d 1 1 1 207s e 1 1 1 207s f 1 1 1 207s g 1 1 1 207s h 1 1 1 207s 0% 50% 100% 207s a 1 1 1 207s b 1 1 1 207s c 1 1 1 207s d 1 1 1 207s e 1 1 1 207s f 1 1 1 207s g 1 1 1 207s h 1 1 1 207s [,1] [,2] [,3] 207s [1,] 1 1 1 207s [2,] 1 1 1 207s [3,] 1 1 1 207s [4,] 1 1 1 207s [5,] 1 1 1 207s [6,] 1 1 1 207s [7,] 1 1 1 207s [8,] 1 1 1 207s [,1] [,2] [,3] 207s [1,] 1 1 1 207s [2,] 1 1 1 207s [3,] 1 1 1 207s [4,] 1 1 1 207s [5,] 1 1 1 207s [6,] 1 1 1 207s [7,] 1 1 1 207s [8,] 1 1 1 207s 0% 50% 100% 207s [1,] 1 1 1 207s [2,] 1 1 1 207s [3,] 1 1 1 207s [4,] 1 1 1 207s [5,] 1 1 1 207s [6,] 1 1 1 207s [7,] 1 1 1 207s [8,] 1 1 1 207s 0% 50% 100% 207s [1,] 1 1 1 207s [2,] 1 1 1 207s [3,] 1 1 1 207s [4,] 1 1 1 207s [5,] 1 1 1 207s [6,] 1 1 1 207s [7,] 1 1 1 207s [8,] 1 1 1 207s [,1] [,2] [,3] 207s [1,] 1 1 1 207s [2,] 1 1 1 207s [3,] 1 1 1 207s [4,] 1 1 1 207s [5,] 1 1 1 207s [6,] 1 1 1 207s [7,] 1 1 1 207s [8,] 1 1 1 207s [,1] [,2] [,3] 207s [1,] 1 1 1 207s [2,] 1 1 1 207s [3,] 1 1 1 207s [4,] 1 1 1 207s [5,] 1 1 1 207s [6,] 1 1 1 207s [7,] 1 1 1 207s [8,] 1 1 1 207s mode: integer 207s int [1:8, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 207s 0% 50% 100% 207s a 1 17 33 207s b 2 18 34 207s c 3 19 35 207s d 4 20 36 207s e 5 21 37 207s f 6 22 38 207s g 7 23 39 207s h 8 24 40 207s 0% 50% 100% 207s a 1 17 33 207s b 2 18 34 207s c 3 19 35 207s d 4 20 36 207s e 5 21 37 207s f 6 22 38 207s g 7 23 39 207s h 8 24 40 207s [,1] [,2] [,3] 207s [1,] 1 17 33 207s [2,] 2 18 34 207s [3,] 3 19 35 207s [4,] 4 20 36 207s [5,] 5 21 37 207s [6,] 6 22 38 207s [7,] 7 23 39 207s [8,] 8 24 40 207s [,1] [,2] [,3] 207s [1,] 1 17 33 207s [2,] 2 18 34 207s [3,] 3 19 35 207s [4,] 4 20 36 207s [5,] 5 21 37 207s [6,] 6 22 38 207s [7,] 7 23 39 207s [8,] 8 24 40 207s 0% 50% 100% 207s [1,] 1 17 33 207s [2,] 2 18 34 207s [3,] 3 19 35 207s [4,] 4 20 36 207s [5,] 5 21 37 207s [6,] 6 22 38 207s [7,] 7 23 39 207s [8,] 8 24 40 207s 0% 50% 100% 207s [1,] 1 17 33 207s [2,] 2 18 34 207s [3,] 3 19 35 207s [4,] 4 20 36 207s [5,] 5 21 37 207s [6,] 6 22 38 207s [7,] 7 23 39 207s [8,] 8 24 40 207s [,1] [,2] [,3] 207s [1,] 1 17 33 207s [2,] 2 18 34 207s [3,] 3 19 35 207s [4,] 4 20 36 207s [5,] 5 21 37 207s [6,] 6 22 38 207s [7,] 7 23 39 207s [8,] 8 24 40 207s [,1] [,2] [,3] 207s [1,] 1 17 33 207s [2,] 2 18 34 207s [3,] 3 19 35 207s [4,] 4 20 36 207s [5,] 5 21 37 207s [6,] 6 22 38 207s [7,] 7 23 39 207s [8,] 8 24 40 207s mode: double 207s num [1:8, 1:5] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ... 207s 0% 50% 100% 207s a 1.1 17.1 33.1 207s b 2.1 18.1 34.1 207s c 3.1 19.1 35.1 207s d 4.1 20.1 36.1 207s e 5.1 21.1 37.1 207s f 6.1 22.1 38.1 207s g 7.1 23.1 39.1 207s h 8.1 24.1 40.1 207s 0% 50% 100% 207s a 1.1 17.1 33.1 207s b 2.1 18.1 34.1 207s c 3.1 19.1 35.1 207s d 4.1 20.1 36.1 207s e 5.1 21.1 37.1 207s f 6.1 22.1 38.1 207s g 7.1 23.1 39.1 207s h 8.1 24.1 40.1 207s [,1] [,2] [,3] 207s [1,] 1.1 17.1 33.1 207s [2,] 2.1 18.1 34.1 207s [3,] 3.1 19.1 35.1 207s [4,] 4.1 20.1 36.1 207s [5,] 5.1 21.1 37.1 207s [6,] 6.1 22.1 38.1 207s [7,] 7.1 23.1 39.1 207s [8,] 8.1 24.1 40.1 207s [,1] [,2] [,3] 207s [1,] 1.1 17.1 33.1 207s [2,] 2.1 18.1 34.1 207s [3,] 3.1 19.1 35.1 207s [4,] 4.1 20.1 36.1 207s [5,] 5.1 21.1 37.1 207s [6,] 6.1 22.1 38.1 207s [7,] 7.1 23.1 39.1 207s [8,] 8.1 24.1 40.1 207s 0% 50% 100% 207s [1,] 1.1 17.1 33.1 207s [2,] 2.1 18.1 34.1 207s [3,] 3.1 19.1 35.1 207s [4,] 4.1 20.1 36.1 207s [5,] 5.1 21.1 37.1 207s [6,] 6.1 22.1 38.1 207s [7,] 7.1 23.1 39.1 207s [8,] 8.1 24.1 40.1 207s 0% 50% 100% 207s [1,] 1.1 17.1 33.1 207s [2,] 2.1 18.1 34.1 207s [3,] 3.1 19.1 35.1 207s [4,] 4.1 20.1 36.1 207s [5,] 5.1 21.1 37.1 207s [6,] 6.1 22.1 38.1 207s [7,] 7.1 23.1 39.1 207s [8,] 8.1 24.1 40.1 207s [,1] [,2] [,3] 207s [1,] 1.1 17.1 33.1 207s [2,] 2.1 18.1 34.1 207s [3,] 3.1 19.1 35.1 207s [4,] 4.1 20.1 36.1 207s [5,] 5.1 21.1 37.1 207s [6,] 6.1 22.1 38.1 207s [7,] 7.1 23.1 39.1 207s [8,] 8.1 24.1 40.1 207s [,1] [,2] [,3] 207s [1,] 1.1 17.1 33.1 207s [2,] 2.1 18.1 34.1 207s [3,] 3.1 19.1 35.1 207s [4,] 4.1 20.1 36.1 207s [5,] 5.1 21.1 37.1 207s [6,] 6.1 22.1 38.1 207s [7,] 7.1 23.1 39.1 207s [8,] 8.1 24.1 40.1 207s > 207s > 207s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 207s > # Test with a single quantile 207s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 207s > for (mode in c("logical", "integer", "double")) { 207s + cat("mode: ", mode, "\n", sep = "") 207s + x <- matrix(1:40, nrow = 8, ncol = 5) 207s + storage.mode(x) <- mode 207s + dimnames <- lapply(dim(x), FUN = function(n) letters[seq_len(n)]) 207s + str(x) 207s + 207s + probs <- c(0.5) 207s + # Test with and without dimnames on x 207s + for (setDimnames in c(TRUE, FALSE)) { 207s + if (setDimnames) dimnames(x) <- dimnames 207s + else dimnames(x) <- NULL 207s + # Check names attribute 207s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 207s + q0 <- rowQuantiles_R(x, probs = probs, useNames = useNames) 207s + print(q0) 207s + q1 <- rowQuantiles(x, probs = probs, useNames = useNames) 207s + ## FIXME: Workaround for R (< 3.0.0) 207s + if (getRversion() < "3.0.0" && mode == "logical") storage.mode(q1) <- storage.mode(q0) 207s + print(q1) 207s + stopifnot(all.equal(q1, q0)) 207s + q2 <- colQuantiles(t(x), probs = probs, useNames = useNames) 207s + ## FIXME: Workaround for R (< 3.0.0) 207s + if (getRversion() < "3.0.0" && mode == "logical") storage.mode(q2) <- storage.mode(q0) 207s + stopifnot(all.equal(q2, q0)) 207s + } 207s + } 207s + } # for (mode ...) 207s mode: logical 207s logi [1:8, 1:5] TRUE TRUE TRUE TRUE TRUE TRUE ... 207s a b c d e f g h 207s 1 1 1 1 1 1 1 1 207s a b c d e f g h 207s 1 1 1 1 1 1 1 1 207s [1] 1 1 1 1 1 1 1 1 207s [1] 1 1 1 1 1 1 1 1 207s [1] 1 1 1 1 1 1 1 1 207s [1] 1 1 1 1 1 1 1 1 207s [1] 1 1 1 1 1 1 1 1 207s [1] 1 1 1 1 1 1 1 1 207s mode: integer 207s int [1:8, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 207s a b c d e f g h 207s 17 18 19 20 21 22 23 24 207s a b c d e f g h 207s 17 18 19 20 21 22 23 24 207s [1] 17 18 19 20 21 22 23 24 207s [1] 17 18 19 20 21 22 23 24 207s [1] 17 18 19 20 21 22 23 24 207s [1] 17 18 19 20 21 22 23 24 207s [1] 17 18 19 20 21 22 23 24 207s [1] 17 18 19 20 21 22 23 24 207s mode: double 207s num [1:8, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 207s a b c d e f g h 207s 17 18 19 20 21 22 23 24 207s a b c d e f g h 207s 17 18 19 20 21 22 23 24 207s [1] 17 18 19 20 21 22 23 24 207s [1] 17 18 19 20 21 22 23 24 207s [1] 17 18 19 20 21 22 23 24 207s [1] 17 18 19 20 21 22 23 24 207s [1] 17 18 19 20 21 22 23 24 207s [1] 17 18 19 20 21 22 23 24 207s > 207s > 207s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 207s > # Consistency checks 207s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 207s > set.seed(1) 207s > 207s > probs <- seq(from = 0, to = 1, by = 0.25) 207s > 207s > cat("Consistency checks:\n") 207s Consistency checks: 207s > n_sims <- if (Sys.getenv("_R_CHECK_USE_VALGRIND_") != "") 6L else 24L 207s > for (kk in seq_len(n_sims)) { 207s + cat("Random test #", kk, "\n", sep = "") 207s + 207s + # Simulate data in a matrix of any shape 207s + dim <- sample(20:60, size = 2L) 207s + n <- prod(dim) 207s + x <- rnorm(n, sd = 100) 207s + dim(x) <- dim 207s + dimnames <- lapply(dim(x), FUN = function(n) rep(letters, length.out = n)) 207s + 207s + # Add NAs? 207s + has_na <- ((kk %% 2) == 0L) 207s + if (has_na) { 207s + cat("Adding NAs\n") 207s + nna <- sample(n, size = 1) 207s + na_values <- c(NA_real_, NaN) 207s + t <- sample(na_values, size = nna, replace = TRUE) 207s + x[sample(length(x), size = nna)] <- t 207s + } 207s + 207s + # Logical, integer, or double? 207s + mode <- "numeric" 207s + if ((kk %% 6) %in% 1:2) { 207s + cat("Coercing to logical\n") 207s + mode <- "logical" 207s + } else if ((kk %% 6) %in% 3:4) { 207s + cat("Coercing to integers\n") 207s + mode <- "integer" 207s + } 207s + storage.mode(x) <- mode 207s + 207s + str(x) 207s + 207s + # rowQuantiles(): 207s + for (type in 1:9) { 207s + cat(sprintf("type=%d, has_na=%s:\n", type, has_na)) 207s + # Test with and without dimnames on x 207s + for (setDimnames in c(TRUE, FALSE)) { 207s + if (setDimnames) dimnames(x) <- dimnames 207s + else dimnames(x) <- NULL 207s + # Check names attribute 207s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 207s + q0 <- rowQuantiles_R(x, probs = probs, na.rm = has_na, type = type, useNames = useNames) 207s + q1 <- rowQuantiles(x, probs = probs, na.rm = has_na, type = type, useNames = useNames) 207s + ## FIXME: Workaround for R (< 3.0.0) 207s + if (getRversion() < "3.0.0" && mode == "logical" && !has_na && type == 7L) storage.mode(q1) <- storage.mode(q0) 207s + stopifnot(all.equal(q1, q0)) 207s + q2 <- colQuantiles(t(x), probs = probs, na.rm = has_na, type = type, useNames = useNames) 207s + ## FIXME: Workaround for R (< 3.0.0) 207s + if (getRversion() < "3.0.0" && mode == "logical" && !has_na && type == 7L) storage.mode(q2) <- storage.mode(q0) 207s + stopifnot(all.equal(q2, q0)) 207s + } 207s + } 207s + } 207s + } # for (kk ...) 207s Random test #1 207s Coercing to logical 207s logi [1:23, 1:58] TRUE TRUE TRUE TRUE TRUE TRUE ... 207s type=1, has_na=FALSE: 207s type=2, has_na=FALSE: 207s type=3, has_na=FALSE: 207s type=4, has_na=FALSE: 207s type=5, has_na=FALSE: 207s type=6, has_na=FALSE: 207s type=7, has_na=FALSE: 207s type=8, has_na=FALSE: 207s type=9, has_na=FALSE: 207s Random test #2 207s Adding NAs 207s Coercing to logical 207s logi [1:58, 1:33] TRUE TRUE TRUE TRUE TRUE NA ... 207s type=1, has_na=TRUE: 208s type=2, has_na=TRUE: 208s type=3, has_na=TRUE: 208s type=4, has_na=TRUE: 208s type=5, has_na=TRUE: 208s type=6, has_na=TRUE: 208s type=7, has_na=TRUE: 208s type=8, has_na=TRUE: 208s type=9, has_na=TRUE: 208s Random test #3 208s Coercing to integers 208s int [1:28, 1:60] 119 -164 115 -129 209 -175 2 -32 120 -28 ... 208s type=1, has_na=FALSE: 208s type=2, has_na=FALSE: 208s type=3, has_na=FALSE: 208s type=4, has_na=FALSE: 208s type=5, has_na=FALSE: 208s type=6, has_na=FALSE: 208s type=7, has_na=FALSE: 208s type=8, has_na=FALSE: 208s type=9, has_na=FALSE: 208s Random test #4 208s Adding NAs 208s Coercing to integers 208s int [1:54, 1:35] 147 11 116 -50 NA -69 132 NA 114 NA ... 208s type=1, has_na=TRUE: 208s type=2, has_na=TRUE: 208s type=3, has_na=TRUE: 208s type=4, has_na=TRUE: 208s type=5, has_na=TRUE: 208s type=6, has_na=TRUE: 208s type=7, has_na=TRUE: 209s type=8, has_na=TRUE: 209s type=9, has_na=TRUE: 209s Random test #5 209s num [1:39, 1:53] 5.94 -27.16 -30.78 173 126.05 ... 209s type=1, has_na=FALSE: 209s type=2, has_na=FALSE: 209s type=3, has_na=FALSE: 209s type=4, has_na=FALSE: 209s type=5, has_na=FALSE: 209s type=6, has_na=FALSE: 209s type=7, has_na=FALSE: 209s type=8, has_na=FALSE: 209s type=9, has_na=FALSE: 209s Random test #6 209s Adding NAs 209s num [1:46, 1:22] 197 -107 15 148 -110 ... 209s type=1, has_na=TRUE: 209s type=2, has_na=TRUE: 209s type=3, has_na=TRUE: 209s type=4, has_na=TRUE: 209s type=5, has_na=TRUE: 209s type=6, has_na=TRUE: 209s type=7, has_na=TRUE: 209s type=8, has_na=TRUE: 209s type=9, has_na=TRUE: 209s Random test #7 209s Coercing to logical 209s logi [1:21, 1:51] TRUE TRUE TRUE TRUE TRUE TRUE ... 209s type=1, has_na=FALSE: 209s type=2, has_na=FALSE: 209s type=3, has_na=FALSE: 209s type=4, has_na=FALSE: 209s type=5, has_na=FALSE: 209s type=6, has_na=FALSE: 209s type=7, has_na=FALSE: 209s type=8, has_na=FALSE: 209s type=9, has_na=FALSE: 209s Random test #8 209s Adding NAs 209s Coercing to logical 209s logi [1:33, 1:53] NA NA TRUE TRUE TRUE TRUE ... 209s type=1, has_na=TRUE: 209s type=2, has_na=TRUE: 209s type=3, has_na=TRUE: 210s type=4, has_na=TRUE: 210s type=5, has_na=TRUE: 210s type=6, has_na=TRUE: 210s type=7, has_na=TRUE: 210s type=8, has_na=TRUE: 210s type=9, has_na=TRUE: 210s Random test #9 210s Coercing to integers 210s int [1:53, 1:24] -73 10 -73 -5 44 -107 -100 95 58 -50 ... 210s type=1, has_na=FALSE: 210s type=2, has_na=FALSE: 210s type=3, has_na=FALSE: 210s type=4, has_na=FALSE: 210s type=5, has_na=FALSE: 210s type=6, has_na=FALSE: 210s type=7, has_na=FALSE: 210s type=8, has_na=FALSE: 210s type=9, has_na=FALSE: 210s Random test #10 210s Adding NAs 210s Coercing to integers 210s int [1:44, 1:20] NA -140 NA -57 -252 NA NA 20 NA NA ... 210s type=1, has_na=TRUE: 210s type=2, has_na=TRUE: 210s type=3, has_na=TRUE: 210s type=4, has_na=TRUE: 210s type=5, has_na=TRUE: 210s type=6, has_na=TRUE: 210s type=7, has_na=TRUE: 210s type=8, has_na=TRUE: 210s type=9, has_na=TRUE: 211s Random test #11 211s num [1:54, 1:23] -160.87 74.13 196.08 7.27 4.92 ... 211s type=1, has_na=FALSE: 211s type=2, has_na=FALSE: 211s type=3, has_na=FALSE: 211s type=4, has_na=FALSE: 211s type=5, has_na=FALSE: 211s type=6, has_na=FALSE: 211s type=7, has_na=FALSE: 211s type=8, has_na=FALSE: 211s type=9, has_na=FALSE: 211s Random test #12 211s Adding NAs 211s num [1:59, 1:27] -139.2 -86.3 NA -40.7 NA ... 211s type=1, has_na=TRUE: 211s type=2, has_na=TRUE: 211s type=3, has_na=TRUE: 211s type=4, has_na=TRUE: 211s type=5, has_na=TRUE: 211s type=6, has_na=TRUE: 211s type=7, has_na=TRUE: 211s type=8, has_na=TRUE: 211s type=9, has_na=TRUE: 212s Random test #13 212s Coercing to logical 212s logi [1:53, 1:60] TRUE TRUE TRUE TRUE TRUE TRUE ... 212s type=1, has_na=FALSE: 212s type=2, has_na=FALSE: 212s type=3, has_na=FALSE: 212s type=4, has_na=FALSE: 212s type=5, has_na=FALSE: 212s type=6, has_na=FALSE: 212s type=7, has_na=FALSE: 212s type=8, has_na=FALSE: 212s type=9, has_na=FALSE: 212s Random test #14 212s Adding NAs 212s Coercing to logical 212s logi [1:22, 1:57] TRUE TRUE TRUE TRUE TRUE TRUE ... 212s type=1, has_na=TRUE: 212s type=2, has_na=TRUE: 212s type=3, has_na=TRUE: 212s type=4, has_na=TRUE: 212s type=5, has_na=TRUE: 212s type=6, has_na=TRUE: 212s type=7, has_na=TRUE: 212s type=8, has_na=TRUE: 212s type=9, has_na=TRUE: 212s Random test #15 212s Coercing to integers 212s int [1:20, 1:34] 78 -41 183 190 -71 37 0 -4 -86 27 ... 212s type=1, has_na=FALSE: 212s type=2, has_na=FALSE: 212s type=3, has_na=FALSE: 212s type=4, has_na=FALSE: 212s type=5, has_na=FALSE: 212s type=6, has_na=FALSE: 212s type=7, has_na=FALSE: 212s type=8, has_na=FALSE: 212s type=9, has_na=FALSE: 212s Random test #16 212s Adding NAs 212s Coercing to integers 212s int [1:42, 1:37] NA 12 -15 41 -28 17 NA -74 NA NA ... 212s type=1, has_na=TRUE: 212s type=2, has_na=TRUE: 212s type=3, has_na=TRUE: 212s type=4, has_na=TRUE: 212s type=5, has_na=TRUE: 212s type=6, has_na=TRUE: 212s type=7, has_na=TRUE: 213s type=8, has_na=TRUE: 213s type=9, has_na=TRUE: 213s Random test #17 213s num [1:42, 1:29] -50.51 -6.51 -117.59 135.58 226.87 ... 213s type=1, has_na=FALSE: 213s type=2, has_na=FALSE: 213s type=3, has_na=FALSE: 213s type=4, has_na=FALSE: 213s type=5, has_na=FALSE: 213s type=6, has_na=FALSE: 213s type=7, has_na=FALSE: 213s type=8, has_na=FALSE: 213s type=9, has_na=FALSE: 213s Random test #18 213s Adding NAs 213s num [1:57, 1:39] 223 156.8 -44.6 -127.5 -147.7 ... 213s type=1, has_na=TRUE: 213s type=2, has_na=TRUE: 213s type=3, has_na=TRUE: 213s type=4, has_na=TRUE: 213s type=5, has_na=TRUE: 213s type=6, has_na=TRUE: 213s type=7, has_na=TRUE: 213s type=8, has_na=TRUE: 213s type=9, has_na=TRUE: 213s Random test #19 213s Coercing to logical 213s logi [1:52, 1:57] TRUE TRUE TRUE TRUE TRUE TRUE ... 213s type=1, has_na=FALSE: 213s type=2, has_na=FALSE: 213s type=3, has_na=FALSE: 213s type=4, has_na=FALSE: 214s type=5, has_na=FALSE: 214s type=6, has_na=FALSE: 214s type=7, has_na=FALSE: 214s type=8, has_na=FALSE: 214s type=9, has_na=FALSE: 214s Random test #20 214s Adding NAs 214s Coercing to logical 214s logi [1:25, 1:48] NA TRUE NA NA NA NA ... 214s type=1, has_na=TRUE: 214s type=2, has_na=TRUE: 214s type=3, has_na=TRUE: 214s type=4, has_na=TRUE: 214s type=5, has_na=TRUE: 214s type=6, has_na=TRUE: 214s type=7, has_na=TRUE: 214s type=8, has_na=TRUE: 214s type=9, has_na=TRUE: 214s Random test #21 214s Coercing to integers 214s int [1:53, 1:27] 3 -30 203 -49 19 -45 -138 28 46 -44 ... 214s type=1, has_na=FALSE: 214s type=2, has_na=FALSE: 214s type=3, has_na=FALSE: 214s type=4, has_na=FALSE: 214s type=5, has_na=FALSE: 214s type=6, has_na=FALSE: 214s type=7, has_na=FALSE: 214s type=8, has_na=FALSE: 214s type=9, has_na=FALSE: 214s Random test #22 214s Adding NAs 214s Coercing to integers 214s int [1:48, 1:36] -131 NA NA -201 45 -17 NA 57 NA NA ... 214s type=1, has_na=TRUE: 214s type=2, has_na=TRUE: 214s type=3, has_na=TRUE: 214s type=4, has_na=TRUE: 215s type=5, has_na=TRUE: 215s type=6, has_na=TRUE: 215s type=7, has_na=TRUE: 215s type=8, has_na=TRUE: 215s type=9, has_na=TRUE: 215s Random test #23 215s num [1:23, 1:43] -99.2 -68.8 -86.7 -104.2 48 ... 215s type=1, has_na=FALSE: 215s type=2, has_na=FALSE: 215s type=3, has_na=FALSE: 215s type=4, has_na=FALSE: 215s type=5, has_na=FALSE: 215s type=6, has_na=FALSE: 215s type=7, has_na=FALSE: 215s type=8, has_na=FALSE: 215s type=9, has_na=FALSE: 215s Random test #24 215s Adding NAs 215s num [1:53, 1:29] NaN -67.6 10.8 -88.4 130.1 ... 215s type=1, has_na=TRUE: 215s type=2, has_na=TRUE: 215s type=3, has_na=TRUE: 215s type=4, has_na=TRUE: 215s type=5, has_na=TRUE: 215s type=6, has_na=TRUE: 215s type=7, has_na=TRUE: 215s type=8, has_na=TRUE: 215s type=9, has_na=TRUE: 215s > 215s > 215s > 215s > for (mode in c("logical", "integer", "double")) { 215s + naValue <- NA_real_ 215s + storage.mode(naValue) <- mode 215s + 215s + someValue <- 1 215s + storage.mode(someValue) <- mode 215s + 215s + for (type in 1:9) { 215s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 215s + # All NA 215s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 215s + x <- matrix(naValue, nrow = 3L, ncol = 4L) 215s + dimnames <- lapply(dim(x), FUN = function(n) letters[seq_len(n)]) 215s + # Test with and without dimnames on x 215s + for (setDimnames in c(TRUE, FALSE)) { 215s + if (setDimnames) dimnames(x) <- dimnames 215s + else dimnames(x) <- NULL 215s + # Check names attribute 215s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 215s + qr0 <- rowQuantiles_R(x, type = type, useNames = useNames) 215s + 215s + qr <- rowQuantiles(x, type = type, useNames = useNames) 215s + stopifnot(identical(qr, qr0)) 215s + 215s + # x <- matrix(naValue, nrow = 4L, ncol = 3L) 215s + qc <- colQuantiles(t(x), type = type, useNames = useNames) 215s + 215s + stopifnot(identical(qc, qr)) 215s + } 215s + } 215s + 215s + 215s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 215s + # Empty matrices 215s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 215s + probs <- c(0, 0.25, 0.75, 1) 215s + x <- matrix(naValue, nrow = 0L, ncol = 0L) 215s + dimnames(x) <- lapply(dim(x), FUN = function(n) letters[seq_len(n)]) 215s + q <- rowQuantiles(x, probs = probs, type = type, useNames = TRUE) 215s + stopifnot(identical(dim(q), c(nrow(x), length(probs)))) 215s + q <- colQuantiles(x, probs = probs, type = type, useNames = TRUE) 215s + stopifnot(identical(dim(q), c(ncol(x), length(probs)))) 215s + 215s + x <- matrix(naValue, nrow = 2L, ncol = 0L) 215s + dimnames(x) <- lapply(dim(x), FUN = function(n) letters[seq_len(n)]) 215s + q <- rowQuantiles(x, probs = probs, type = type, useNames = TRUE) 215s + stopifnot(identical(dim(q), c(nrow(x), length(probs)))) 215s + 215s + x <- matrix(naValue, nrow = 0L, ncol = 2L) 215s + dimnames(x) <- lapply(dim(x), FUN = function(n) letters[seq_len(n)]) 215s + q <- colQuantiles(x, probs = probs, type = type, useNames = TRUE) 215s + stopifnot(identical(dim(q), c(ncol(x), length(probs)))) 215s + 215s + 215s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 215s + # Single column matrices 215s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 215s + probs <- c(0, 0.25, 0.75, 1) 215s + x <- matrix(someValue, nrow = 2L, ncol = 1L) 215s + dimnames(x) <- lapply(dim(x), FUN = function(n) letters[seq_len(n)]) 215s + qr <- rowQuantiles(x, probs = probs, type = type, useNames = TRUE) 215s + print(qr) 215s + 215s + x <- matrix(someValue, nrow = 1L, ncol = 2L) 215s + dimnames(x) <- lapply(dim(x), FUN = function(n) letters[seq_len(n)]) 215s + qc <- colQuantiles(x, probs = probs, type = type, useNames = TRUE) 215s + print(qc) 215s + 215s + stopifnot(identical(qc, qr)) 215s + } 215s + } 215s 0% 25% 75% 100% 215s a 1 1 1 1 215s b 1 1 1 1 215s 0% 25% 75% 100% 215s a 1 1 1 1 215s b 1 1 1 1 215s 0% 25% 75% 100% 215s a 1 1 1 1 215s b 1 1 1 1 215s 0% 25% 75% 100% 215s a 1 1 1 1 215s b 1 1 1 1 215s 0% 25% 75% 100% 215s a 1 1 1 1 215s b 1 1 1 1 215s 0% 25% 75% 100% 215s a 1 1 1 1 215s b 1 1 1 1 215s 0% 25% 75% 100% 215s a 1 1 1 1 215s b 1 1 1 1 215s 0% 25% 75% 100% 215s a 1 1 1 1 215s b 1 1 1 1 215s 0% 25% 75% 100% 215s a 1 1 1 1 215s b 1 1 1 1 215s 0% 25% 75% 100% 215s a 1 1 1 1 215s b 1 1 1 1 215s 0% 25% 75% 100% 215s a 1 1 1 1 215s b 1 1 1 1 215s 0% 25% 75% 100% 215s a 1 1 1 1 215s b 1 1 1 1 215s 0% 25% 75% 100% 215s a 1 1 1 1 215s b 1 1 1 1 215s 0% 25% 75% 100% 215s a 1 1 1 1 215s b 1 1 1 1 215s 0% 25% 75% 100% 215s a 1 1 1 1 215s b 1 1 1 1 215s 0% 25% 75% 100% 215s a 1 1 1 1 215s b 1 1 1 1 215s 0% 25% 75% 100% 215s a 1 1 1 1 215s b 1 1 1 1 215s 0% 25% 75% 100% 215s a 1 1 1 1 215s b 1 1 1 1 215s 0% 25% 75% 100% 215s a 1 1 1 1 215s b 1 1 1 1 215s 0% 25% 75% 100% 215s a 1 1 1 1 215s b 1 1 1 1 215s 0% 25% 75% 100% 215s a 1 1 1 1 215s b 1 1 1 1 215s 0% 25% 75% 100% 215s a 1 1 1 1 215s b 1 1 1 1 215s 0% 25% 75% 100% 215s a 1 1 1 1 215s b 1 1 1 1 215s 0% 25% 75% 100% 215s a 1 1 1 1 215s b 1 1 1 1 215s 0% 25% 75% 100% 215s a 1 1 1 1 215s b 1 1 1 1 215s 0% 25% 75% 100% 215s a 1 1 1 1 215s b 1 1 1 1 215s 0% 25% 75% 100% 215s a 1 1 1 1 215s b 1 1 1 1 215s 0% 25% 75% 100% 215s a 1 1 1 1 215s b 1 1 1 1 215s 0% 25% 75% 100% 215s a 1 1 1 1 215s b 1 1 1 1 215s 0% 25% 75% 100% 215s a 1 1 1 1 215s b 1 1 1 1 215s 0% 25% 75% 100% 215s a 1 1 1 1 215s b 1 1 1 1 215s 0% 25% 75% 100% 215s a 1 1 1 1 215s b 1 1 1 1 215s 0% 25% 75% 100% 215s a 1 1 1 1 215s b 1 1 1 1 215s 0% 25% 75% 100% 215s a 1 1 1 1 215s b 1 1 1 1 215s 0% 25% 75% 100% 215s a 1 1 1 1 215s b 1 1 1 1 215s 0% 25% 75% 100% 215s a 1 1 1 1 215s b 1 1 1 1 215s 0% 25% 75% 100% 215s a 1 1 1 1 215s b 1 1 1 1 215s 0% 25% 75% 100% 215s a 1 1 1 1 215s b 1 1 1 1 215s 0% 25% 75% 100% 215s a 1 1 1 1 215s b 1 1 1 1 215s 0% 25% 75% 100% 215s a 1 1 1 1 215s b 1 1 1 1 215s 0% 25% 75% 100% 215s a 1 1 1 1 215s b 1 1 1 1 215s 0% 25% 75% 100% 215s a 1 1 1 1 215s b 1 1 1 1 215s 0% 25% 75% 100% 215s a 1 1 1 1 215s b 1 1 1 1 215s 0% 25% 75% 100% 215s a 1 1 1 1 215s b 1 1 1 1 215s 0% 25% 75% 100% 215s a 1 1 1 1 215s b 1 1 1 1 215s 0% 25% 75% 100% 215s a 1 1 1 1 215s b 1 1 1 1 215s 0% 25% 75% 100% 215s a 1 1 1 1 215s b 1 1 1 1 215s 0% 25% 75% 100% 215s a 1 1 1 1 215s b 1 1 1 1 215s 0% 25% 75% 100% 215s a 1 1 1 1 215s b 1 1 1 1 215s 0% 25% 75% 100% 215s a 1 1 1 1 215s b 1 1 1 1 215s 0% 25% 75% 100% 215s a 1 1 1 1 215s b 1 1 1 1 215s 0% 25% 75% 100% 215s a 1 1 1 1 215s b 1 1 1 1 216s 0% 25% 75% 100% 216s a 1 1 1 1 216s b 1 1 1 1 216s 0% 25% 75% 100% 216s a 1 1 1 1 216s b 1 1 1 1 216s > 216s 216s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 216s Copyright (C) 2024 The R Foundation for Statistical Computing 216s Platform: x86_64-pc-linux-gnu 216s 216s R is free software and comes with ABSOLUTELY NO WARRANTY. 216s You are welcome to redistribute it under certain conditions. 216s Type 'license()' or 'licence()' for distribution details. 216s 216s R is a collaborative project with many contributors. 216s Type 'contributors()' for more information and 216s 'citation()' on how to cite R or R packages in publications. 216s 216s Type 'demo()' for some demos, 'help()' for on-line help, or 216s 'help.start()' for an HTML browser interface to help. 216s Type 'q()' to quit R. 216s 216s > library("matrixStats") 216s > 216s > ## Create isFALSE() if running on an old version of R 216s > if (!exists("isFALSE", mode="function")) { 216s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 216s + } 216s > 216s > rowQuantiles_R <- function(x, probs, na.rm = FALSE, drop = TRUE, ..., useNames = NA) { 216s + q <- apply(x, MARGIN = 1L, FUN = function(x, probs, na.rm) { 216s + if (!na.rm && any(is.na(x))) { 216s + na_value <- NA_real_ 216s + storage.mode(na_value) <- storage.mode(x) 216s + rep(na_value, times = length(probs)) 216s + 216s + } else { 216s + as.vector(quantile(x, probs = probs, na.rm = na.rm, names = FALSE, ...)) 216s + } 216s + }, probs = probs, na.rm = na.rm) 216s + 216s + if (!is.null(dim(q))) q <- t(q) 216s + else dim(q) <- c(nrow(x), length(probs)) 216s + 216s + colnames(q) <- matrixStats:::quantile_probs_names(probs) 216s + rownames(q) <- rownames(x) 216s + if (isFALSE(useNames)) dimnames(q) <- NULL 216s + 216s + if (drop) q <- drop(q) 216s + q 216s + } 216s > 216s > 216s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 216s > # Subsetted tests 216s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 216s > source("utils/validateIndicesFramework.R") 216s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 216s > dimnames <- lapply(dim(x), FUN = function(n) letters[seq_len(n)]) 216s > probs <- c(0, 0.25, 0.75, 1) 216s > # Test with and without dimnames on x 216s > for (setDimnames in c(TRUE, FALSE)) { 216s + if (setDimnames) dimnames(x) <- dimnames 216s + else dimnames(x) <- NULL 216s + 216s + count <- 0L 216s + for (rows in index_cases) { 216s + for (cols in index_cases) { 216s + count <- count + 1L 216s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 216s + useNames <- c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE) 216s + useNames <- useNames[count %% length(useNames) + 1] 216s + 216s + validateIndicesTestMatrix(x, rows, cols, 216s + ftest = rowQuantiles, fsure = rowQuantiles_R, 216s + probs = probs, na.rm = na.rm, drop = FALSE, useNames = useNames) 216s + validateIndicesTestMatrix(x, rows, cols, 216s + fcoltest = colQuantiles, fsure = rowQuantiles_R, 216s + probs = probs, na.rm = na.rm, drop = FALSE, useNames = useNames) 216s + } 216s + } 216s + } 217s > 217s > 217s 217s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 217s Copyright (C) 2024 The R Foundation for Statistical Computing 217s Platform: x86_64-pc-linux-gnu 217s 217s R is free software and comes with ABSOLUTELY NO WARRANTY. 217s You are welcome to redistribute it under certain conditions. 217s Type 'license()' or 'licence()' for distribution details. 217s 217s R is a collaborative project with many contributors. 217s Type 'contributors()' for more information and 217s 'citation()' on how to cite R or R packages in publications. 217s 217s Type 'demo()' for some demos, 'help()' for on-line help, or 217s 'help.start()' for an HTML browser interface to help. 217s Type 'q()' to quit R. 217s 217s > library("matrixStats") 217s > 217s > rowMins_R <- function(x, ..., useNames = NA) { 217s + suppressWarnings({ 217s + res <- apply(x, MARGIN = 1L, FUN = min, ...) 217s + }) 217s + if (is.na(useNames) || !useNames) names(res) <- NULL 217s + res 217s + } # rowMins_R() 217s > 217s > rowMaxs_R <- function(x, ..., useNames = NA) { 217s + suppressWarnings({ 217s + res <- apply(x, MARGIN = 1L, FUN = max, ...) 217s + }) 217s + if (is.na(useNames) || !useNames) names(res) <- NULL 217s + res 217s + } # rowMaxs_R() 217s > 217s > rowRanges_R <- function(x, ..., useNames = NA) { 217s + suppressWarnings({ 217s + ans <- t(apply(x, MARGIN = 1L, FUN = range, ...)) 217s + }) 217s + 217s + # Preserve rownames attribute 217s + dim <- c(dim(x)[1], 2L) 217s + if (!isTRUE(all.equal(dim(ans), dim))) { 217s + dim(ans) <- dim 217s + rownames <- rownames(x) 217s + if (!is.null(dimnames)) rownames(ans) <- rownames 217s + } 217s + if (is.na(useNames) || !useNames) dimnames(ans) <- NULL 217s + ans 217s + } # rowRanges_R() 217s > 217s > 217s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 217s > # With and without some NAs 217s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 217s > for (mode in c("integer", "double")) { 217s + cat("mode: ", mode, "\n", sep = "") 217s + 217s + for (add_na in c(FALSE, TRUE)) { 217s + cat("add_na = ", add_na, "\n", sep = "") 217s + 217s + x <- matrix(1:50 + 0.1, nrow = 10L, ncol = 5L) 217s + if (add_na) { 217s + x[3:7, c(2, 4)] <- NA_real_ 217s + } 217s + storage.mode(x) <- mode 217s + str(x) 217s + 217s + # To check names attribute 217s + dimnames <- list(letters[1:10], LETTERS[1:5]) 217s + 217s + # Test with and without dimnames on x 217s + for (setDimnames in c(TRUE, FALSE)) { 217s + if (setDimnames) dimnames(x) <- dimnames 217s + else dimnames(x) <- NULL 217s + # Row/column extremes 217s + for (na.rm in c(FALSE, TRUE)) { 217s + # Check names attribute 217s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 217s + cat("na.rm = ", na.rm, "\n", sep = "") 217s + 217s + # Ranges 217s + cat("range:\n") 217s + r0 <- rowRanges_R(x, na.rm = na.rm, useNames = useNames) 217s + r1 <- rowRanges(x, na.rm = na.rm, useNames = useNames) 217s + r2 <- colRanges(t(x), na.rm = na.rm, useNames = useNames) 217s + stopifnot(all.equal(r1, r2)) 217s + stopifnot(all.equal(r1, r0)) 217s + 217s + # Min 217s + cat("min:\n") 217s + m0 <- rowMins_R(x, na.rm = na.rm, useNames = useNames) 217s + m1 <- rowMins(x, na.rm = na.rm, useNames = useNames) 217s + m2 <- colMins(t(x), na.rm = na.rm, useNames = useNames) 217s + stopifnot(all.equal(m1, m2)) 217s + stopifnot(all.equal(m1, m0)) 217s + 217s + # Max 217s + cat("max:\n") 217s + m0 <- rowMaxs_R(x, na.rm = na.rm, useNames = useNames) 217s + m1 <- rowMaxs(x, na.rm = na.rm, useNames = useNames) 217s + m2 <- colMaxs(t(x), na.rm = na.rm, useNames = useNames) 217s + stopifnot(all.equal(m1, m2)) 217s + stopifnot(all.equal(m1, m0)) 217s + } 217s + } 217s + } 217s + } # for (add_na ...) 217s + } # for (mode ...) 217s mode: integer 217s add_na = FALSE 217s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 217s na.rm = FALSE 217s range: 217s min: 217s max: 217s na.rm = FALSE 217s range: 217s min: 217s max: 217s na.rm = TRUE 217s range: 217s min: 217s max: 217s na.rm = TRUE 217s range: 217s min: 217s max: 217s na.rm = FALSE 217s range: 217s min: 217s max: 217s na.rm = FALSE 217s range: 217s min: 217s max: 217s na.rm = TRUE 217s range: 217s min: 217s max: 217s na.rm = TRUE 217s range: 217s min: 217s max: 217s add_na = TRUE 217s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 217s na.rm = FALSE 217s range: 217s min: 217s max: 217s na.rm = FALSE 217s range: 217s min: 217s max: 217s na.rm = TRUE 217s range: 217s min: 217s max: 217s na.rm = TRUE 217s range: 217s min: 217s max: 217s na.rm = FALSE 217s range: 217s min: 217s max: 217s na.rm = FALSE 217s range: 217s min: 217s max: 217s na.rm = TRUE 217s range: 217s min: 217s max: 217s na.rm = TRUE 217s range: 217s min: 217s max: 217s mode: double 217s add_na = FALSE 217s num [1:10, 1:5] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ... 217s na.rm = FALSE 217s range: 217s min: 217s max: 217s na.rm = FALSE 217s range: 217s min: 217s max: 217s na.rm = TRUE 217s range: 217s min: 217s max: 217s na.rm = TRUE 217s range: 217s min: 217s max: 217s na.rm = FALSE 217s range: 217s min: 217s max: 217s na.rm = FALSE 217s range: 217s min: 217s max: 217s na.rm = TRUE 217s range: 217s min: 217s max: 217s na.rm = TRUE 217s range: 217s min: 217s max: 217s add_na = TRUE 217s num [1:10, 1:5] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ... 217s na.rm = FALSE 217s range: 217s min: 217s max: 217s na.rm = FALSE 217s range: 217s min: 217s max: 217s na.rm = TRUE 217s range: 217s min: 217s max: 217s na.rm = TRUE 217s range: 217s min: 217s max: 217s na.rm = FALSE 217s range: 217s min: 217s max: 217s na.rm = FALSE 217s range: 217s min: 217s max: 217s na.rm = TRUE 217s range: 217s min: 217s max: 217s na.rm = TRUE 217s range: 217s min: 217s max: 217s > 217s > 217s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 217s > # All NAs 217s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 217s > for (mode in c("integer", "double")) { 217s + cat("mode: ", mode, "\n", sep = "") 217s + x <- matrix(NA_real_, nrow = 10L, ncol = 5L) 217s + storage.mode(x) <- mode 217s + str(x) 217s + 217s + # Test with and without dimnames on x 217s + for (setDimnames in c(TRUE, FALSE)) { 217s + if (setDimnames) dimnames(x) <- dimnames 217s + else dimnames(x) <- NULL 217s + for (na.rm in c(FALSE, TRUE)) { 217s + # Check names attribute 217s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 217s + cat("na.rm = ", na.rm, "\n", sep = "") 217s + r0 <- rowRanges_R(x, na.rm = na.rm, useNames = useNames) 217s + r1 <- rowRanges(x, na.rm = na.rm, useNames = useNames) 217s + r2 <- colRanges(t(x), na.rm = na.rm, useNames = useNames) 217s + stopifnot(all.equal(r1, r2)) 217s + stopifnot(all.equal(r1, r0)) 217s + } 217s + } 217s + } 217s + } # for (mode ...) 217s mode: integer 217s int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 217s na.rm = FALSE 217s na.rm = FALSE 217s na.rm = TRUE 217s na.rm = TRUE 217s na.rm = FALSE 217s na.rm = FALSE 217s na.rm = TRUE 217s na.rm = TRUE 217s mode: double 217s num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 217s na.rm = FALSE 217s na.rm = FALSE 217s na.rm = TRUE 217s na.rm = TRUE 217s na.rm = FALSE 217s na.rm = FALSE 217s na.rm = TRUE 217s na.rm = TRUE 217s > 217s > 217s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 217s > # Special cases 217s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 217s > # Nx0 matrix 217s > x <- matrix(double(0L), nrow = 5L, ncol = 0L) 217s > r0 <- rowRanges_R(x) 217s > #r1 <- rowRanges(x) 217s > #r_truth <- matrix(c(Inf, -Inf), nrow = nrow(x), ncol = 2L, byrow = TRUE) 217s > #stopifnot(all.equal(r1, r_truth)) 217s > 217s > # 0xN matrix 217s > x <- t(x) 217s > #r1 <- colRanges(x) 217s > #stopifnot(all.equal(r1, r_truth)) 217s > 217s > # Nx1 matrix 217s > x <- matrix(1:5, nrow = 5L, ncol = 1L) 217s > # To check names attribute 217s > dimnames <- list(letters[1:5], "A") 217s > r1 <- rowRanges(x) 217s > r_truth <- matrix(1:5, nrow = nrow(x), ncol = 2L, byrow = FALSE) 217s > stopifnot(all.equal(r1, r_truth)) 217s > # Check names attribute 217s > dimnames(x) <- dimnames 217s > r0 <- rowRanges_R(x, useNames = TRUE) 217s > r1 <- rowRanges(x, useNames = TRUE) 217s > stopifnot(all.equal(r1, r0)) 217s > dimnames(x) <- NULL 217s > 217s > # 1xN matrix 217s > x <- t(x) 217s > r1 <- colRanges(x) 217s > stopifnot(all.equal(r1, r_truth)) 217s > # Check names attribute 217s > dimnames(x) <- list("a", LETTERS[1:5]) 217s > r1 <- colRanges(x, useNames = TRUE) 217s > stopifnot(identical(rownames(r1), colnames(x))) 217s > 217s > 217s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 217s > # Additional tests with NA_integer_, NA_real, NaN, -Inf, +Inf 217s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 217s > x <- matrix(1:12, nrow = 4L, ncol = 3L) 217s > 217s > na_list <- list( 217s + "integer" = matrix(1:12, nrow = 4L, ncol = 3L), 217s + "integer w/ NA" = matrix(NA_integer_, nrow = 4L, ncol = 3L), 217s + "real" = matrix(as.double(1:12), nrow = 4L, ncol = 3L), 217s + "real w/ NA" = matrix(NA_real_, nrow = 4L, ncol = 3L) 217s + ) 217s > 217s > na <- na_list[["real"]] 217s > na[2, 2] <- NA 217s > na_list[["real + NA cell"]] <- na 217s > 217s > na <- na_list[["real"]] 217s > na[2, ] <- NA 217s > na_list[["real + NA row"]] <- na 217s > 217s > na <- na_list[["real"]] 217s > na[2, ] <- NaN 217s > na_list[["real + NaN row"]] <- na 217s > 217s > na <- na_list[["real"]] 217s > na[2, 2] <- Inf 217s > na_list[["real + Inf cell"]] <- na 217s > 217s > na <- na_list[["real"]] 217s > na[2, ] <- Inf 217s > na_list[["real + Inf row"]] <- na 217s > 217s > na <- na_list[["real"]] 217s > na[2, 2] <- NaN 217s > na_list[["real + NaN cell"]] <- na 217s > 217s > na <- na_list[["real w/ NA"]] 217s > na[2, 2] <- NaN 217s > na_list[["real w/ NA + NaN cell"]] <- na 217s > 217s > na <- na_list[["real w/ NA"]] 217s > na[2, ] <- NaN 217s > na_list[["real w/ NA + NaN row"]] <- na 217s > 217s > # To check names attribute 217s > dimnames <- list(letters[1:4], LETTERS[1:3]) 217s > 217s > # Test with and without dimnames on x 217s > for (setDimnames in c(TRUE, FALSE)) { 217s + if (setDimnames) dimnames(x) <- dimnames 217s + else dimnames(x) <- NULL 217s + for (na.rm in c(FALSE, TRUE)) { 217s + for (name in names(na_list)) { 217s + # Check names attribute 217s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 217s + na <- na_list[[name]] 217s + cat(sprintf("%s (%s) w/ na.rm = %s:\n", name, typeof(na), na.rm)) 217s + print(na) 217s + 217s + cat(" min:\n") 217s + y0 <- rowMins_R(na, na.rm = na.rm, useNames = useNames) 217s + str(y0) 217s + y1 <- rowMins(na, na.rm = na.rm, useNames = useNames) 217s + str(y1) 217s + stopifnot(all.equal(y1, y0)) 217s + y1c <- colMins(t(na), na.rm = na.rm, useNames = useNames) 217s + str(y1c) 217s + stopifnot(all.equal(y1c, y1)) 217s + 217s + cat(" max:\n") 217s + y0 <- rowMaxs_R(na, na.rm = na.rm, useNames = useNames) 217s + str(y0) 217s + y1 <- rowMaxs(na, na.rm = na.rm, useNames = useNames) 217s + str(y1) 217s + stopifnot(all.equal(y1, y0)) 217s + y1c <- colMaxs(t(na), na.rm = na.rm, useNames = useNames) 217s + str(y1c) 217s + stopifnot(all.equal(y1c, y1)) 217s + 217s + cat(" range:\n") 217s + y0 <- rowRanges_R(na, na.rm = na.rm, useNames = useNames) 217s + str(y0) 217s + y1 <- rowRanges(na, na.rm = na.rm, useNames = useNames) 217s + str(y1) 217s + stopifnot(all.equal(y1, y0)) 217s + y1c <- colRanges(t(na), na.rm = na.rm, useNames = useNames) 217s + str(y1c) 217s + stopifnot(all.equal(y1c, y1)) 217s + } 217s + } # for (name ...) 217s + } # for (na.rm ...) 217s + } 217s integer (integer) w/ na.rm = FALSE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] 2 6 10 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s int [1:4] 1 2 3 4 217s int [1:4] 1 2 3 4 217s int [1:4] 1 2 3 4 217s max: 217s int [1:4] 9 10 11 12 217s int [1:4] 9 10 11 12 217s int [1:4] 9 10 11 12 217s range: 217s int [1:4, 1:2] 1 2 3 4 9 10 11 12 217s int [1:4, 1:2] 1 2 3 4 9 10 11 12 217s int [1:4, 1:2] 1 2 3 4 9 10 11 12 217s integer (integer) w/ na.rm = FALSE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] 2 6 10 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s int [1:4] 1 2 3 4 217s int [1:4] 1 2 3 4 217s int [1:4] 1 2 3 4 217s max: 217s int [1:4] 9 10 11 12 217s int [1:4] 9 10 11 12 217s int [1:4] 9 10 11 12 217s range: 217s int [1:4, 1:2] 1 2 3 4 9 10 11 12 217s int [1:4, 1:2] 1 2 3 4 9 10 11 12 217s int [1:4, 1:2] 1 2 3 4 9 10 11 12 217s integer w/ NA (integer) w/ na.rm = FALSE: 217s [,1] [,2] [,3] 217s [1,] NA NA NA 217s [2,] NA NA NA 217s [3,] NA NA NA 217s [4,] NA NA NA 217s min: 217s int [1:4] NA NA NA NA 217s int [1:4] NA NA NA NA 217s int [1:4] NA NA NA NA 217s max: 217s int [1:4] NA NA NA NA 217s int [1:4] NA NA NA NA 217s int [1:4] NA NA NA NA 217s range: 217s int [1:4, 1:2] NA NA NA NA NA NA NA NA 217s int [1:4, 1:2] NA NA NA NA NA NA NA NA 217s int [1:4, 1:2] NA NA NA NA NA NA NA NA 217s integer w/ NA (integer) w/ na.rm = FALSE: 217s [,1] [,2] [,3] 217s [1,] NA NA NA 217s [2,] NA NA NA 217s [3,] NA NA NA 217s [4,] NA NA NA 217s min: 217s int [1:4] NA NA NA NA 217s int [1:4] NA NA NA NA 217s int [1:4] NA NA NA NA 217s max: 217s int [1:4] NA NA NA NA 217s int [1:4] NA NA NA NA 217s int [1:4] NA NA NA NA 217s range: 217s int [1:4, 1:2] NA NA NA NA NA NA NA NA 217s int [1:4, 1:2] NA NA NA NA NA NA NA NA 217s int [1:4, 1:2] NA NA NA NA NA NA NA NA 217s real (double) w/ na.rm = FALSE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] 2 6 10 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s num [1:4] 1 2 3 4 217s num [1:4] 1 2 3 4 217s num [1:4] 1 2 3 4 217s max: 217s num [1:4] 9 10 11 12 217s num [1:4] 9 10 11 12 217s num [1:4] 9 10 11 12 217s range: 217s num [1:4, 1:2] 1 2 3 4 9 10 11 12 217s num [1:4, 1:2] 1 2 3 4 9 10 11 12 217s num [1:4, 1:2] 1 2 3 4 9 10 11 12 217s real (double) w/ na.rm = FALSE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] 2 6 10 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s num [1:4] 1 2 3 4 217s num [1:4] 1 2 3 4 217s num [1:4] 1 2 3 4 217s max: 217s num [1:4] 9 10 11 12 217s num [1:4] 9 10 11 12 217s num [1:4] 9 10 11 12 217s range: 217s num [1:4, 1:2] 1 2 3 4 9 10 11 12 217s num [1:4, 1:2] 1 2 3 4 9 10 11 12 217s num [1:4, 1:2] 1 2 3 4 9 10 11 12 217s real w/ NA (double) w/ na.rm = FALSE: 217s [,1] [,2] [,3] 217s [1,] NA NA NA 217s [2,] NA NA NA 217s [3,] NA NA NA 217s [4,] NA NA NA 217s min: 217s num [1:4] NA NA NA NA 217s num [1:4] NA NA NA NA 217s num [1:4] NA NA NA NA 217s max: 217s num [1:4] NA NA NA NA 217s num [1:4] NA NA NA NA 217s num [1:4] NA NA NA NA 217s range: 217s num [1:4, 1:2] NA NA NA NA NA NA NA NA 217s num [1:4, 1:2] NA NA NA NA NA NA NA NA 217s num [1:4, 1:2] NA NA NA NA NA NA NA NA 217s real w/ NA (double) w/ na.rm = FALSE: 217s [,1] [,2] [,3] 217s [1,] NA NA NA 217s [2,] NA NA NA 217s [3,] NA NA NA 217s [4,] NA NA NA 217s min: 217s num [1:4] NA NA NA NA 217s num [1:4] NA NA NA NA 217s num [1:4] NA NA NA NA 217s max: 217s num [1:4] NA NA NA NA 217s num [1:4] NA NA NA NA 217s num [1:4] NA NA NA NA 217s range: 217s num [1:4, 1:2] NA NA NA NA NA NA NA NA 217s num [1:4, 1:2] NA NA NA NA NA NA NA NA 217s num [1:4, 1:2] NA NA NA NA NA NA NA NA 217s real + NA cell (double) w/ na.rm = FALSE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] 2 NA 10 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s num [1:4] 1 NA 3 4 217s num [1:4] 1 NA 3 4 217s num [1:4] 1 NA 3 4 217s max: 217s num [1:4] 9 NA 11 12 217s num [1:4] 9 NA 11 12 217s num [1:4] 9 NA 11 12 217s range: 217s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 217s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 217s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 217s real + NA cell (double) w/ na.rm = FALSE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] 2 NA 10 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s num [1:4] 1 NA 3 4 217s num [1:4] 1 NA 3 4 217s num [1:4] 1 NA 3 4 217s max: 217s num [1:4] 9 NA 11 12 217s num [1:4] 9 NA 11 12 217s num [1:4] 9 NA 11 12 217s range: 217s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 217s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 217s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 217s real + NA row (double) w/ na.rm = FALSE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] NA NA NA 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s num [1:4] 1 NA 3 4 217s num [1:4] 1 NA 3 4 217s num [1:4] 1 NA 3 4 217s max: 217s num [1:4] 9 NA 11 12 217s num [1:4] 9 NA 11 12 217s num [1:4] 9 NA 11 12 217s range: 217s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 217s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 217s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 217s real + NA row (double) w/ na.rm = FALSE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] NA NA NA 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s num [1:4] 1 NA 3 4 217s num [1:4] 1 NA 3 4 217s num [1:4] 1 NA 3 4 217s max: 217s num [1:4] 9 NA 11 12 217s num [1:4] 9 NA 11 12 217s num [1:4] 9 NA 11 12 217s range: 217s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 217s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 217s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 217s real + NaN row (double) w/ na.rm = FALSE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] NaN NaN NaN 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s num [1:4] 1 NaN 3 4 217s num [1:4] 1 NaN 3 4 217s num [1:4] 1 NaN 3 4 217s max: 217s num [1:4] 9 NaN 11 12 217s num [1:4] 9 NaN 11 12 217s num [1:4] 9 NaN 11 12 217s range: 217s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 217s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 217s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 217s real + NaN row (double) w/ na.rm = FALSE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] NaN NaN NaN 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s num [1:4] 1 NaN 3 4 217s num [1:4] 1 NaN 3 4 217s num [1:4] 1 NaN 3 4 217s max: 217s num [1:4] 9 NaN 11 12 217s num [1:4] 9 NaN 11 12 217s num [1:4] 9 NaN 11 12 217s range: 217s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 217s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 217s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 217s real + Inf cell (double) w/ na.rm = FALSE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] 2 Inf 10 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s num [1:4] 1 2 3 4 217s num [1:4] 1 2 3 4 217s num [1:4] 1 2 3 4 217s max: 217s num [1:4] 9 Inf 11 12 217s num [1:4] 9 Inf 11 12 217s num [1:4] 9 Inf 11 12 217s range: 217s num [1:4, 1:2] 1 2 3 4 9 ... 217s num [1:4, 1:2] 1 2 3 4 9 ... 217s num [1:4, 1:2] 1 2 3 4 9 ... 217s real + Inf cell (double) w/ na.rm = FALSE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] 2 Inf 10 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s num [1:4] 1 2 3 4 217s num [1:4] 1 2 3 4 217s num [1:4] 1 2 3 4 217s max: 217s num [1:4] 9 Inf 11 12 217s num [1:4] 9 Inf 11 12 217s num [1:4] 9 Inf 11 12 217s range: 217s num [1:4, 1:2] 1 2 3 4 9 ... 217s num [1:4, 1:2] 1 2 3 4 9 ... 217s num [1:4, 1:2] 1 2 3 4 9 ... 217s real + Inf row (double) w/ na.rm = FALSE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] Inf Inf Inf 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s num [1:4] 1 Inf 3 4 217s num [1:4] 1 Inf 3 4 217s num [1:4] 1 Inf 3 4 217s max: 217s num [1:4] 9 Inf 11 12 217s num [1:4] 9 Inf 11 12 217s num [1:4] 9 Inf 11 12 217s range: 217s num [1:4, 1:2] 1 Inf 3 4 9 ... 217s num [1:4, 1:2] 1 Inf 3 4 9 ... 217s num [1:4, 1:2] 1 Inf 3 4 9 ... 217s real + Inf row (double) w/ na.rm = FALSE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] Inf Inf Inf 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s num [1:4] 1 Inf 3 4 217s num [1:4] 1 Inf 3 4 217s num [1:4] 1 Inf 3 4 217s max: 217s num [1:4] 9 Inf 11 12 217s num [1:4] 9 Inf 11 12 217s num [1:4] 9 Inf 11 12 217s range: 217s num [1:4, 1:2] 1 Inf 3 4 9 ... 217s num [1:4, 1:2] 1 Inf 3 4 9 ... 217s num [1:4, 1:2] 1 Inf 3 4 9 ... 217s real + NaN cell (double) w/ na.rm = FALSE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] 2 NaN 10 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s num [1:4] 1 NaN 3 4 217s num [1:4] 1 NaN 3 4 217s num [1:4] 1 NaN 3 4 217s max: 217s num [1:4] 9 NaN 11 12 217s num [1:4] 9 NaN 11 12 217s num [1:4] 9 NaN 11 12 217s range: 217s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 217s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 217s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 217s real + NaN cell (double) w/ na.rm = FALSE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] 2 NaN 10 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s num [1:4] 1 NaN 3 4 217s num [1:4] 1 NaN 3 4 217s num [1:4] 1 NaN 3 4 217s max: 217s num [1:4] 9 NaN 11 12 217s num [1:4] 9 NaN 11 12 217s num [1:4] 9 NaN 11 12 217s range: 217s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 217s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 217s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 217s real w/ NA + NaN cell (double) w/ na.rm = FALSE: 217s [,1] [,2] [,3] 217s [1,] NA NA NA 217s [2,] NA NaN NA 217s [3,] NA NA NA 217s [4,] NA NA NA 217s min: 217s num [1:4] NA NA NA NA 217s num [1:4] NA NA NA NA 217s num [1:4] NA NA NA NA 217s max: 217s num [1:4] NA NA NA NA 217s num [1:4] NA NA NA NA 217s num [1:4] NA NA NA NA 217s range: 217s num [1:4, 1:2] NA NA NA NA NA NA NA NA 217s num [1:4, 1:2] NA NA NA NA NA NA NA NA 217s num [1:4, 1:2] NA NA NA NA NA NA NA NA 217s real w/ NA + NaN cell (double) w/ na.rm = FALSE: 217s [,1] [,2] [,3] 217s [1,] NA NA NA 217s [2,] NA NaN NA 217s [3,] NA NA NA 217s [4,] NA NA NA 217s min: 217s num [1:4] NA NA NA NA 217s num [1:4] NA NA NA NA 217s num [1:4] NA NA NA NA 217s max: 217s num [1:4] NA NA NA NA 217s num [1:4] NA NA NA NA 217s num [1:4] NA NA NA NA 217s range: 217s num [1:4, 1:2] NA NA NA NA NA NA NA NA 217s num [1:4, 1:2] NA NA NA NA NA NA NA NA 217s num [1:4, 1:2] NA NA NA NA NA NA NA NA 217s real w/ NA + NaN row (double) w/ na.rm = FALSE: 217s [,1] [,2] [,3] 217s [1,] NA NA NA 217s [2,] NaN NaN NaN 217s [3,] NA NA NA 217s [4,] NA NA NA 217s min: 217s num [1:4] NA NaN NA NA 217s num [1:4] NA NaN NA NA 217s num [1:4] NA NaN NA NA 217s max: 217s num [1:4] NA NaN NA NA 217s num [1:4] NA NaN NA NA 217s num [1:4] NA NaN NA NA 217s range: 217s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 217s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 217s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 217s real w/ NA + NaN row (double) w/ na.rm = FALSE: 217s [,1] [,2] [,3] 217s [1,] NA NA NA 217s [2,] NaN NaN NaN 217s [3,] NA NA NA 217s [4,] NA NA NA 217s min: 217s num [1:4] NA NaN NA NA 217s num [1:4] NA NaN NA NA 217s num [1:4] NA NaN NA NA 217s max: 217s num [1:4] NA NaN NA NA 217s num [1:4] NA NaN NA NA 217s num [1:4] NA NaN NA NA 217s range: 217s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 217s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 217s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 217s integer (integer) w/ na.rm = TRUE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] 2 6 10 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s int [1:4] 1 2 3 4 217s int [1:4] 1 2 3 4 217s int [1:4] 1 2 3 4 217s max: 217s int [1:4] 9 10 11 12 217s int [1:4] 9 10 11 12 217s int [1:4] 9 10 11 12 217s range: 217s int [1:4, 1:2] 1 2 3 4 9 10 11 12 217s int [1:4, 1:2] 1 2 3 4 9 10 11 12 217s int [1:4, 1:2] 1 2 3 4 9 10 11 12 217s integer (integer) w/ na.rm = TRUE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] 2 6 10 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s int [1:4] 1 2 3 4 217s int [1:4] 1 2 3 4 217s int [1:4] 1 2 3 4 217s max: 217s int [1:4] 9 10 11 12 217s int [1:4] 9 10 11 12 217s int [1:4] 9 10 11 12 217s range: 217s int [1:4, 1:2] 1 2 3 4 9 10 11 12 217s int [1:4, 1:2] 1 2 3 4 9 10 11 12 217s int [1:4, 1:2] 1 2 3 4 9 10 11 12 217s integer w/ NA (integer) w/ na.rm = TRUE: 217s [,1] [,2] [,3] 217s [1,] NA NA NA 217s [2,] NA NA NA 217s [3,] NA NA NA 217s [4,] NA NA NA 217s min: 217s num [1:4] Inf Inf Inf Inf 217s num [1:4] Inf Inf Inf Inf 217s num [1:4] Inf Inf Inf Inf 217s max: 217s num [1:4] -Inf -Inf -Inf -Inf 217s num [1:4] -Inf -Inf -Inf -Inf 217s num [1:4] -Inf -Inf -Inf -Inf 217s range: 217s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 217s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 217s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 217s integer w/ NA (integer) w/ na.rm = TRUE: 217s [,1] [,2] [,3] 217s [1,] NA NA NA 217s [2,] NA NA NA 217s [3,] NA NA NA 217s [4,] NA NA NA 217s min: 217s num [1:4] Inf Inf Inf Inf 217s num [1:4] Inf Inf Inf Inf 217s num [1:4] Inf Inf Inf Inf 217s max: 217s num [1:4] -Inf -Inf -Inf -Inf 217s num [1:4] -Inf -Inf -Inf -Inf 217s num [1:4] -Inf -Inf -Inf -Inf 217s range: 217s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 217s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 217s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 217s real (double) w/ na.rm = TRUE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] 2 6 10 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s num [1:4] 1 2 3 4 217s num [1:4] 1 2 3 4 217s num [1:4] 1 2 3 4 217s max: 217s num [1:4] 9 10 11 12 217s num [1:4] 9 10 11 12 217s num [1:4] 9 10 11 12 217s range: 217s num [1:4, 1:2] 1 2 3 4 9 10 11 12 217s num [1:4, 1:2] 1 2 3 4 9 10 11 12 217s num [1:4, 1:2] 1 2 3 4 9 10 11 12 217s real (double) w/ na.rm = TRUE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] 2 6 10 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s num [1:4] 1 2 3 4 217s num [1:4] 1 2 3 4 217s num [1:4] 1 2 3 4 217s max: 217s num [1:4] 9 10 11 12 217s num [1:4] 9 10 11 12 217s num [1:4] 9 10 11 12 217s range: 217s num [1:4, 1:2] 1 2 3 4 9 10 11 12 217s num [1:4, 1:2] 1 2 3 4 9 10 11 12 217s num [1:4, 1:2] 1 2 3 4 9 10 11 12 217s real w/ NA (double) w/ na.rm = TRUE: 217s [,1] [,2] [,3] 217s [1,] NA NA NA 217s [2,] NA NA NA 217s [3,] NA NA NA 217s [4,] NA NA NA 217s min: 217s num [1:4] Inf Inf Inf Inf 217s num [1:4] Inf Inf Inf Inf 217s num [1:4] Inf Inf Inf Inf 217s max: 217s num [1:4] -Inf -Inf -Inf -Inf 217s num [1:4] -Inf -Inf -Inf -Inf 217s num [1:4] -Inf -Inf -Inf -Inf 217s range: 217s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 217s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 217s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 217s real w/ NA (double) w/ na.rm = TRUE: 217s [,1] [,2] [,3] 217s [1,] NA NA NA 217s [2,] NA NA NA 217s [3,] NA NA NA 217s [4,] NA NA NA 217s min: 217s num [1:4] Inf Inf Inf Inf 217s num [1:4] Inf Inf Inf Inf 217s num [1:4] Inf Inf Inf Inf 217s max: 217s num [1:4] -Inf -Inf -Inf -Inf 217s num [1:4] -Inf -Inf -Inf -Inf 217s num [1:4] -Inf -Inf -Inf -Inf 217s range: 217s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 217s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 217s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 217s real + NA cell (double) w/ na.rm = TRUE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] 2 NA 10 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s num [1:4] 1 2 3 4 217s num [1:4] 1 2 3 4 217s num [1:4] 1 2 3 4 217s max: 217s num [1:4] 9 10 11 12 217s num [1:4] 9 10 11 12 217s num [1:4] 9 10 11 12 217s range: 217s num [1:4, 1:2] 1 2 3 4 9 10 11 12 217s num [1:4, 1:2] 1 2 3 4 9 10 11 12 217s num [1:4, 1:2] 1 2 3 4 9 10 11 12 217s real + NA cell (double) w/ na.rm = TRUE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] 2 NA 10 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s num [1:4] 1 2 3 4 217s num [1:4] 1 2 3 4 217s num [1:4] 1 2 3 4 217s max: 217s num [1:4] 9 10 11 12 217s num [1:4] 9 10 11 12 217s num [1:4] 9 10 11 12 217s range: 217s num [1:4, 1:2] 1 2 3 4 9 10 11 12 217s num [1:4, 1:2] 1 2 3 4 9 10 11 12 217s num [1:4, 1:2] 1 2 3 4 9 10 11 12 217s real + NA row (double) w/ na.rm = TRUE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] NA NA NA 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s num [1:4] 1 Inf 3 4 217s num [1:4] 1 Inf 3 4 217s num [1:4] 1 Inf 3 4 217s max: 217s num [1:4] 9 -Inf 11 12 217s num [1:4] 9 -Inf 11 12 217s num [1:4] 9 -Inf 11 12 217s range: 217s num [1:4, 1:2] 1 Inf 3 4 9 ... 217s num [1:4, 1:2] 1 Inf 3 4 9 ... 217s num [1:4, 1:2] 1 Inf 3 4 9 ... 217s real + NA row (double) w/ na.rm = TRUE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] NA NA NA 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s num [1:4] 1 Inf 3 4 217s num [1:4] 1 Inf 3 4 217s num [1:4] 1 Inf 3 4 217s max: 217s num [1:4] 9 -Inf 11 12 217s num [1:4] 9 -Inf 11 12 217s num [1:4] 9 -Inf 11 12 217s range: 217s num [1:4, 1:2] 1 Inf 3 4 9 ... 217s num [1:4, 1:2] 1 Inf 3 4 9 ... 217s num [1:4, 1:2] 1 Inf 3 4 9 ... 217s real + NaN row (double) w/ na.rm = TRUE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] NaN NaN NaN 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s num [1:4] 1 Inf 3 4 217s num [1:4] 1 Inf 3 4 217s num [1:4] 1 Inf 3 4 217s max: 217s num [1:4] 9 -Inf 11 12 217s num [1:4] 9 -Inf 11 12 217s num [1:4] 9 -Inf 11 12 217s range: 217s num [1:4, 1:2] 1 Inf 3 4 9 ... 217s num [1:4, 1:2] 1 Inf 3 4 9 ... 217s num [1:4, 1:2] 1 Inf 3 4 9 ... 217s real + NaN row (double) w/ na.rm = TRUE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] NaN NaN NaN 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s num [1:4] 1 Inf 3 4 217s num [1:4] 1 Inf 3 4 217s num [1:4] 1 Inf 3 4 217s max: 217s num [1:4] 9 -Inf 11 12 217s num [1:4] 9 -Inf 11 12 217s num [1:4] 9 -Inf 11 12 217s range: 217s num [1:4, 1:2] 1 Inf 3 4 9 ... 217s num [1:4, 1:2] 1 Inf 3 4 9 ... 217s num [1:4, 1:2] 1 Inf 3 4 9 ... 217s real + Inf cell (double) w/ na.rm = TRUE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] 2 Inf 10 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s num [1:4] 1 2 3 4 217s num [1:4] 1 2 3 4 217s num [1:4] 1 2 3 4 217s max: 217s num [1:4] 9 Inf 11 12 217s num [1:4] 9 Inf 11 12 217s num [1:4] 9 Inf 11 12 217s range: 217s num [1:4, 1:2] 1 2 3 4 9 ... 217s num [1:4, 1:2] 1 2 3 4 9 ... 217s num [1:4, 1:2] 1 2 3 4 9 ... 217s real + Inf cell (double) w/ na.rm = TRUE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] 2 Inf 10 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s num [1:4] 1 2 3 4 217s num [1:4] 1 2 3 4 217s num [1:4] 1 2 3 4 217s max: 217s num [1:4] 9 Inf 11 12 217s num [1:4] 9 Inf 11 12 217s num [1:4] 9 Inf 11 12 217s range: 217s num [1:4, 1:2] 1 2 3 4 9 ... 217s num [1:4, 1:2] 1 2 3 4 9 ... 217s num [1:4, 1:2] 1 2 3 4 9 ... 217s real + Inf row (double) w/ na.rm = TRUE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] Inf Inf Inf 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s num [1:4] 1 Inf 3 4 217s num [1:4] 1 Inf 3 4 217s num [1:4] 1 Inf 3 4 217s max: 217s num [1:4] 9 Inf 11 12 217s num [1:4] 9 Inf 11 12 217s num [1:4] 9 Inf 11 12 217s range: 217s num [1:4, 1:2] 1 Inf 3 4 9 ... 217s num [1:4, 1:2] 1 Inf 3 4 9 ... 217s num [1:4, 1:2] 1 Inf 3 4 9 ... 217s real + Inf row (double) w/ na.rm = TRUE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] Inf Inf Inf 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s num [1:4] 1 Inf 3 4 217s num [1:4] 1 Inf 3 4 217s num [1:4] 1 Inf 3 4 217s max: 217s num [1:4] 9 Inf 11 12 217s num [1:4] 9 Inf 11 12 217s num [1:4] 9 Inf 11 12 217s range: 217s num [1:4, 1:2] 1 Inf 3 4 9 ... 217s num [1:4, 1:2] 1 Inf 3 4 9 ... 217s num [1:4, 1:2] 1 Inf 3 4 9 ... 217s real + NaN cell (double) w/ na.rm = TRUE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] 2 NaN 10 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s num [1:4] 1 2 3 4 217s num [1:4] 1 2 3 4 217s num [1:4] 1 2 3 4 217s max: 217s num [1:4] 9 10 11 12 217s num [1:4] 9 10 11 12 217s num [1:4] 9 10 11 12 217s range: 217s num [1:4, 1:2] 1 2 3 4 9 10 11 12 217s num [1:4, 1:2] 1 2 3 4 9 10 11 12 217s num [1:4, 1:2] 1 2 3 4 9 10 11 12 217s real + NaN cell (double) w/ na.rm = TRUE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] 2 NaN 10 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s num [1:4] 1 2 3 4 217s num [1:4] 1 2 3 4 217s num [1:4] 1 2 3 4 217s max: 217s num [1:4] 9 10 11 12 217s num [1:4] 9 10 11 12 217s num [1:4] 9 10 11 12 217s range: 217s num [1:4, 1:2] 1 2 3 4 9 10 11 12 217s num [1:4, 1:2] 1 2 3 4 9 10 11 12 217s num [1:4, 1:2] 1 2 3 4 9 10 11 12 217s real w/ NA + NaN cell (double) w/ na.rm = TRUE: 217s [,1] [,2] [,3] 217s [1,] NA NA NA 217s [2,] NA NaN NA 217s [3,] NA NA NA 217s [4,] NA NA NA 217s min: 217s num [1:4] Inf Inf Inf Inf 217s num [1:4] Inf Inf Inf Inf 217s num [1:4] Inf Inf Inf Inf 217s max: 217s num [1:4] -Inf -Inf -Inf -Inf 217s num [1:4] -Inf -Inf -Inf -Inf 217s num [1:4] -Inf -Inf -Inf -Inf 217s range: 217s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 217s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 217s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 217s real w/ NA + NaN cell (double) w/ na.rm = TRUE: 217s [,1] [,2] [,3] 217s [1,] NA NA NA 217s [2,] NA NaN NA 217s [3,] NA NA NA 217s [4,] NA NA NA 217s min: 217s num [1:4] Inf Inf Inf Inf 217s num [1:4] Inf Inf Inf Inf 217s num [1:4] Inf Inf Inf Inf 217s max: 217s num [1:4] -Inf -Inf -Inf -Inf 217s num [1:4] -Inf -Inf -Inf -Inf 217s num [1:4] -Inf -Inf -Inf -Inf 217s range: 217s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 217s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 217s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 217s real w/ NA + NaN row (double) w/ na.rm = TRUE: 217s [,1] [,2] [,3] 217s [1,] NA NA NA 217s [2,] NaN NaN NaN 217s [3,] NA NA NA 217s [4,] NA NA NA 217s min: 217s num [1:4] Inf Inf Inf Inf 217s num [1:4] Inf Inf Inf Inf 217s num [1:4] Inf Inf Inf Inf 217s max: 217s num [1:4] -Inf -Inf -Inf -Inf 217s num [1:4] -Inf -Inf -Inf -Inf 217s num [1:4] -Inf -Inf -Inf -Inf 217s range: 217s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 217s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 217s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 217s real w/ NA + NaN row (double) w/ na.rm = TRUE: 217s [,1] [,2] [,3] 217s [1,] NA NA NA 217s [2,] NaN NaN NaN 217s [3,] NA NA NA 217s [4,] NA NA NA 217s min: 217s num [1:4] Inf Inf Inf Inf 217s num [1:4] Inf Inf Inf Inf 217s num [1:4] Inf Inf Inf Inf 217s max: 217s num [1:4] -Inf -Inf -Inf -Inf 217s num [1:4] -Inf -Inf -Inf -Inf 217s num [1:4] -Inf -Inf -Inf -Inf 217s range: 217s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 217s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 217s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 217s integer (integer) w/ na.rm = FALSE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] 2 6 10 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s int [1:4] 1 2 3 4 217s int [1:4] 1 2 3 4 217s int [1:4] 1 2 3 4 217s max: 217s int [1:4] 9 10 11 12 217s int [1:4] 9 10 11 12 217s int [1:4] 9 10 11 12 217s range: 217s int [1:4, 1:2] 1 2 3 4 9 10 11 12 217s int [1:4, 1:2] 1 2 3 4 9 10 11 12 217s int [1:4, 1:2] 1 2 3 4 9 10 11 12 217s integer (integer) w/ na.rm = FALSE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] 2 6 10 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s int [1:4] 1 2 3 4 217s int [1:4] 1 2 3 4 217s int [1:4] 1 2 3 4 217s max: 217s int [1:4] 9 10 11 12 217s int [1:4] 9 10 11 12 217s int [1:4] 9 10 11 12 217s range: 217s int [1:4, 1:2] 1 2 3 4 9 10 11 12 217s int [1:4, 1:2] 1 2 3 4 9 10 11 12 217s int [1:4, 1:2] 1 2 3 4 9 10 11 12 217s integer w/ NA (integer) w/ na.rm = FALSE: 217s [,1] [,2] [,3] 217s [1,] NA NA NA 217s [2,] NA NA NA 217s [3,] NA NA NA 217s [4,] NA NA NA 217s min: 217s int [1:4] NA NA NA NA 217s int [1:4] NA NA NA NA 217s int [1:4] NA NA NA NA 217s max: 217s int [1:4] NA NA NA NA 217s int [1:4] NA NA NA NA 217s int [1:4] NA NA NA NA 217s range: 217s int [1:4, 1:2] NA NA NA NA NA NA NA NA 217s int [1:4, 1:2] NA NA NA NA NA NA NA NA 217s int [1:4, 1:2] NA NA NA NA NA NA NA NA 217s integer w/ NA (integer) w/ na.rm = FALSE: 217s [,1] [,2] [,3] 217s [1,] NA NA NA 217s [2,] NA NA NA 217s [3,] NA NA NA 217s [4,] NA NA NA 217s min: 217s int [1:4] NA NA NA NA 217s int [1:4] NA NA NA NA 217s int [1:4] NA NA NA NA 217s max: 217s int [1:4] NA NA NA NA 217s int [1:4] NA NA NA NA 217s int [1:4] NA NA NA NA 217s range: 217s int [1:4, 1:2] NA NA NA NA NA NA NA NA 217s int [1:4, 1:2] NA NA NA NA NA NA NA NA 217s int [1:4, 1:2] NA NA NA NA NA NA NA NA 217s real (double) w/ na.rm = FALSE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] 2 6 10 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s num [1:4] 1 2 3 4 217s num [1:4] 1 2 3 4 217s num [1:4] 1 2 3 4 217s max: 217s num [1:4] 9 10 11 12 217s num [1:4] 9 10 11 12 217s num [1:4] 9 10 11 12 217s range: 217s num [1:4, 1:2] 1 2 3 4 9 10 11 12 217s num [1:4, 1:2] 1 2 3 4 9 10 11 12 217s num [1:4, 1:2] 1 2 3 4 9 10 11 12 217s real (double) w/ na.rm = FALSE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] 2 6 10 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s num [1:4] 1 2 3 4 217s num [1:4] 1 2 3 4 217s num [1:4] 1 2 3 4 217s max: 217s num [1:4] 9 10 11 12 217s num [1:4] 9 10 11 12 217s num [1:4] 9 10 11 12 217s range: 217s num [1:4, 1:2] 1 2 3 4 9 10 11 12 217s num [1:4, 1:2] 1 2 3 4 9 10 11 12 217s num [1:4, 1:2] 1 2 3 4 9 10 11 12 217s real w/ NA (double) w/ na.rm = FALSE: 217s [,1] [,2] [,3] 217s [1,] NA NA NA 217s [2,] NA NA NA 217s [3,] NA NA NA 217s [4,] NA NA NA 217s min: 217s num [1:4] NA NA NA NA 217s num [1:4] NA NA NA NA 217s num [1:4] NA NA NA NA 217s max: 217s num [1:4] NA NA NA NA 217s num [1:4] NA NA NA NA 217s num [1:4] NA NA NA NA 217s range: 217s num [1:4, 1:2] NA NA NA NA NA NA NA NA 217s num [1:4, 1:2] NA NA NA NA NA NA NA NA 217s num [1:4, 1:2] NA NA NA NA NA NA NA NA 217s real w/ NA (double) w/ na.rm = FALSE: 217s [,1] [,2] [,3] 217s [1,] NA NA NA 217s [2,] NA NA NA 217s [3,] NA NA NA 217s [4,] NA NA NA 217s min: 217s num [1:4] NA NA NA NA 217s num [1:4] NA NA NA NA 217s num [1:4] NA NA NA NA 217s max: 217s num [1:4] NA NA NA NA 217s num [1:4] NA NA NA NA 217s num [1:4] NA NA NA NA 217s range: 217s num [1:4, 1:2] NA NA NA NA NA NA NA NA 217s num [1:4, 1:2] NA NA NA NA NA NA NA NA 217s num [1:4, 1:2] NA NA NA NA NA NA NA NA 217s real + NA cell (double) w/ na.rm = FALSE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] 2 NA 10 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s num [1:4] 1 NA 3 4 217s num [1:4] 1 NA 3 4 217s num [1:4] 1 NA 3 4 217s max: 217s num [1:4] 9 NA 11 12 217s num [1:4] 9 NA 11 12 217s num [1:4] 9 NA 11 12 217s range: 217s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 217s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 217s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 217s real + NA cell (double) w/ na.rm = FALSE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] 2 NA 10 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s num [1:4] 1 NA 3 4 217s num [1:4] 1 NA 3 4 217s num [1:4] 1 NA 3 4 217s max: 217s num [1:4] 9 NA 11 12 217s num [1:4] 9 NA 11 12 217s num [1:4] 9 NA 11 12 217s range: 217s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 217s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 217s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 217s real + NA row (double) w/ na.rm = FALSE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] NA NA NA 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s num [1:4] 1 NA 3 4 217s num [1:4] 1 NA 3 4 217s num [1:4] 1 NA 3 4 217s max: 217s num [1:4] 9 NA 11 12 217s num [1:4] 9 NA 11 12 217s num [1:4] 9 NA 11 12 217s range: 217s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 217s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 217s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 217s real + NA row (double) w/ na.rm = FALSE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] NA NA NA 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s num [1:4] 1 NA 3 4 217s num [1:4] 1 NA 3 4 217s num [1:4] 1 NA 3 4 217s max: 217s num [1:4] 9 NA 11 12 217s num [1:4] 9 NA 11 12 217s num [1:4] 9 NA 11 12 217s range: 217s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 217s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 217s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 217s real + NaN row (double) w/ na.rm = FALSE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] NaN NaN NaN 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s num [1:4] 1 NaN 3 4 217s num [1:4] 1 NaN 3 4 217s num [1:4] 1 NaN 3 4 217s max: 217s num [1:4] 9 NaN 11 12 217s num [1:4] 9 NaN 11 12 217s num [1:4] 9 NaN 11 12 217s range: 217s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 217s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 217s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 217s real + NaN row (double) w/ na.rm = FALSE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] NaN NaN NaN 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s num [1:4] 1 NaN 3 4 217s num [1:4] 1 NaN 3 4 217s num [1:4] 1 NaN 3 4 217s max: 217s num [1:4] 9 NaN 11 12 217s num [1:4] 9 NaN 11 12 217s num [1:4] 9 NaN 11 12 217s range: 217s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 217s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 217s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 217s real + Inf cell (double) w/ na.rm = FALSE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] 2 Inf 10 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s num [1:4] 1 2 3 4 217s num [1:4] 1 2 3 4 217s num [1:4] 1 2 3 4 217s max: 217s num [1:4] 9 Inf 11 12 217s num [1:4] 9 Inf 11 12 217s num [1:4] 9 Inf 11 12 217s range: 217s num [1:4, 1:2] 1 2 3 4 9 ... 217s num [1:4, 1:2] 1 2 3 4 9 ... 217s num [1:4, 1:2] 1 2 3 4 9 ... 217s real + Inf cell (double) w/ na.rm = FALSE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] 2 Inf 10 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s num [1:4] 1 2 3 4 217s num [1:4] 1 2 3 4 217s num [1:4] 1 2 3 4 217s max: 217s num [1:4] 9 Inf 11 12 217s num [1:4] 9 Inf 11 12 217s num [1:4] 9 Inf 11 12 217s range: 217s num [1:4, 1:2] 1 2 3 4 9 ... 217s num [1:4, 1:2] 1 2 3 4 9 ... 217s num [1:4, 1:2] 1 2 3 4 9 ... 217s real + Inf row (double) w/ na.rm = FALSE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] Inf Inf Inf 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s num [1:4] 1 Inf 3 4 217s num [1:4] 1 Inf 3 4 217s num [1:4] 1 Inf 3 4 217s max: 217s num [1:4] 9 Inf 11 12 217s num [1:4] 9 Inf 11 12 217s num [1:4] 9 Inf 11 12 217s range: 217s num [1:4, 1:2] 1 Inf 3 4 9 ... 217s num [1:4, 1:2] 1 Inf 3 4 9 ... 217s num [1:4, 1:2] 1 Inf 3 4 9 ... 217s real + Inf row (double) w/ na.rm = FALSE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] Inf Inf Inf 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s num [1:4] 1 Inf 3 4 217s num [1:4] 1 Inf 3 4 217s num [1:4] 1 Inf 3 4 217s max: 217s num [1:4] 9 Inf 11 12 217s num [1:4] 9 Inf 11 12 217s num [1:4] 9 Inf 11 12 217s range: 217s num [1:4, 1:2] 1 Inf 3 4 9 ... 217s num [1:4, 1:2] 1 Inf 3 4 9 ... 217s num [1:4, 1:2] 1 Inf 3 4 9 ... 217s real + NaN cell (double) w/ na.rm = FALSE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] 2 NaN 10 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s num [1:4] 1 NaN 3 4 217s num [1:4] 1 NaN 3 4 217s num [1:4] 1 NaN 3 4 217s max: 217s num [1:4] 9 NaN 11 12 217s num [1:4] 9 NaN 11 12 217s num [1:4] 9 NaN 11 12 217s range: 217s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 217s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 217s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 217s real + NaN cell (double) w/ na.rm = FALSE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] 2 NaN 10 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s num [1:4] 1 NaN 3 4 217s num [1:4] 1 NaN 3 4 217s num [1:4] 1 NaN 3 4 217s max: 217s num [1:4] 9 NaN 11 12 217s num [1:4] 9 NaN 11 12 217s num [1:4] 9 NaN 11 12 217s range: 217s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 217s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 217s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 217s real w/ NA + NaN cell (double) w/ na.rm = FALSE: 217s [,1] [,2] [,3] 217s [1,] NA NA NA 217s [2,] NA NaN NA 217s [3,] NA NA NA 217s [4,] NA NA NA 217s min: 217s num [1:4] NA NA NA NA 217s num [1:4] NA NA NA NA 217s num [1:4] NA NA NA NA 217s max: 217s num [1:4] NA NA NA NA 217s num [1:4] NA NA NA NA 217s num [1:4] NA NA NA NA 217s range: 217s num [1:4, 1:2] NA NA NA NA NA NA NA NA 217s num [1:4, 1:2] NA NA NA NA NA NA NA NA 217s num [1:4, 1:2] NA NA NA NA NA NA NA NA 217s real w/ NA + NaN cell (double) w/ na.rm = FALSE: 217s [,1] [,2] [,3] 217s [1,] NA NA NA 217s [2,] NA NaN NA 217s [3,] NA NA NA 217s [4,] NA NA NA 217s min: 217s num [1:4] NA NA NA NA 217s num [1:4] NA NA NA NA 217s num [1:4] NA NA NA NA 217s max: 217s num [1:4] NA NA NA NA 217s num [1:4] NA NA NA NA 217s num [1:4] NA NA NA NA 217s range: 217s num [1:4, 1:2] NA NA NA NA NA NA NA NA 217s num [1:4, 1:2] NA NA NA NA NA NA NA NA 217s num [1:4, 1:2] NA NA NA NA NA NA NA NA 217s real w/ NA + NaN row (double) w/ na.rm = FALSE: 217s [,1] [,2] [,3] 217s [1,] NA NA NA 217s [2,] NaN NaN NaN 217s [3,] NA NA NA 217s [4,] NA NA NA 217s min: 217s num [1:4] NA NaN NA NA 217s num [1:4] NA NaN NA NA 217s num [1:4] NA NaN NA NA 217s max: 217s num [1:4] NA NaN NA NA 217s num [1:4] NA NaN NA NA 217s num [1:4] NA NaN NA NA 217s range: 217s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 217s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 217s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 217s real w/ NA + NaN row (double) w/ na.rm = FALSE: 217s [,1] [,2] [,3] 217s [1,] NA NA NA 217s [2,] NaN NaN NaN 217s [3,] NA NA NA 217s [4,] NA NA NA 217s min: 217s num [1:4] NA NaN NA NA 217s num [1:4] NA NaN NA NA 217s num [1:4] NA NaN NA NA 217s max: 217s num [1:4] NA NaN NA NA 217s num [1:4] NA NaN NA NA 217s num [1:4] NA NaN NA NA 217s range: 217s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 217s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 217s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 217s integer (integer) w/ na.rm = TRUE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] 2 6 10 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s int [1:4] 1 2 3 4 217s int [1:4] 1 2 3 4 217s int [1:4] 1 2 3 4 217s max: 217s int [1:4] 9 10 11 12 217s int [1:4] 9 10 11 12 217s int [1:4] 9 10 11 12 217s range: 217s int [1:4, 1:2] 1 2 3 4 9 10 11 12 217s int [1:4, 1:2] 1 2 3 4 9 10 11 12 217s int [1:4, 1:2] 1 2 3 4 9 10 11 12 217s integer (integer) w/ na.rm = TRUE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] 2 6 10 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s int [1:4] 1 2 3 4 217s int [1:4] 1 2 3 4 217s int [1:4] 1 2 3 4 217s max: 217s int [1:4] 9 10 11 12 217s int [1:4] 9 10 11 12 217s int [1:4] 9 10 11 12 217s range: 217s int [1:4, 1:2] 1 2 3 4 9 10 11 12 217s int [1:4, 1:2] 1 2 3 4 9 10 11 12 217s int [1:4, 1:2] 1 2 3 4 9 10 11 12 217s integer w/ NA (integer) w/ na.rm = TRUE: 217s [,1] [,2] [,3] 217s [1,] NA NA NA 217s [2,] NA NA NA 217s [3,] NA NA NA 217s [4,] NA NA NA 217s min: 217s num [1:4] Inf Inf Inf Inf 217s num [1:4] Inf Inf Inf Inf 217s num [1:4] Inf Inf Inf Inf 217s max: 217s num [1:4] -Inf -Inf -Inf -Inf 217s num [1:4] -Inf -Inf -Inf -Inf 217s num [1:4] -Inf -Inf -Inf -Inf 217s range: 217s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 217s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 217s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 217s integer w/ NA (integer) w/ na.rm = TRUE: 217s [,1] [,2] [,3] 217s [1,] NA NA NA 217s [2,] NA NA NA 217s [3,] NA NA NA 217s [4,] NA NA NA 217s min: 217s num [1:4] Inf Inf Inf Inf 217s num [1:4] Inf Inf Inf Inf 217s num [1:4] Inf Inf Inf Inf 217s max: 217s num [1:4] -Inf -Inf -Inf -Inf 217s num [1:4] -Inf -Inf -Inf -Inf 217s num [1:4] -Inf -Inf -Inf -Inf 217s range: 217s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 217s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 217s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 217s real (double) w/ na.rm = TRUE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] 2 6 10 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s num [1:4] 1 2 3 4 217s num [1:4] 1 2 3 4 217s num [1:4] 1 2 3 4 217s max: 217s num [1:4] 9 10 11 12 217s num [1:4] 9 10 11 12 217s num [1:4] 9 10 11 12 217s range: 217s num [1:4, 1:2] 1 2 3 4 9 10 11 12 217s num [1:4, 1:2] 1 2 3 4 9 10 11 12 217s num [1:4, 1:2] 1 2 3 4 9 10 11 12 217s real (double) w/ na.rm = TRUE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] 2 6 10 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s num [1:4] 1 2 3 4 217s num [1:4] 1 2 3 4 217s num [1:4] 1 2 3 4 217s max: 217s num [1:4] 9 10 11 12 217s num [1:4] 9 10 11 12 217s num [1:4] 9 10 11 12 217s range: 217s num [1:4, 1:2] 1 2 3 4 9 10 11 12 217s num [1:4, 1:2] 1 2 3 4 9 10 11 12 217s num [1:4, 1:2] 1 2 3 4 9 10 11 12 217s real w/ NA (double) w/ na.rm = TRUE: 217s [,1] [,2] [,3] 217s [1,] NA NA NA 217s [2,] NA NA NA 217s [3,] NA NA NA 217s [4,] NA NA NA 217s min: 217s num [1:4] Inf Inf Inf Inf 217s num [1:4] Inf Inf Inf Inf 217s num [1:4] Inf Inf Inf Inf 217s max: 217s num [1:4] -Inf -Inf -Inf -Inf 217s num [1:4] -Inf -Inf -Inf -Inf 217s num [1:4] -Inf -Inf -Inf -Inf 217s range: 217s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 217s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 217s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 217s real w/ NA (double) w/ na.rm = TRUE: 217s [,1] [,2] [,3] 217s [1,] NA NA NA 217s [2,] NA NA NA 217s [3,] NA NA NA 217s [4,] NA NA NA 217s min: 217s num [1:4] Inf Inf Inf Inf 217s num [1:4] Inf Inf Inf Inf 217s num [1:4] Inf Inf Inf Inf 217s max: 217s num [1:4] -Inf -Inf -Inf -Inf 217s num [1:4] -Inf -Inf -Inf -Inf 217s num [1:4] -Inf -Inf -Inf -Inf 217s range: 217s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 217s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 217s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 217s real + NA cell (double) w/ na.rm = TRUE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] 2 NA 10 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s num [1:4] 1 2 3 4 217s num [1:4] 1 2 3 4 217s num [1:4] 1 2 3 4 217s max: 217s num [1:4] 9 10 11 12 217s num [1:4] 9 10 11 12 217s num [1:4] 9 10 11 12 217s range: 217s num [1:4, 1:2] 1 2 3 4 9 10 11 12 217s num [1:4, 1:2] 1 2 3 4 9 10 11 12 217s num [1:4, 1:2] 1 2 3 4 9 10 11 12 217s real + NA cell (double) w/ na.rm = TRUE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] 2 NA 10 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s num [1:4] 1 2 3 4 217s num [1:4] 1 2 3 4 217s num [1:4] 1 2 3 4 217s max: 217s num [1:4] 9 10 11 12 217s num [1:4] 9 10 11 12 217s num [1:4] 9 10 11 12 217s range: 217s num [1:4, 1:2] 1 2 3 4 9 10 11 12 217s num [1:4, 1:2] 1 2 3 4 9 10 11 12 217s num [1:4, 1:2] 1 2 3 4 9 10 11 12 217s real + NA row (double) w/ na.rm = TRUE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] NA NA NA 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s num [1:4] 1 Inf 3 4 217s num [1:4] 1 Inf 3 4 217s num [1:4] 1 Inf 3 4 217s max: 217s num [1:4] 9 -Inf 11 12 217s num [1:4] 9 -Inf 11 12 217s num [1:4] 9 -Inf 11 12 217s range: 217s num [1:4, 1:2] 1 Inf 3 4 9 ... 217s num [1:4, 1:2] 1 Inf 3 4 9 ... 217s num [1:4, 1:2] 1 Inf 3 4 9 ... 217s real + NA row (double) w/ na.rm = TRUE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] NA NA NA 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s num [1:4] 1 Inf 3 4 217s num [1:4] 1 Inf 3 4 217s num [1:4] 1 Inf 3 4 217s max: 217s num [1:4] 9 -Inf 11 12 217s num [1:4] 9 -Inf 11 12 217s num [1:4] 9 -Inf 11 12 217s range: 217s num [1:4, 1:2] 1 Inf 3 4 9 ... 217s num [1:4, 1:2] 1 Inf 3 4 9 ... 217s num [1:4, 1:2] 1 Inf 3 4 9 ... 217s real + NaN row (double) w/ na.rm = TRUE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] NaN NaN NaN 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s num [1:4] 1 Inf 3 4 217s num [1:4] 1 Inf 3 4 217s num [1:4] 1 Inf 3 4 217s max: 217s num [1:4] 9 -Inf 11 12 217s num [1:4] 9 -Inf 11 12 217s num [1:4] 9 -Inf 11 12 217s range: 217s num [1:4, 1:2] 1 Inf 3 4 9 ... 217s num [1:4, 1:2] 1 Inf 3 4 9 ... 217s num [1:4, 1:2] 1 Inf 3 4 9 ... 217s real + NaN row (double) w/ na.rm = TRUE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] NaN NaN NaN 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s num [1:4] 1 Inf 3 4 217s num [1:4] 1 Inf 3 4 217s num [1:4] 1 Inf 3 4 217s max: 217s num [1:4] 9 -Inf 11 12 217s num [1:4] 9 -Inf 11 12 217s num [1:4] 9 -Inf 11 12 217s range: 217s num [1:4, 1:2] 1 Inf 3 4 9 ... 217s num [1:4, 1:2] 1 Inf 3 4 9 ... 217s num [1:4, 1:2] 1 Inf 3 4 9 ... 217s real + Inf cell (double) w/ na.rm = TRUE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] 2 Inf 10 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s num [1:4] 1 2 3 4 217s num [1:4] 1 2 3 4 217s num [1:4] 1 2 3 4 217s max: 217s num [1:4] 9 Inf 11 12 217s num [1:4] 9 Inf 11 12 217s num [1:4] 9 Inf 11 12 217s range: 217s num [1:4, 1:2] 1 2 3 4 9 ... 217s num [1:4, 1:2] 1 2 3 4 9 ... 217s num [1:4, 1:2] 1 2 3 4 9 ... 217s real + Inf cell (double) w/ na.rm = TRUE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] 2 Inf 10 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s num [1:4] 1 2 3 4 217s num [1:4] 1 2 3 4 217s num [1:4] 1 2 3 4 217s max: 217s num [1:4] 9 Inf 11 12 217s num [1:4] 9 Inf 11 12 217s num [1:4] 9 Inf 11 12 217s range: 217s num [1:4, 1:2] 1 2 3 4 9 ... 217s num [1:4, 1:2] 1 2 3 4 9 ... 217s num [1:4, 1:2] 1 2 3 4 9 ... 217s real + Inf row (double) w/ na.rm = TRUE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] Inf Inf Inf 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s num [1:4] 1 Inf 3 4 217s num [1:4] 1 Inf 3 4 217s num [1:4] 1 Inf 3 4 217s max: 217s num [1:4] 9 Inf 11 12 217s num [1:4] 9 Inf 11 12 217s num [1:4] 9 Inf 11 12 217s range: 217s num [1:4, 1:2] 1 Inf 3 4 9 ... 217s num [1:4, 1:2] 1 Inf 3 4 9 ... 217s num [1:4, 1:2] 1 Inf 3 4 9 ... 217s real + Inf row (double) w/ na.rm = TRUE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] Inf Inf Inf 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s num [1:4] 1 Inf 3 4 217s num [1:4] 1 Inf 3 4 217s num [1:4] 1 Inf 3 4 217s max: 217s num [1:4] 9 Inf 11 12 217s num [1:4] 9 Inf 11 12 217s num [1:4] 9 Inf 11 12 217s range: 217s num [1:4, 1:2] 1 Inf 3 4 9 ... 217s num [1:4, 1:2] 1 Inf 3 4 9 ... 217s num [1:4, 1:2] 1 Inf 3 4 9 ... 217s real + NaN cell (double) w/ na.rm = TRUE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] 2 NaN 10 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s num [1:4] 1 2 3 4 217s num [1:4] 1 2 3 4 217s num [1:4] 1 2 3 4 217s max: 217s num [1:4] 9 10 11 12 217s num [1:4] 9 10 11 12 217s num [1:4] 9 10 11 12 217s range: 217s num [1:4, 1:2] 1 2 3 4 9 10 11 12 217s num [1:4, 1:2] 1 2 3 4 9 10 11 12 217s num [1:4, 1:2] 1 2 3 4 9 10 11 12 217s real + NaN cell (double) w/ na.rm = TRUE: 217s [,1] [,2] [,3] 217s [1,] 1 5 9 217s [2,] 2 NaN 10 217s [3,] 3 7 11 217s [4,] 4 8 12 217s min: 217s num [1:4] 1 2 3 4 217s num [1:4] 1 2 3 4 217s num [1:4] 1 2 3 4 217s max: 217s num [1:4] 9 10 11 12 217s num [1:4] 9 10 11 12 217s num [1:4] 9 10 11 12 217s range: 217s num [1:4, 1:2] 1 2 3 4 9 10 11 12 217s num [1:4, 1:2] 1 2 3 4 9 10 11 12 217s num [1:4, 1:2] 1 2 3 4 9 10 11 12 217s real w/ NA + NaN cell (double) w/ na.rm = TRUE: 217s [,1] [,2] [,3] 217s [1,] NA NA NA 217s [2,] NA NaN NA 217s [3,] NA NA NA 217s [4,] NA NA NA 217s min: 217s num [1:4] Inf Inf Inf Inf 217s num [1:4] Inf Inf Inf Inf 217s num [1:4] Inf Inf Inf Inf 217s max: 217s num [1:4] -Inf -Inf -Inf -Inf 217s num [1:4] -Inf -Inf -Inf -Inf 217s num [1:4] -Inf -Inf -Inf -Inf 217s range: 217s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 217s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 217s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 217s real w/ NA + NaN cell (double) w/ na.rm = TRUE: 217s [,1] [,2] [,3] 217s [1,] NA NA NA 217s [2,] NA NaN NA 217s [3,] NA NA NA 217s [4,] NA NA NA 217s min: 217s num [1:4] Inf Inf Inf Inf 217s num [1:4] Inf Inf Inf Inf 217s num [1:4] Inf Inf Inf Inf 217s max: 217s num [1:4] -Inf -Inf -Inf -Inf 217s num [1:4] -Inf -Inf -Inf -Inf 217s num [1:4] -Inf -Inf -Inf -Inf 217s range: 217s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 217s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 217s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 217s real w/ NA + NaN row (double) w/ na.rm = TRUE: 217s [,1] [,2] [,3] 217s [1,] NA NA NA 217s [2,] NaN NaN NaN 217s [3,] NA NA NA 217s [4,] NA NA NA 217s min: 217s num [1:4] Inf Inf Inf Inf 217s num [1:4] Inf Inf Inf Inf 217s num [1:4] Inf Inf Inf Inf 217s max: 217s num [1:4] -Inf -Inf -Inf -Inf 217s num [1:4] -Inf -Inf -Inf -Inf 217s num [1:4] -Inf -Inf -Inf -Inf 217s range: 217s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 217s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 217s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 217s real w/ NA + NaN row (double) w/ na.rm = TRUE: 217s [,1] [,2] [,3] 217s [1,] NA NA NA 217s [2,] NaN NaN NaN 217s [3,] NA NA NA 217s [4,] NA NA NA 217s min: 217s num [1:4] Inf Inf Inf Inf 217s num [1:4] Inf Inf Inf Inf 217s num [1:4] Inf Inf Inf Inf 217s max: 217s num [1:4] -Inf -Inf -Inf -Inf 217s num [1:4] -Inf -Inf -Inf -Inf 217s num [1:4] -Inf -Inf -Inf -Inf 217s range: 217s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 217s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 217s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 217s > 217s 217s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 217s Copyright (C) 2024 The R Foundation for Statistical Computing 217s Platform: x86_64-pc-linux-gnu 217s 217s R is free software and comes with ABSOLUTELY NO WARRANTY. 217s You are welcome to redistribute it under certain conditions. 217s Type 'license()' or 'licence()' for distribution details. 217s 217s R is a collaborative project with many contributors. 217s Type 'contributors()' for more information and 217s 'citation()' on how to cite R or R packages in publications. 217s 217s Type 'demo()' for some demos, 'help()' for on-line help, or 217s 'help.start()' for an HTML browser interface to help. 217s Type 'q()' to quit R. 217s 218s > library("matrixStats") 218s > 218s > rowMins_R <- function(x, ..., useNames = NA) { 218s + suppressWarnings({ 218s + res <- apply(x, MARGIN = 1L, FUN = min, ...) 218s + }) 218s + if (is.na(useNames) || !useNames) names(res) <- NULL 218s + res 218s + } # rowMins_R() 218s > 218s > rowMaxs_R <- function(x, ..., useNames = NA) { 218s + suppressWarnings({ 218s + res <- apply(x, MARGIN = 1L, FUN = max, ...) 218s + }) 218s + if (is.na(useNames) || !useNames) names(res) <- NULL 218s + res 218s + } # rowMaxs_R() 218s > 218s > rowRanges_R <- function(x, ..., useNames = NA) { 218s + suppressWarnings({ 218s + ans <- t(apply(x, MARGIN = 1L, FUN = range, ...)) 218s + }) 218s + 218s + # Preserve rownames attribute 218s + dim <- c(dim(x)[1], 2L) 218s + if (!isTRUE(all.equal(dim(ans), dim))) { 218s + dim(ans) <- dim 218s + rownames <- rownames(x) 218s + if (!is.null(dimnames)) rownames(ans) <- rownames 218s + } 218s + if (is.na(useNames) || !useNames) dimnames(ans) <- NULL 218s + ans 218s + } # rowRanges_R() 218s > 218s > 218s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 218s > # Subsetted tests 218s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 218s > source("utils/validateIndicesFramework.R") 218s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 218s > storage.mode(x) <- "integer" 218s > 218s > # To check rownames/names attributes 218s > dimnames <- list(letters[1:6], LETTERS[1:6]) 218s > 218s > # Test with and without dimnames on x 218s > for (setDimnames in c(TRUE, FALSE)) { 218s + if (setDimnames) dimnames(x) <- dimnames 218s + else dimnames(x) <- NULL 218s + 218s + count <- 0L 218s + for (rows in index_cases) { 218s + for (cols in index_cases) { 218s + count <- count + 1L 218s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 218s + useNames <- c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE) 218s + useNames <- useNames[count %% length(useNames) + 1] 218s + 218s + validateIndicesTestMatrix(x, rows, cols, 218s + ftest = rowRanges, fsure = rowRanges_R, 218s + na.rm = na.rm, useNames = useNames) 218s + validateIndicesTestMatrix(x, rows, cols, 218s + ftest = rowMins, fsure = rowMins_R, 218s + na.rm = na.rm, useNames = useNames) 218s + validateIndicesTestMatrix(x, rows, cols, 218s + ftest = rowMaxs, fsure = rowMaxs_R, 218s + na.rm = na.rm, useNames = useNames) 218s + 218s + validateIndicesTestMatrix(x, rows, cols, 218s + fcoltest = colRanges, fsure = rowRanges_R, 218s + na.rm = na.rm, useNames = useNames) 218s + validateIndicesTestMatrix(x, rows, cols, 218s + fcoltest = colMins, fsure = rowMins_R, 218s + na.rm = na.rm, useNames = useNames) 218s + validateIndicesTestMatrix(x, rows, cols, 218s + fcoltest = colMaxs, fsure = rowMaxs_R, 218s + na.rm = na.rm, useNames = useNames) 218s + } 218s + } 218s + } 219s > 219s 219s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 219s Copyright (C) 2024 The R Foundation for Statistical Computing 219s Platform: x86_64-pc-linux-gnu 219s 219s R is free software and comes with ABSOLUTELY NO WARRANTY. 219s You are welcome to redistribute it under certain conditions. 219s Type 'license()' or 'licence()' for distribution details. 219s 219s R is a collaborative project with many contributors. 219s Type 'contributors()' for more information and 219s 'citation()' on how to cite R or R packages in publications. 219s 219s Type 'demo()' for some demos, 'help()' for on-line help, or 219s 'help.start()' for an HTML browser interface to help. 219s Type 'q()' to quit R. 219s 219s > library("matrixStats") 219s > 219s > dense_rank <- function(x) match(x, table = sort(unique(x))) 219s > 219s > rowRanks_R <- function(x, ties.method, ..., useNames = NA) { 219s + if (ties.method == "dense") { 219s + res <- t(apply(x, MARGIN = 1L, FUN = dense_rank)) 219s + } else { 219s + res <- t(apply(x, MARGIN = 1L, FUN = rank, na.last = "keep", ties.method = ties.method)) 219s + } 219s + 219s + # Preserve dimnames attribute? 219s + dim(res) <- dim(x) 219s + dimnames(res) <- if (isTRUE(useNames)) dimnames(x) else NULL 219s + 219s + res 219s + } 219s > 219s > colRanks_R <- function(x, ties.method, preserveShape = FALSE, ..., useNames = NA) { 219s + if (ties.method == "dense") { 219s + res <- t(apply(x, MARGIN = 2L, FUN = dense_rank)) 219s + } else { 219s + res <- t(apply(x, MARGIN = 2L, FUN = rank, na.last = "keep", ties.method = ties.method)) 219s + } 219s + 219s + # Preserve dimnames attribute? 219s + tx <- t(x) 219s + dim(res) <- dim(tx) 219s + dimnames(res) <- if (isTRUE(useNames)) dimnames(tx) else NULL 219s + 219s + if (preserveShape) res <- t(res) 219s + res 219s + } 219s > 219s > set.seed(1) 219s > 219s > cat("Consistency checks:\n") 219s Consistency checks: 219s > xs <- vector("list", length = 4L) 219s > for (kk in 1:4) { 219s + 219s + # Simulate data in a matrix of any shape 219s + dim <- sample(40:80, size = 2L) 219s + n <- prod(dim) 219s + x <- rnorm(n, sd = 10) 219s + dim(x) <- dim 219s + 219s + # Add NAs? 219s + if ((kk %% 4) %in% c(3, 0)) { 219s + cat("Adding NAs\n") 219s + nna <- sample(n, size = 1L) 219s + x[sample(length(x), size = nna)] <- NA_real_ 219s + } 219s + 219s + # Integer or double? 219s + if ((kk %% 4) %in% c(2, 0)) { 219s + cat("Coercing to integers\n") 219s + storage.mode(x) <- "integer" 219s + } 219s + 219s + xs[[kk]] <- x 219s + } # for (kk ...) 219s Coercing to integers 219s Adding NAs 219s Adding NAs 219s Coercing to integers 219s > str(xs) 219s List of 4 219s $ : num [1:43, 1:78] 13.3 12.72 4.15 -15.4 -9.29 ... 219s $ : int [1:46, 1:61] 2 11 -16 -5 19 5 26 -13 1 -9 ... 219s $ : num [1:42, 1:47] NA -22.3 NA NA NA ... 219s $ : int [1:42, 1:78] NA NA NA NA NA NA NA NA NA NA ... 219s > 219s > for (kk in 1:4) { 219s + cat("Random test #", kk, "\n", sep = "") 219s + x <- xs[[kk]] 219s + tx <- t(x) 219s + 219s + for (ties in c("max", "min", "average", "first", "last", "dense")) { 219s + cat(sprintf("ties.method = %s\n", ties)) 219s + # rowRanks(): 219s + y1 <- matrixStats::rowRanks(x, ties.method = ties) 219s + if (ties != "last" || getRversion() >= "3.3.0") { 219s + y2 <- rowRanks_R(x, ties.method = ties) 219s + stopifnot(identical(y1, y2)) 219s + } 219s + 219s + y3 <- matrixStats::colRanks(tx, ties.method = ties) 219s + stopifnot(identical(y1, y3)) 219s + 219s + # colRanks(): 219s + y1 <- matrixStats::colRanks(x, ties.method = ties) 219s + if (ties != "last" || getRversion() >= "3.3.0") { 219s + y2 <- colRanks_R(x, ties.method = ties) 219s + stopifnot(identical(y1, y2)) 219s + } 219s + 219s + y3 <- matrixStats::rowRanks(tx, ties.method = ties) 219s + stopifnot(identical(y1, y3)) 219s + } 219s + } # for (kk ...) 219s Random test #1 219s ties.method = max 219s ties.method = min 219s ties.method = average 219s ties.method = first 219s ties.method = last 219s ties.method = dense 219s Random test #2 219s ties.method = max 219s ties.method = min 219s ties.method = average 219s ties.method = first 219s ties.method = last 219s ties.method = dense 219s Random test #3 219s ties.method = max 219s ties.method = min 219s ties.method = average 219s ties.method = first 219s ties.method = last 219s ties.method = dense 219s Random test #4 219s ties.method = max 219s ties.method = min 219s ties.method = average 219s ties.method = first 219s ties.method = last 219s ties.method = dense 219s > 219s > # Note, below we know ties.method %in% c("min", "max", "average") is correct 219s > 219s > cat("Consistency checks for random:\n") 219s Consistency checks for random: 219s > tolerance <- 0.1 219s > nsamples <- 10000 219s > for (kk in 1:4) { 219s + cat("Random test #", kk, "\n", sep = "") 219s + x <- xs[[kk]] 219s + tx <- t(x) 219s + 219s + for (ties in c("random")) { 219s + cat(sprintf("ties.method = %s\n", ties)) 219s + 219s + ## rowRanks(): 219s + y0 <- rowRanks_R(x, ties.method = ties) 219s + y1 <- matrixStats::rowRanks(x, ties.method = ties) 219s + 219s + ## Assert symmetric rank differences 219s + d <- y1 - y0 219s + stopifnot(all(rowSums(d) == 0, na.rm = TRUE)) 219s + 219s + ## Assert within [min, max] 219s + y2min <- matrixStats::rowRanks(x, ties.method = "min") 219s + y2max <- matrixStats::rowRanks(x, ties.method = "max") 219s + stopifnot(all(y1 >= y2min, na.rm = TRUE) && all(y1 <= y2max, na.rm = TRUE)) 219s + ## Assert near average 219s + y1list <- replicate(nsamples, matrixStats::rowRanks(x, ties.method = ties), simplify = FALSE) 219s + y1mean <- Reduce(`+`, y1list) / nsamples 219s + y2avg <- matrixStats::rowRanks(x, ties.method = "average") 219s + stopifnot(all(abs(y1mean - y2avg) < tolerance, na.rm = TRUE)) 219s + 219s + ## colRanks(): 219s + y0 <- colRanks_R(x, ties.method = ties) 219s + y1 <- matrixStats::colRanks(x, ties.method = ties) 219s + 219s + ## Assert symmetric rank differences 219s + d <- y1 - y0 219s + stopifnot(all(rowSums(d) == 0, na.rm = TRUE)) 219s + 219s + ## Assert within [min, max] 219s + y2min <- matrixStats::colRanks(x, ties.method = "min") 219s + y2max <- matrixStats::colRanks(x, ties.method = "max") 219s + stopifnot(all(y1 >= y2min, na.rm = TRUE) && all(y1 <= y2max, na.rm = TRUE)) 219s + y1list <- replicate(nsamples, matrixStats::colRanks(x, ties.method = ties), simplify = FALSE) 219s + y1mean <- Reduce(`+`, y1list) / nsamples 219s + ## Assert near average 219s + y2avg <- matrixStats::colRanks(x, ties.method = "average") 219s + stopifnot(all(abs(y1mean - y2avg) < tolerance, na.rm = TRUE)) 219s + } 219s + } # for (kk ...) 219s Random test #1 219s ties.method = random 221s Random test #2 221s ties.method = random 224s Random test #3 224s ties.method = random 224s Random test #4 224s ties.method = random 225s > 225s > 225s > ## Exception handling 225s > x <- matrix(1:12, nrow = 3L, ncol = 4L) 225s > y <- try(rowRanks(x, ties.method = "unknown"), silent = TRUE) 225s > stopifnot(inherits(y, "try-error")) 225s > 225s > y <- try(colRanks(x, ties.method = "unknown"), silent = TRUE) 225s > stopifnot(inherits(y, "try-error")) 225s > 225s > dimnames <- list(letters[1:3], LETTERS[1:4]) 225s > for (mode in c("integer", "double")){ 225s + storage.mode(x) <- mode 225s + # Test with and without dimnames on x 225s + for (setDimnames in c(TRUE, FALSE)) { 225s + if (setDimnames) dimnames(x) <- dimnames 225s + else dimnames(x) <- NULL 225s + # Check names attribute 225s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 225s + for (ties in c("max", "min", "average", "first", "last", "dense", "random")) { 225s + cat(sprintf("ties.method = %s\n", ties)) 225s + # rowRanks(): 225s + y1 <- matrixStats::rowRanks(x, ties.method = ties, useNames = useNames) 225s + if (ties != "last" || getRversion() >= "3.3.0") { 225s + y2 <- rowRanks_R(x, ties.method = ties, useNames = useNames) 225s + stopifnot(identical(y1, y2)) 225s + } 225s + 225s + y3 <- matrixStats::colRanks(t(x), ties.method = ties, useNames = useNames) 225s + stopifnot(identical(y1, y3)) 225s + 225s + # colRanks(): 225s + y1 <- matrixStats::colRanks(x, ties.method = ties, useNames = useNames) 225s + if (ties != "last" || getRversion() >= "3.3.0") { 225s + y2 <- colRanks_R(x, ties.method = ties, useNames = useNames) 225s + stopifnot(identical(y1, y2)) 225s + } 225s + 225s + y3 <- matrixStats::rowRanks(t(x), ties.method = ties, useNames = useNames) 225s + stopifnot(identical(y1, y3)) 225s + 225s + # Check preserveShape 225s + y1 <- matrixStats::colRanks(x, ties.method = ties, preserveShape = TRUE, useNames = useNames) 225s + if (ties != "last" || getRversion() >= "3.3.0") { 225s + y2 <- colRanks_R(x, ties.method = ties, preserveShape = TRUE, useNames = useNames) 225s + stopifnot(identical(y1, y2)) 225s + } 225s + } 225s + } 225s + } 225s + } 225s ties.method = max 225s ties.method = min 225s ties.method = average 225s ties.method = first 225s ties.method = last 225s ties.method = dense 225s ties.method = random 225s ties.method = max 225s ties.method = min 225s ties.method = average 225s ties.method = first 225s ties.method = last 225s ties.method = dense 225s ties.method = random 225s ties.method = max 225s ties.method = min 225s ties.method = average 225s ties.method = first 225s ties.method = last 225s ties.method = dense 225s ties.method = random 225s ties.method = max 225s ties.method = min 225s ties.method = average 225s ties.method = first 225s ties.method = last 225s ties.method = dense 225s ties.method = random 225s ties.method = max 225s ties.method = min 225s ties.method = average 225s ties.method = first 225s ties.method = last 225s ties.method = dense 225s ties.method = random 225s ties.method = max 225s ties.method = min 225s ties.method = average 225s ties.method = first 225s ties.method = last 225s ties.method = dense 225s ties.method = random 225s ties.method = max 225s ties.method = min 225s ties.method = average 225s ties.method = first 225s ties.method = last 225s ties.method = dense 225s ties.method = random 225s ties.method = max 225s ties.method = min 225s ties.method = average 225s ties.method = first 225s ties.method = last 225s ties.method = dense 225s ties.method = random 225s > 225s 225s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 225s Copyright (C) 2024 The R Foundation for Statistical Computing 225s Platform: x86_64-pc-linux-gnu 225s 225s R is free software and comes with ABSOLUTELY NO WARRANTY. 225s You are welcome to redistribute it under certain conditions. 225s Type 'license()' or 'licence()' for distribution details. 225s 225s R is a collaborative project with many contributors. 225s Type 'contributors()' for more information and 225s 'citation()' on how to cite R or R packages in publications. 225s 225s Type 'demo()' for some demos, 'help()' for on-line help, or 225s 'help.start()' for an HTML browser interface to help. 225s Type 'q()' to quit R. 225s 225s > library("matrixStats") 225s > 225s > rowRanks_R <- function(x, ties.method = "average", ..., useNames = NA) { 225s + ans <- t(apply(x, MARGIN = 1L, FUN = rank, na.last = "keep", 225s + ties.method = ties.method)) 225s + 225s + # Preserve dimnames attribute? 225s + dim(ans) <- dim(x) 225s + dimnames(ans) <- if (isTRUE(useNames)) dimnames(x) else NULL 225s + 225s + ans 225s + } 225s > 225s > colRanks_R <- function(x, ties.method, preserveShape = FALSE, ..., useNames = NA) { 225s + ans <- t(apply(x, MARGIN = 2L, FUN = rank, na.last = "keep", ties.method = ties.method)) 225s + 225s + # Preserve dimnames attribute? 225s + tx <- t(x) 225s + dim(ans) <- dim(tx) 225s + dimnames(ans) <- if (isTRUE(useNames)) dimnames(tx) else NULL 225s + 225s + if (preserveShape) ans <- t(ans) 225s + ans 225s + } 225s > 225s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 225s > # Subsetted tests 225s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 225s > source("utils/validateIndicesFramework.R") 225s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 225s > storage.mode(x) <- "integer" 225s > 225s > # To check dimnames attribute 225s > dimnames <- list(letters[1:6], LETTERS[1:6]) 225s > 225s > colRanks_R_t <- function(x, rows, cols, ..., useNames = NA) { 225s + t(colRanks(t(x), rows = cols, cols = rows, preserveShape = TRUE, ..., useNames = useNames)) 225s + } 225s > 225s > # Test with and without dimnames on x 225s > for (setDimnames in c(TRUE, FALSE)) { 225s + if (setDimnames) dimnames(x) <- dimnames 225s + else dimnames(x) <- NULL 225s + 225s + count <- 0L 225s + for (rows in index_cases) { 225s + for (cols in index_cases) { 225s + count <- count + 1L 225s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 225s + useNames <- c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE) 225s + useNames <- useNames[count %% length(useNames) + 1] 225s + 225s + validateIndicesTestMatrix(x, rows, cols, 225s + ftest = rowRanks, fsure = rowRanks_R, 225s + ties.method = "average", useNames = useNames) 225s + 225s + validateIndicesTestMatrix(x, rows, cols, 225s + ftest = colRanks_R_t, fsure = rowRanks_R, 225s + ties.method = "average", useNames = useNames) 225s + 225s + for (perserveShape in c(TRUE, FALSE)) { 225s + validateIndicesTestMatrix(x, rows, cols, 225s + ftest = colRanks, fsure = colRanks_R, 225s + ties.method = "average", perserveShape = perserveShape, 225s + useNames = useNames) 225s + } 225s + } 225s + } 225s + } 226s > 226s 226s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 226s Copyright (C) 2024 The R Foundation for Statistical Computing 226s Platform: x86_64-pc-linux-gnu 226s 226s R is free software and comes with ABSOLUTELY NO WARRANTY. 226s You are welcome to redistribute it under certain conditions. 226s Type 'license()' or 'licence()' for distribution details. 226s 226s R is a collaborative project with many contributors. 226s Type 'contributors()' for more information and 226s 'citation()' on how to cite R or R packages in publications. 226s 226s Type 'demo()' for some demos, 'help()' for on-line help, or 226s 'help.start()' for an HTML browser interface to help. 226s Type 'q()' to quit R. 226s 226s > library("matrixStats") 226s > 226s > ## Always allow testing of the 'center' argument (as long as it's not defunct) 226s > options(matrixStats.center.onUse = "ignore") 226s > 226s > ## Create isFALSE() if running on an old version of R 226s > if (!exists("isFALSE", mode="function")) { 226s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 226s + } 226s > 226s > rowSds_R <- function(x, na.rm = FALSE, center = NULL, ..., useNames = NA) { 226s + suppressWarnings({ 226s + sigma <- apply(x, MARGIN = 1L, FUN = sd, na.rm = na.rm) 226s + }) 226s + stopifnot(!any(is.infinite(sigma))) 226s + 226s + # Keep naming support consistency same as rowSds() 226s + if (is.null(center) || ncol(x) <= 1L) { 226s + if (is.na(useNames) || isFALSE(useNames)) names(sigma) <- NULL 226s + } 226s + else if (isFALSE(useNames)) names(sigma) <- NULL 226s + sigma 226s + } 226s > 226s > colSds_R <- function(x, na.rm = FALSE, center = NULL, ..., useNames = NA) { 226s + suppressWarnings({ 226s + sigma <- apply(x, MARGIN = 2L, FUN = sd, na.rm = na.rm) 226s + }) 226s + stopifnot(!any(is.infinite(sigma))) 226s + 226s + # Keep naming support consistency same as colSds() 226s + if (is.null(center) || nrow(x) <= 1L) { 226s + if (is.na(useNames) || isFALSE(useNames)) names(sigma) <- NULL 226s + } 226s + if (isFALSE(useNames)) names(sigma) <- NULL 226s + sigma 226s + } 226s > 226s > 226s > rowSds_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = NA) { 226s + center <- rowWeightedMeans(x, cols = cols, na.rm = na.rm, useNames = FALSE) 226s + sigma <- rowSds(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 226s + stopifnot(!any(is.infinite(sigma))) 226s + sigma 226s + } 226s > 226s > colSds_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = NA) { 226s + center <- colWeightedMeans(x, rows = rows, na.rm = na.rm, useNames = FALSE) 226s + sigma <- colSds(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 226s + stopifnot(!any(is.infinite(sigma))) 226s + sigma 226s + } 226s > 226s > 226s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 226s > # With and without some NAs 226s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 226s > for (mode in c("integer", "double")) { 226s + for (add_na in c(FALSE, TRUE)) { 226s + cat("add_na = ", add_na, "\n", sep = "") 226s + 226s + x <- matrix(1:50 + 0.1, nrow = 10L, ncol = 5L) 226s + if (add_na) { 226s + x[3:7, c(2, 4)] <- NA_real_ 226s + } 226s + cat("mode: ", mode, "\n", sep = "") 226s + storage.mode(x) <- mode 226s + str(x) 226s + 226s + # To check names attribute 226s + dimnames <- list(letters[1:10], LETTERS[1:5]) 226s + 226s + # Test with and without dimnames on x 226s + for (setDimnames in c(TRUE, FALSE)) { 226s + if (setDimnames) dimnames(x) <- dimnames 226s + else dimnames(x) <- NULL 226s + # Row/column ranges 226s + for (na.rm in c(FALSE, TRUE)) { 226s + # Check names attribute 226s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 226s + r0 <- rowSds_R(x, na.rm = na.rm, useNames = useNames) 226s + r1 <- rowSds(x, na.rm = na.rm, useNames = useNames) 226s + r1b <- rowSds_center(x, na.rm = na.rm, useNames = useNames) 226s + r2 <- colSds(t(x), na.rm = na.rm, useNames = useNames) 226s + r2b <- colSds_center(t(x), na.rm = na.rm, useNames = useNames) 226s + stopifnot(all.equal(r1, r2)) 226s + stopifnot(all.equal(r1, r0)) 226s + stopifnot(all.equal(r2, r0)) 226s + stopifnot(all.equal(r1b, r2b)) 226s + stopifnot( 226s + !any(is.infinite(r1)), 226s + !any(is.infinite(r2)), 226s + !any(is.infinite(r1b)), 226s + !any(is.infinite(r2b)) 226s + ) 226s + } 226s + } 226s + } 226s + } # for (add_na ...) 226s + } 226s add_na = FALSE 226s mode: integer 226s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 227s add_na = TRUE 227s mode: integer 227s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 227s add_na = FALSE 227s mode: double 227s num [1:10, 1:5] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ... 227s add_na = TRUE 227s mode: double 227s num [1:10, 1:5] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ... 227s > 227s > 227s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 227s > # All NAs 227s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 227s > for (mode in c("integer", "double")) { 227s + x <- matrix(NA_real_, nrow = 10L, ncol = 5L) 227s + cat("mode: ", mode, "\n", sep = "") 227s + storage.mode(x) <- mode 227s + str(x) 227s + 227s + # Test with and without dimnames on x 227s + for (setDimnames in c(TRUE, FALSE)) { 227s + if (setDimnames) dimnames(x) <- dimnames 227s + else dimnames(x) <- NULL 227s + # Row/column ranges 227s + for (na.rm in c(FALSE, TRUE)) { 227s + # Check names attribute 227s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 227s + r0 <- rowSds_R(x, na.rm = na.rm, useNames = useNames) 227s + r1 <- rowSds(x, na.rm = na.rm, useNames = useNames) 227s + r1b <- rowSds_center(x, na.rm = na.rm, useNames = useNames) 227s + r2 <- colSds(t(x), na.rm = na.rm, useNames = useNames) 227s + r2b <- colSds_center(t(x), na.rm = na.rm, useNames = useNames) 227s + stopifnot(all.equal(r1, r2)) 227s + stopifnot(all.equal(r1, r0)) 227s + stopifnot(all.equal(r2, r0)) 227s + stopifnot(all.equal(r1b, r2b)) 227s + stopifnot( 227s + !any(is.infinite(r1)), 227s + !any(is.infinite(r2)), 227s + !any(is.infinite(r1b)), 227s + !any(is.infinite(r2b)) 227s + ) 227s + } 227s + } 227s + } 227s + } 227s mode: integer 227s int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 227s mode: double 227s num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 227s > 227s > 227s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 227s > # A 1x1 matrix 227s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 227s > x <- matrix(0, nrow = 1L, ncol = 1L) 227s > dimnames <- list("a", "A") 227s > for (na.rm in c(FALSE, TRUE)) { 227s + cat("na.rm = ", na.rm, "\n", sep = "") 227s + 227s + # Test with and without dimnames on x 227s + for (setDimnames in c(TRUE, FALSE)) { 227s + if (setDimnames) dimnames(x) <- dimnames 227s + else dimnames(x) <- NULL 227s + # Row/column ranges 227s + for (na.rm in c(FALSE, TRUE)) { 227s + # Check names attribute 227s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 227s + r0 <- rowSds_R(x, na.rm = na.rm, useNames = useNames) 227s + r1 <- rowSds(x, na.rm = na.rm, useNames = useNames) 227s + r1b <- rowSds_center(x, na.rm = na.rm, useNames = useNames) 227s + r2 <- colSds(t(x), na.rm = na.rm, useNames = useNames) 227s + r2b <- colSds_center(t(x), na.rm = na.rm, useNames = useNames) 227s + stopifnot(all.equal(r1, r2)) 227s + stopifnot(all.equal(r1, r0)) 227s + stopifnot(all.equal(r2, r0)) 227s + stopifnot(all.equal(r1b, r2b)) 227s + stopifnot( 227s + !any(is.infinite(r1)), 227s + !any(is.infinite(r2)), 227s + !any(is.infinite(r1b)), 227s + !any(is.infinite(r2b)) 227s + ) 227s + } 227s + } 227s + } 227s + } 227s na.rm = FALSE 227s na.rm = TRUE 227s > 227s 227s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 227s Copyright (C) 2024 The R Foundation for Statistical Computing 227s Platform: x86_64-pc-linux-gnu 227s 227s R is free software and comes with ABSOLUTELY NO WARRANTY. 227s You are welcome to redistribute it under certain conditions. 227s Type 'license()' or 'licence()' for distribution details. 227s 227s R is a collaborative project with many contributors. 227s Type 'contributors()' for more information and 227s 'citation()' on how to cite R or R packages in publications. 227s 227s Type 'demo()' for some demos, 'help()' for on-line help, or 227s 'help.start()' for an HTML browser interface to help. 227s Type 'q()' to quit R. 227s 227s > library("matrixStats") 227s > 227s > ## Always allow testing of the 'center' argument (as long as it's not defunct) 227s > options(matrixStats.center.onUse = "ignore") 227s > 227s > ## Create isFALSE() if running on an old version of R 227s > if (!exists("isFALSE", mode="function")) { 227s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 227s + } 227s > 227s > rowSds_R <- function(x, na.rm = FALSE, center = NULL, ..., useNames = NA) { 227s + suppressWarnings({ 227s + sigma <- apply(x, MARGIN = 1L, FUN = sd, na.rm = na.rm) 227s + }) 227s + stopifnot(!any(is.infinite(sigma))) 227s + 227s + # Keep naming support consistency same as rowSds() 227s + if (is.null(center) || ncol(x) <= 1L) { 227s + if (is.na(useNames) || isFALSE(useNames)) names(sigma) <- NULL 227s + } 227s + else if (isFALSE(useNames)) names(sigma) <- NULL 227s + sigma 227s + } 227s > 227s > colSds_R <- function(x, na.rm = FALSE, center = NULL, ..., useNames = NA) { 227s + suppressWarnings({ 227s + sigma <- apply(x, MARGIN = 2L, FUN = sd, na.rm = na.rm) 227s + }) 227s + stopifnot(!any(is.infinite(sigma))) 227s + 227s + # Keep naming support consistency same as colSds() 227s + if (is.null(center) || nrow(x) <= 1L) { 227s + if (is.na(useNames) || isFALSE(useNames)) names(sigma) <- NULL 227s + } 227s + else if (isFALSE(useNames)) names(sigma) <- NULL 227s + sigma 227s + } 227s > 227s > 227s > rowSds_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = NA) { 227s + center <- rowWeightedMeans(x, cols = cols, na.rm = na.rm, useNames = FALSE) 227s + sigma <- rowSds(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 227s + stopifnot(!any(is.infinite(sigma))) 227s + sigma 227s + } 227s > 227s > colSds_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = NA) { 227s + center <- colWeightedMeans(x, rows = rows, na.rm = na.rm, useNames = FALSE) 227s + sigma <- colSds(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 227s + stopifnot(!any(is.infinite(sigma))) 227s + sigma 227s + } 227s > 227s > 227s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 227s > # Subsetted tests 227s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 227s > source("utils/validateIndicesFramework.R") 227s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 227s > storage.mode(x) <- "integer" 227s > 227s > # To check names attribute 227s > dimnames <- list(letters[1:6], LETTERS[1:6]) 227s > 227s > # Test with and without dimnames on x 227s > for (setDimnames in c(TRUE, FALSE)) { 227s + if (setDimnames) dimnames(x) <- dimnames 227s + else dimnames(x) <- NULL 227s + 227s + count <- 0L 227s + for (rows in index_cases) { 227s + for (cols in index_cases) { 227s + count <- count + 1L 227s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 227s + useNames <- c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE) 227s + useNames <- useNames[count %% length(useNames) + 1] 227s + 227s + validateIndicesTestMatrix(x, rows, cols, 227s + ftest = rowSds, fsure = rowSds_R, 227s + na.rm = na.rm, useNames = useNames) 227s + validateIndicesTestMatrix(x, rows, cols, 227s + ftest = rowSds_center, fsure = rowSds_R, 227s + na.rm = na.rm, center = TRUE, useNames = useNames) 227s + 227s + validateIndicesTestMatrix(x, rows, cols, 227s + fcoltest = colSds, fsure = rowSds_R, 227s + na.rm = na.rm, useNames = useNames) 227s + validateIndicesTestMatrix(x, rows, cols, 227s + fcoltest = colSds_center, fsure = rowSds_R, 227s + na.rm = na.rm, center = TRUE, useNames = useNames) 227s + } 227s + } 227s + } 227s > 227s 227s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 227s Copyright (C) 2024 The R Foundation for Statistical Computing 227s Platform: x86_64-pc-linux-gnu 227s 227s R is free software and comes with ABSOLUTELY NO WARRANTY. 227s You are welcome to redistribute it under certain conditions. 227s Type 'license()' or 'licence()' for distribution details. 227s 227s R is a collaborative project with many contributors. 227s Type 'contributors()' for more information and 227s 'citation()' on how to cite R or R packages in publications. 227s 227s Type 'demo()' for some demos, 'help()' for on-line help, or 227s 'help.start()' for an HTML browser interface to help. 227s Type 'q()' to quit R. 227s 228s > library("matrixStats") 228s > 228s > rowSums2_R <- function(x, na.rm = FALSE, ..., useNames = NA) { 228s + ## FIXME: sum() may overflow for integers, whereas 228s + ## base::rowSums() doesn't. What should rowSums2() do? 228s + ## apply(x, MARGIN = 1L, FUN = sum, na.rm = na.rm) 228s + res <- rowSums(x, na.rm = na.rm) 228s + if (is.na(useNames) || !useNames) names(res) <- NULL 228s + res 228s + } 228s > 228s > colSums2_R <- function(x, na.rm = FALSE, ..., useNames = NA) { 228s + ## FIXME: sum() may overflow for integers, whereas 228s + ## base::colSums() doesn't. What should colSums2() do? 228s + ## apply(x, MARGIN = 2L, FUN = sum, na.rm = na.rm) 228s + res <- colSums(x, na.rm = na.rm) 228s + if (is.na(useNames) || !useNames) names(res) <- NULL 228s + res 228s + } 228s > 228s > for (mode in c("integer", "logical", "double")) { 228s + x <- matrix(-4:4, nrow = 3, ncol = 3) 228s + storage.mode(x) <- mode 228s + if (mode == "double") x <- x + 0.1 228s + 228s + # To check names attribute 228s + dimnames <- list(letters[1:3], LETTERS[1:3]) 228s + 228s + # Test with and without dimnames on x 228s + for (setDimnames in c(TRUE, FALSE)) { 228s + if (setDimnames) dimnames(x) <- dimnames 228s + else dimnames(x) <- NULL 228s + # Check names attribute 228s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 228s + y0 <- rowSums2_R(x, na.rm = FALSE, useNames = useNames) 228s + y1 <- rowSums2(x, na.rm = FALSE, useNames = useNames) 228s + stopifnot(all.equal(y1, y0)) 228s + 228s + y0 <- colSums2_R(x, na.rm = FALSE, useNames = useNames) 228s + y1 <- colSums2(x, na.rm = FALSE, useNames = useNames) 228s + stopifnot(all.equal(y1, y0)) 228s + } 228s + } 228s + } 228s > 228s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 228s > # Special case: Single-element matrix 228s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 228s > cat("Special case: Single-element matrix:\n") 228s Special case: Single-element matrix: 228s > for (mode in c("integer", "logical", "double")) { 228s + x <- matrix(1, nrow = 1, ncol = 1) 228s + storage.mode(x) <- mode 228s + 228s + # To check names attribute 228s + dimnames <- list("a", "A") 228s + 228s + # Test with and without dimnames on x 228s + for (setDimnames in c(TRUE, FALSE)) { 228s + if (setDimnames) dimnames(x) <- dimnames 228s + else dimnames(x) <- NULL 228s + # Check names attribute 228s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 228s + y0 <- rowSums2_R(x, na.rm = FALSE, useNames = useNames) 228s + y1 <- rowSums2(x, na.rm = FALSE, useNames = useNames) 228s + stopifnot(all.equal(y1, y0)) 228s + 228s + y0 <- colSums2_R(x, na.rm = FALSE, useNames = useNames) 228s + y1 <- colSums2(x, na.rm = FALSE, useNames = useNames) 228s + stopifnot(all.equal(y1, y0)) 228s + } 228s + } 228s + } 228s > 228s > 228s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 228s > # Special case: Empty matrix 228s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 228s > cat("Special case: Empty matrix:\n") 228s Special case: Empty matrix: 228s > for (mode in c("integer", "logical", "double")) { 228s + x <- matrix(integer(0), nrow = 0, ncol = 0) 228s + storage.mode(x) <- mode 228s + 228s + y0 <- rowSums2_R(x, na.rm = FALSE) 228s + y1 <- rowSums2(x, na.rm = FALSE) 228s + stopifnot(all.equal(y1, y0)) 228s + 228s + y0 <- colSums2_R(x, na.rm = FALSE) 228s + y1 <- colSums2(x, na.rm = FALSE) 228s + stopifnot(all.equal(y1, y0)) 228s + } 228s > 228s > 228s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 228s > # Special case: All NAs 228s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 228s > cat("Special case: All NAs:\n") 228s Special case: All NAs: 228s > for (mode in c("integer", "logical", "double")) { 228s + x <- matrix(NA_integer_, nrow = 3, ncol = 3) 228s + storage.mode(x) <- mode 228s + 228s + # To check names attribute 228s + dimnames <- list(letters[1:3], LETTERS[1:3]) 228s + 228s + # Test with and without dimnames on x 228s + for (setDimnames in c(TRUE, FALSE)) { 228s + if (setDimnames) dimnames(x) <- dimnames 228s + else dimnames(x) <- NULL 228s + # Check names attribute 228s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 228s + y0 <- rowSums2_R(x, na.rm = TRUE, useNames = useNames) 228s + y1 <- rowSums2(x, na.rm = TRUE, useNames = useNames) 228s + stopifnot(all.equal(y1, y0)) 228s + 228s + y0 <- colSums2_R(x, na.rm = TRUE, useNames = useNames) 228s + y1 <- colSums2(x, na.rm = TRUE, useNames = useNames) 228s + stopifnot(all.equal(y1, y0)) 228s + } 228s + } 228s + } 228s > 228s > 228s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 228s > # Special case: All NaNs 228s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 228s > cat("Special case: All NaNs:\n") 228s Special case: All NaNs: 228s > x <- matrix(NA_real_, nrow = 3, ncol = 3) 228s > 228s > # Test with and without dimnames on x 228s > for (setDimnames in c(TRUE, FALSE)) { 228s + if (setDimnames) dimnames(x) <- dimnames 228s + else dimnames(x) <- NULL 228s + # Check names attribute 228s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 228s + y0 <- rowSums2_R(x, na.rm = TRUE, useNames = useNames) 228s + y1 <- rowSums2(x, na.rm = TRUE, useNames = useNames) 228s + stopifnot(all.equal(y1, y0)) 228s + 228s + y0 <- colSums2_R(x, na.rm = TRUE, useNames = useNames) 228s + y1 <- colSums2(x, na.rm = TRUE, useNames = useNames) 228s + stopifnot(all.equal(y1, y0)) 228s + } 228s + } 228s > 228s > 228s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 228s > # Special case: All Infs 228s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 228s > cat("Special case: All Infs:\n") 228s Special case: All Infs: 228s > x <- matrix(Inf, nrow = 3, ncol = 3) 228s > 228s > # Test with and without dimnames on x 228s > for (setDimnames in c(TRUE, FALSE)) { 228s + if (setDimnames) dimnames(x) <- dimnames 228s + else dimnames(x) <- NULL 228s + # Check names attribute 228s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 228s + y0 <- rowSums2_R(x, na.rm = FALSE, useNames = useNames) 228s + y1 <- rowSums2(x, na.rm = FALSE, useNames = useNames) 228s + stopifnot(all.equal(y1, y0)) 228s + 228s + y0 <- colSums2_R(x, na.rm = FALSE, useNames = useNames) 228s + y1 <- colSums2(x, na.rm = FALSE, useNames = useNames) 228s + stopifnot(all.equal(y1, y0)) 228s + } 228s + } 228s > 228s > 228s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 228s > # Special case: All -Infs 228s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 228s > cat("Special case: All -Infs:\n") 228s Special case: All -Infs: 228s > x <- matrix(-Inf, nrow = 3, ncol = 3) 228s > 228s > # Test with and without dimnames on x 228s > for (setDimnames in c(TRUE, FALSE)) { 228s + if (setDimnames) dimnames(x) <- dimnames 228s + else dimnames(x) <- NULL 228s + # Check names attribute 228s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 228s + y0 <- rowSums2_R(x, na.rm = FALSE, useNames = useNames) 228s + y1 <- rowSums2(x, na.rm = FALSE, useNames = useNames) 228s + stopifnot(all.equal(y1, y0)) 228s + 228s + y0 <- colSums2_R(x, na.rm = FALSE, useNames = useNames) 228s + y1 <- colSums2(x, na.rm = FALSE, useNames = useNames) 228s + stopifnot(all.equal(y1, y0)) 228s + } 228s + } 228s > 228s > 228s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 228s > # Special case: Infs and -Infs 228s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 228s > cat("Special case: Infs and -Infs:\n") 228s Special case: Infs and -Infs: 228s > x <- matrix(c(-Inf, +Inf), nrow = 4, ncol = 4) 228s > 228s > # To check names attribute 228s > dimnames <- list(letters[1:4], LETTERS[1:4]) 228s > 228s > # Test with and without dimnames on x 228s > for (setDimnames in c(TRUE, FALSE)) { 228s + if (setDimnames) dimnames(x) <- dimnames 228s + else dimnames(x) <- NULL 228s + # Check names attribute 228s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 228s + y0 <- rowSums2_R(x, na.rm = FALSE, useNames = useNames) 228s + y1 <- rowSums2(x, na.rm = FALSE, useNames = useNames) 228s + stopifnot(all.equal(y1, y0)) 228s + 228s + y0 <- colSums2_R(x, na.rm = FALSE, useNames = useNames) 228s + y1 <- colSums2(x, na.rm = FALSE, useNames = useNames) 228s + stopifnot(all.equal(y1, y0)) 228s + } 228s + } 228s > 228s > 228s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 228s > # Special case: NaNs and NAs 228s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 228s > cat("Special case: Infs and -Infs:\n") 228s Special case: Infs and -Infs: 228s > x <- matrix(c(NaN, NA_real_), nrow = 4, ncol = 4) 228s > 228s > y0 <- rowSums(x, na.rm = FALSE) 228s > str(y0) 228s num [1:4] NaN NA NaN NA 228s > stopifnot(all(is.na(y0)), length(unique(y0)) >= 1L) 228s > y1 <- rowSums2(x, na.rm = FALSE) 228s > str(y0) 228s num [1:4] NaN NA NaN NA 228s > stopifnot(all(is.na(y1)), length(unique(y1)) >= 1L) 228s > stopifnot(all.equal(y1, y0)) 228s > 228s > y0 <- colSums(x, na.rm = FALSE) 228s > stopifnot(all(is.na(y0)), length(unique(y0)) == 1L) 228s > y1 <- colSums2(x, na.rm = FALSE) 228s > stopifnot(all(is.na(y1)), length(unique(y1)) == 1L) 228s > ## NOTE, due to compiler optimization, it is not guaranteed that NA is 228s > ## returned here (as one would expect). NaN might very well be returned, 228s > ## when both NA and NaN are involved. This is an accepted feature in R, 228s > ## which is documented in help("is.nan"). See also 228s > ## https://stat.ethz.ch/pipermail/r-devel/2017-April/074009.html. 228s > ## Thus, we cannot guarantee that y1 is identical to y0. 228s > 228s > 228s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 228s > # Special case: Integer overflow with ties 228s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 228s > cat("Special case: Integer overflow with ties:\n") 228s Special case: Integer overflow with ties: 228s > x <- matrix(.Machine$integer.max, nrow = 4, ncol = 4) 228s > 228s > # Test with and without dimnames on x 228s > for (setDimnames in c(TRUE, FALSE)) { 228s + if (setDimnames) dimnames(x) <- dimnames 228s + else dimnames(x) <- NULL 228s + # Check names attribute 228s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 228s + y0 <- rowSums2_R(x, na.rm = FALSE, useNames = useNames) 228s + y1 <- rowSums2(x, na.rm = FALSE, useNames = useNames) 228s + stopifnot(all.equal(y1, y0)) 228s + 228s + y0 <- colSums2_R(x, na.rm = FALSE, useNames = useNames) 228s + y1 <- colSums2(x, na.rm = FALSE, useNames = useNames) 228s + stopifnot(all.equal(y1, y0)) 228s + } 228s + } 228s > 228s > 228s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 228s > # Consistency checks 228s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 228s > set.seed(1) 228s > 228s > cat("Consistency checks:\n") 228s Consistency checks: 228s > n_sims <- if (Sys.getenv("_R_CHECK_USE_VALGRIND_") != "") 4L else 20L 228s > for (kk in seq_len(n_sims)) { 228s + cat("Random test #", kk, "\n", sep = "") 228s + 228s + # Simulate data in a matrix of any shape 228s + dim <- sample(50:200, size = 2) 228s + n <- prod(dim) 228s + x <- rnorm(n, sd = 100) 228s + dim(x) <- dim 228s + 228s + # Add NAs? 228s + if ((kk %% 4) %in% c(3, 0)) { 228s + cat("Adding NAs\n") 228s + nna <- sample(n, size = 1) 228s + na_values <- c(NA_real_, NaN) 228s + t <- sample(na_values, size = nna, replace = TRUE) 228s + x[sample(length(x), size = nna)] <- t 228s + } 228s + 228s + # Mode? 228s + modes <- "double" 228s + if ((kk %% 4) %in% c(2, 0)) { 228s + modes <- c("integer", "logical") 228s + } 228s + 228s + for (mode in modes) { 228s + if (mode != "double") { 228s + cat(sprintf("Coercing from %s to %s\n", storage.mode(x), mode)) 228s + storage.mode(x) <- mode 228s + } 228s + 228s + na.rm <- sample(c(TRUE, FALSE), size = 1) 228s + 228s + # rowSums2(): 228s + y0 <- rowSums2_R(x, na.rm = na.rm) 228s + y1 <- rowSums2(x, na.rm = na.rm) 228s + stopifnot(all.equal(y1, y0)) 228s + y2 <- colSums2(t(x), na.rm = na.rm) 228s + stopifnot(all.equal(y2, y0)) 228s + 228s + # colSums2(): 228s + y0 <- colSums2_R(x, na.rm = na.rm) 228s + y1 <- colSums2(x, na.rm = na.rm) 228s + stopifnot(all.equal(y1, y0)) 228s + y2 <- rowSums2(t(x), na.rm = na.rm) 228s + stopifnot(all.equal(y2, y0)) 228s + } 228s + } # for (kk ...) 228s Random test #1 228s Random test #2 228s Coercing from double to integer 228s Coercing from integer to logical 228s Random test #3 228s Adding NAs 228s Random test #4 228s Adding NAs 228s Coercing from double to integer 228s Coercing from integer to logical 228s Random test #5 228s Random test #6 228s Coercing from double to integer 228s Coercing from integer to logical 228s Random test #7 228s Adding NAs 228s Random test #8 228s Adding NAs 228s Coercing from double to integer 228s Coercing from integer to logical 228s Random test #9 228s Random test #10 228s Coercing from double to integer 228s Coercing from integer to logical 228s Random test #11 228s Adding NAs 228s Random test #12 228s Adding NAs 228s Coercing from double to integer 228s Coercing from integer to logical 228s Random test #13 228s Random test #14 228s Coercing from double to integer 228s Coercing from integer to logical 228s Random test #15 228s Adding NAs 228s Random test #16 228s Adding NAs 228s Coercing from double to integer 228s Coercing from integer to logical 228s Random test #17 228s Random test #18 228s Coercing from double to integer 228s Coercing from integer to logical 228s Random test #19 228s Adding NAs 228s Random test #20 228s Adding NAs 228s Coercing from double to integer 228s Coercing from integer to logical 228s > 228s 228s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 228s Copyright (C) 2024 The R Foundation for Statistical Computing 228s Platform: x86_64-pc-linux-gnu 228s 228s R is free software and comes with ABSOLUTELY NO WARRANTY. 228s You are welcome to redistribute it under certain conditions. 228s Type 'license()' or 'licence()' for distribution details. 228s 228s R is a collaborative project with many contributors. 228s Type 'contributors()' for more information and 228s 'citation()' on how to cite R or R packages in publications. 228s 228s Type 'demo()' for some demos, 'help()' for on-line help, or 228s 'help.start()' for an HTML browser interface to help. 228s Type 'q()' to quit R. 228s 228s > library("matrixStats") 228s > 228s > rowSums2_R <- function(x, na.rm = FALSE, ..., useNames = NA) { 228s + ## FIXME: sum() may overflow for integers, whereas 228s + ## base::rowSums() doesn't. What should rowSums2() do? 228s + ## apply(x, MARGIN = 1L, FUN = sum, na.rm = na.rm) 228s + res <- rowSums(x, na.rm = na.rm) 228s + if (is.na(useNames) || !useNames) names(res) <- NULL 228s + res 228s + } 228s > 228s > colSums2_R <- function(x, na.rm = FALSE, ..., useNames = NA) { 228s + ## FIXME: sum() may overflow for integers, whereas 228s + ## base::colSums() doesn't. What should colSums2() do? 228s + ## apply(x, MARGIN = 2L, FUN = sum, na.rm = na.rm) 228s + res <- colSums(x, na.rm = na.rm) 228s + if (is.na(useNames) || !useNames) names(res) <- NULL 228s + res 228s + } 228s > 228s > 228s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 228s > # Subsetted tests 228s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 228s > source("utils/validateIndicesFramework.R") 228s > x <- matrix(runif(6 * 6, min = -3, max = 3), nrow = 6, ncol = 6) 228s > storage.mode(x) <- "integer" 228s > 228s > # To check names attribute 228s > dimnames <- list(letters[1:6], LETTERS[1:6]) 228s > 228s > # Test with and without dimnames on x 228s > for (setDimnames in c(TRUE, FALSE)) { 228s + if (setDimnames) dimnames(x) <- dimnames 228s + else dimnames(x) <- NULL 228s + for (rows in index_cases) { 228s + for (cols in index_cases) { 228s + for (na.rm in c(TRUE, FALSE)) { 228s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 228s + validateIndicesTestMatrix(x, rows, cols, 228s + ftest = rowSums2, fsure = rowSums2_R, 228s + na.rm = na.rm, useNames = useNames) 228s + validateIndicesTestMatrix(x, rows, cols, 228s + fcoltest = colSums2, fsure = rowSums2_R, 228s + na.rm = na.rm, useNames = useNames) 228s + } 228s + } 228s + } 228s + } 228s + } 228s > 229s 229s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 229s Copyright (C) 2024 The R Foundation for Statistical Computing 229s Platform: x86_64-pc-linux-gnu 229s 229s R is free software and comes with ABSOLUTELY NO WARRANTY. 229s You are welcome to redistribute it under certain conditions. 229s Type 'license()' or 'licence()' for distribution details. 229s 229s R is a collaborative project with many contributors. 229s Type 'contributors()' for more information and 229s 'citation()' on how to cite R or R packages in publications. 229s 229s Type 'demo()' for some demos, 'help()' for on-line help, or 229s 'help.start()' for an HTML browser interface to help. 229s Type 'q()' to quit R. 229s 229s > library("matrixStats") 229s > 229s > nrow <- 6L 229s > ncol <- 5L 229s > data <- matrix(0:4, nrow = nrow, ncol = ncol) 229s > 229s > # To check names attribute 229s > dimnames <- list(letters[1:6], LETTERS[1:5]) 229s > 229s > modes <- c("integer", "logical", "raw") 229s > for (mode in modes) { 229s + cat(sprintf("Mode: %s...\n", mode)) 229s + 229s + x <- data 229s + if (mode == "logical") x <- x - 2L 229s + if (mode != "raw") x[c(2,5,7)] <- NA_integer_ 229s + storage.mode(x) <- mode 229s + print(x) 229s + 229s + unique_values <- unique(as.vector(x)) 229s + nbr_of_unique_values <- length(unique_values) 229s + 229s + y <- rowTabulates(x) 229s + print(y) 229s + stopifnot( 229s + identical(dim(y), c(nrow, nbr_of_unique_values)), 229s + all(y >= 0) 229s + ) 229s + if (mode != "raw") { 229s + y0 <- t(table(x, row(x), useNA = "always")[, seq_len(nrow(x))]) 229s + stopifnot(all(y == y0)) 229s + } 229s + # Check names attribute 229s + dimnames(x) <- dimnames 229s + y1 <- rowTabulates(x, useNames = FALSE) 229s + stopifnot(all.equal(y1, y)) 229s + if (!matrixStats:::isUseNamesNADefunct()) { 229s + y2 <- rowTabulates(x, useNames = NA) 229s + stopifnot(all.equal(y2, y)) 229s + } 229s + y <- rowTabulates(x, useNames = TRUE) 229s + stopifnot(identical(rownames(y), rownames(x))) 229s + dimnames(x) <- NULL 229s + 229s + y <- colTabulates(x) 229s + print(y) 229s + stopifnot( 229s + identical(dim(y), c(ncol, nbr_of_unique_values)), 229s + all(y >= 0) 229s + ) 229s + if (mode != "raw") { 229s + y0 <- t(table(x, col(x), useNA = "always")[, seq_len(ncol(x))]) 229s + stopifnot(all(y == y0)) 229s + } 229s + # Check names attribute 229s + dimnames(x) <- dimnames 229s + y1 <- colTabulates(x, useNames = FALSE) 229s + stopifnot(all.equal(y1, y)) 229s + if (!matrixStats:::isUseNamesNADefunct()) { 229s + y2 <- colTabulates(x, useNames = NA) 229s + stopifnot(all.equal(y2, y)) 229s + } 229s + y <- colTabulates(x, useNames = TRUE) 229s + stopifnot(identical(rownames(y), colnames(x))) 229s + dimnames(x) <- NULL 229s + 229s + # Count only certain values 229s + if (mode == "integer") { 229s + subset <- c(0:2, NA_integer_) 229s + } else if (mode == "logical") { 229s + subset <- c(TRUE, FALSE, NA) 229s + } else { 229s + subset <- c(0:2) 229s + } 229s + y <- rowTabulates(x, values = subset) 229s + print(y) 229s + stopifnot(identical(dim(y), c(nrow, length(subset)))) 229s + # Check names attribute 229s + dimnames(x) <- dimnames 229s + y1 <- rowTabulates(x, values = subset, useNames = FALSE) 229s + stopifnot(all.equal(y1, y)) 229s + if (!matrixStats:::isUseNamesNADefunct()) { 229s + y2 <- rowTabulates(x, values = subset, useNames = NA) 229s + stopifnot(all.equal(y2, y)) 229s + } 229s + y <- rowTabulates(x, values = subset, useNames = TRUE) 229s + stopifnot(identical(rownames(y), rownames(x))) 229s + dimnames(x) <- NULL 229s + 229s + y <- colTabulates(x, values = subset) 229s + print(y) 229s + stopifnot(identical(dim(y), c(ncol, length(subset)))) 229s + # Check names attribute 229s + dimnames(x) <- dimnames 229s + y1 <- colTabulates(x, values = subset, useNames = FALSE) 229s + stopifnot(all.equal(y1, y)) 229s + if (!matrixStats:::isUseNamesNADefunct()) { 229s + y2 <- colTabulates(x, values = subset, useNames = NA) 229s + stopifnot(all.equal(y2, y)) 229s + } 229s + y <- colTabulates(x, values = subset, useNames = TRUE) 229s + stopifnot(identical(rownames(y), colnames(x))) 229s + dimnames(x) <- NULL 229s + 229s + # Raw 229s + if (mode %in% c("integer", "raw")) { 229s + subset <- c(0:2) 229s + 229s + y <- rowTabulates(x, values = as.raw(subset)) 229s + print(y) 229s + stopifnot(identical(dim(y), c(nrow, length(subset)))) 229s + # Check names attribute 229s + dimnames(x) <- dimnames 229s + y1 <- rowTabulates(x, values = as.raw(subset), useNames = FALSE) 229s + stopifnot(all.equal(y1, y)) 229s + if (!matrixStats:::isUseNamesNADefunct()) { 229s + y2 <- rowTabulates(x, values = as.raw(subset), useNames = NA) 229s + stopifnot(all.equal(y2, y)) 229s + } 229s + y3 <- rowTabulates(x, values = as.raw(subset), useNames = TRUE) 229s + stopifnot(identical(rownames(y3), rownames(x))) 229s + dimnames(x) <- NULL 229s + 229s + y2 <- colTabulates(t(x), values = as.raw(subset)) 229s + print(y2) 229s + stopifnot( 229s + identical(dim(y2), c(nrow, length(subset))), 229s + identical(y2, y) 229s + ) 229s + # Check names attribute 229s + dimnames(x) <- dimnames 229s + y1 <- colTabulates(t(x), values = as.raw(subset), useNames = FALSE) 229s + stopifnot(all.equal(y1, y)) 229s + if (!matrixStats:::isUseNamesNADefunct()) { 229s + y2 <- colTabulates(t(x), values = as.raw(subset), useNames = NA) 229s + stopifnot(all.equal(y2, y)) 229s + } 229s + y <- colTabulates(t(x), values = as.raw(subset), useNames = TRUE) 229s + stopifnot(identical(rownames(y), colnames(t(x)))) 229s + dimnames(x) <- NULL 229s + } 229s + 229s + cat(sprintf("Mode: %s...done\n", mode)) 229s + } # for (mode ...) 229s Mode: integer... 229s [,1] [,2] [,3] [,4] [,5] 229s [1,] 0 NA 2 3 4 229s [2,] NA 2 3 4 0 229s [3,] 2 3 4 0 1 229s [4,] 3 4 0 1 2 229s [5,] NA 0 1 2 3 229s [6,] 0 1 2 3 4 229s 0 1 2 3 4 229s [1,] 1 0 1 1 1 1 229s [2,] 1 0 1 1 1 1 229s [3,] 1 1 1 1 1 0 229s [4,] 1 1 1 1 1 0 229s [5,] 1 1 1 1 0 1 229s [6,] 1 1 1 1 1 0 229s 0 1 2 3 4 229s [1,] 2 0 1 1 0 2 229s [2,] 1 1 1 1 1 1 229s [3,] 1 1 2 1 1 0 229s [4,] 1 1 1 2 1 0 229s [5,] 1 1 1 1 2 0 229s 0 1 2 229s [1,] 1 0 1 1 229s [2,] 1 0 1 1 229s [3,] 1 1 1 0 229s [4,] 1 1 1 0 229s [5,] 1 1 1 1 229s [6,] 1 1 1 0 229s 0 1 2 229s [1,] 2 0 1 2 229s [2,] 1 1 1 1 229s [3,] 1 1 2 0 229s [4,] 1 1 1 0 229s [5,] 1 1 1 0 229s 0x0 0x1 0x2 229s [1,] 1 0 1 229s [2,] 1 0 1 229s [3,] 1 1 1 229s [4,] 1 1 1 229s [5,] 1 1 1 229s [6,] 1 1 1 229s 0x0 0x1 0x2 229s [1,] 1 0 1 229s [2,] 1 0 1 229s [3,] 1 1 1 229s [4,] 1 1 1 229s [5,] 1 1 1 229s [6,] 1 1 1 229s Mode: integer...done 229s Mode: logical... 229s [,1] [,2] [,3] [,4] [,5] 229s [1,] TRUE NA FALSE TRUE TRUE 229s [2,] NA FALSE TRUE TRUE TRUE 229s [3,] FALSE TRUE TRUE TRUE TRUE 229s [4,] TRUE TRUE TRUE TRUE FALSE 229s [5,] NA TRUE TRUE FALSE TRUE 229s [6,] TRUE TRUE FALSE TRUE TRUE 229s FALSE TRUE 229s [1,] 1 3 1 229s [2,] 1 3 1 229s [3,] 1 4 0 229s [4,] 1 4 0 229s [5,] 1 3 1 229s [6,] 1 4 0 229s FALSE TRUE 229s [1,] 1 3 2 229s [2,] 1 4 1 229s [3,] 2 4 0 229s [4,] 1 5 0 229s [5,] 1 5 0 229s TRUE FALSE 229s [1,] 3 1 1 229s [2,] 3 1 1 229s [3,] 4 1 0 229s [4,] 4 1 0 229s [5,] 3 1 1 229s [6,] 4 1 0 229s TRUE FALSE 229s [1,] 3 1 2 229s [2,] 4 1 1 229s [3,] 4 2 0 229s [4,] 5 1 0 229s [5,] 5 1 0 229s Mode: logical...done 229s Mode: raw... 229s [,1] [,2] [,3] [,4] [,5] 229s [1,] 00 01 02 03 04 229s [2,] 01 02 03 04 00 229s [3,] 02 03 04 00 01 229s [4,] 03 04 00 01 02 229s [5,] 04 00 01 02 03 229s [6,] 00 01 02 03 04 229s 0x0 0x1 0x2 0x3 0x4 229s [1,] 1 1 1 1 1 229s [2,] 1 1 1 1 1 229s [3,] 1 1 1 1 1 229s [4,] 1 1 1 1 1 229s [5,] 1 1 1 1 1 229s [6,] 1 1 1 1 1 229s 0x0 0x1 0x2 0x3 0x4 229s [1,] 2 1 1 1 1 229s [2,] 1 2 1 1 1 229s [3,] 1 1 2 1 1 229s [4,] 1 1 1 2 1 229s [5,] 1 1 1 1 2 229s 0 1 2 229s [1,] 1 1 1 229s [2,] 1 1 1 229s [3,] 1 1 1 229s [4,] 1 1 1 229s [5,] 1 1 1 229s [6,] 1 1 1 229s 0 1 2 229s [1,] 2 1 1 229s [2,] 1 2 1 229s [3,] 1 1 2 229s [4,] 1 1 1 229s [5,] 1 1 1 229s 0x0 0x1 0x2 229s [1,] 1 1 1 229s [2,] 1 1 1 229s [3,] 1 1 1 229s [4,] 1 1 1 229s [5,] 1 1 1 229s [6,] 1 1 1 229s 0x0 0x1 0x2 229s [1,] 1 1 1 229s [2,] 1 1 1 229s [3,] 1 1 1 229s [4,] 1 1 1 229s [5,] 1 1 1 229s [6,] 1 1 1 229s Mode: raw...done 229s > 229s 229s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 229s Copyright (C) 2024 The R Foundation for Statistical Computing 229s Platform: x86_64-pc-linux-gnu 229s 229s R is free software and comes with ABSOLUTELY NO WARRANTY. 229s You are welcome to redistribute it under certain conditions. 229s Type 'license()' or 'licence()' for distribution details. 229s 229s R is a collaborative project with many contributors. 229s Type 'contributors()' for more information and 229s 'citation()' on how to cite R or R packages in publications. 229s 229s Type 'demo()' for some demos, 'help()' for on-line help, or 229s 'help.start()' for an HTML browser interface to help. 229s Type 'q()' to quit R. 229s 229s > library("matrixStats") 229s > 229s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 229s > # Subsetted tests 229s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 229s > source("utils/validateIndicesFramework.R") 229s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 229s > storage.mode(x) <- "integer" 229s > 229s > # To check names attribute 229s > dimnames <- list(letters[1:6], LETTERS[1:6]) 229s > 229s > # Test with and without dimnames on x 229s > for (setDimnames in c(TRUE, FALSE)) { 229s + if (setDimnames) dimnames(x) <- dimnames 229s + else dimnames(x) <- NULL 229s + 229s + count <- 0L 229s + for (rows in index_cases) { 229s + for (cols in index_cases) { 229s + count <- count + 1L 229s + useNames <- c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE) 229s + useNames <- useNames[count %% length(useNames) + 1] 229s + 229s + validateIndicesTestMatrix(x, rows, cols, 229s + ftest = rowTabulates, fsure = rowTabulates, useNames = useNames) 229s + validateIndicesTestMatrix(x, rows, cols, 229s + ftest = rowTabulates, fsure = rowTabulates, 229s + values = 1:3, useNames = useNames) 229s + 229s + validateIndicesTestMatrix(x, rows, cols, 229s + ftest = colTabulates, fsure = colTabulates, useNames = useNames) 229s + validateIndicesTestMatrix(x, rows, cols, 229s + ftest = colTabulates, fsure = colTabulates, 229s + values = 1:3, useNames = useNames) 229s + } 229s + } 229s + } 230s > 230s 230s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 230s Copyright (C) 2024 The R Foundation for Statistical Computing 230s Platform: x86_64-pc-linux-gnu 230s 230s R is free software and comes with ABSOLUTELY NO WARRANTY. 230s You are welcome to redistribute it under certain conditions. 230s Type 'license()' or 'licence()' for distribution details. 230s 230s R is a collaborative project with many contributors. 230s Type 'contributors()' for more information and 230s 'citation()' on how to cite R or R packages in publications. 230s 230s Type 'demo()' for some demos, 'help()' for on-line help, or 230s 'help.start()' for an HTML browser interface to help. 230s Type 'q()' to quit R. 230s 230s > library("matrixStats") 230s > 230s > fcns <- list( 230s + rowVarDiffs = list(rowVarDiffs, colVarDiffs), 230s + rowSdDiffs = list(rowSdDiffs, colSdDiffs), 230s + rowMadDiffs = list(rowMadDiffs, colMadDiffs), 230s + rowIQRDiffs = list(rowIQRDiffs, colIQRDiffs) 230s + ) 230s > 230s > for (fcn in names(fcns)) { 230s + cat(sprintf("%s()...\n", fcn)) 230s + row_fcn <- fcns[[fcn]][[1L]] 230s + col_fcn <- fcns[[fcn]][[2L]] 230s + 230s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 230s + # With and without some NAs 230s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 230s + for (mode in c("integer", "double")) { 230s + for (add_na in c(FALSE, TRUE)) { 230s + cat("add_na = ", add_na, "\n", sep = "") 230s + 230s + x <- matrix(1:50 + 0.1, nrow = 10L, ncol = 5L) 230s + if (add_na) { 230s + x[3:7, c(2, 4)] <- NA_real_ 230s + } 230s + cat("mode: ", mode, "\n", sep = "") 230s + storage.mode(x) <- mode 230s + str(x) 230s + 230s + # To check names attribute 230s + dimnames <- list(letters[1:10], LETTERS[1:5]) 230s + 230s + # Test with and without dimnames on x 230s + for (setDimnames in c(TRUE, FALSE)) { 230s + if (setDimnames) dimnames(x) <- dimnames 230s + else dimnames(x) <- NULL 230s + # Row/column ranges 230s + for (na.rm in c(FALSE, TRUE)) { 230s + # Check names attribute 230s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 230s + cat("na.rm = ", na.rm, "\n", sep = "") 230s + r1 <- row_fcn(x, na.rm = na.rm, useNames = useNames) 230s + r2 <- col_fcn(t(x), na.rm = na.rm, useNames = useNames) 230s + stopifnot(all.equal(r1, r2)) 230s + } 230s + } 230s + } 230s + } # for (add_na ...) 230s + } 230s + 230s + 230s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 230s + # All NAs 230s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 230s + for (mode in c("integer", "double")) { 230s + x <- matrix(NA_real_, nrow = 10L, ncol = 5L) 230s + cat("mode: ", mode, "\n", sep = "") 230s + storage.mode(x) <- mode 230s + str(x) 230s + 230s + # Test with and without dimnames on x 230s + for (setDimnames in c(TRUE, FALSE)) { 230s + if (setDimnames) dimnames(x) <- dimnames 230s + else dimnames(x) <- NULL 230s + # Row/column ranges 230s + for (na.rm in c(FALSE, TRUE)) { 230s + # Check names attribute 230s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 230s + cat("na.rm = ", na.rm, "\n", sep = "") 230s + r1 <- row_fcn(x, na.rm = na.rm, useNames = useNames) 230s + r2 <- col_fcn(t(x), na.rm = na.rm, useNames = useNames) 230s + stopifnot(all.equal(r1, r2)) 230s + } 230s + } 230s + } 230s + } 230s + 230s + 230s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 230s + # A 1x1 matrix 230s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 230s + x <- matrix(0, nrow = 1L, ncol = 1L) 230s + dimnames <- list("a", "A") 230s + # Test with and without dimnames on x 230s + for (setDimnames in c(TRUE, FALSE)) { 230s + if (setDimnames) dimnames(x) <- dimnames 230s + else dimnames(x) <- NULL 230s + # Row/column ranges 230s + for (na.rm in c(FALSE, TRUE)) { 230s + # Check names attribute 230s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 230s + cat("na.rm = ", na.rm, "\n", sep = "") 230s + r1 <- row_fcn(x, na.rm = na.rm, useNames = useNames) 230s + r2 <- col_fcn(t(x), na.rm = na.rm, useNames = useNames) 230s + stopifnot(all.equal(r1, r2)) 230s + } 230s + } 230s + } 230s + 230s + cat(sprintf("%s()...DONE\n", fcn)) 230s + } # for (fcn ...) 230s rowVarDiffs()... 230s add_na = FALSE 230s mode: integer 230s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 230s na.rm = FALSE 230s na.rm = FALSE 230s na.rm = TRUE 230s na.rm = TRUE 230s na.rm = FALSE 230s na.rm = FALSE 230s na.rm = TRUE 230s na.rm = TRUE 230s add_na = TRUE 230s mode: integer 230s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 230s na.rm = FALSE 230s na.rm = FALSE 230s na.rm = TRUE 230s na.rm = TRUE 230s na.rm = FALSE 230s na.rm = FALSE 230s na.rm = TRUE 230s na.rm = TRUE 230s add_na = FALSE 230s mode: double 230s num [1:10, 1:5] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ... 230s na.rm = FALSE 230s na.rm = FALSE 230s na.rm = TRUE 230s na.rm = TRUE 230s na.rm = FALSE 230s na.rm = FALSE 230s na.rm = TRUE 230s na.rm = TRUE 230s add_na = TRUE 230s mode: double 230s num [1:10, 1:5] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ... 230s na.rm = FALSE 230s na.rm = FALSE 230s na.rm = TRUE 230s na.rm = TRUE 230s na.rm = FALSE 230s na.rm = FALSE 230s na.rm = TRUE 230s na.rm = TRUE 230s mode: integer 230s int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 230s na.rm = FALSE 230s na.rm = FALSE 230s na.rm = TRUE 230s na.rm = TRUE 230s na.rm = FALSE 230s na.rm = FALSE 230s na.rm = TRUE 230s na.rm = TRUE 230s mode: double 230s num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 230s na.rm = FALSE 230s na.rm = FALSE 230s na.rm = TRUE 230s na.rm = TRUE 230s na.rm = FALSE 230s na.rm = FALSE 230s na.rm = TRUE 230s na.rm = TRUE 230s na.rm = FALSE 230s na.rm = FALSE 230s na.rm = TRUE 230s na.rm = TRUE 230s na.rm = FALSE 230s na.rm = FALSE 230s na.rm = TRUE 230s na.rm = TRUE 230s rowVarDiffs()...DONE 230s rowSdDiffs()... 230s add_na = FALSE 230s mode: integer 230s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 230s na.rm = FALSE 230s na.rm = FALSE 230s na.rm = TRUE 230s na.rm = TRUE 230s na.rm = FALSE 230s na.rm = FALSE 230s na.rm = TRUE 230s na.rm = TRUE 230s add_na = TRUE 230s mode: integer 230s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 230s na.rm = FALSE 230s na.rm = FALSE 230s na.rm = TRUE 230s na.rm = TRUE 230s na.rm = FALSE 230s na.rm = FALSE 230s na.rm = TRUE 230s na.rm = TRUE 230s add_na = FALSE 230s mode: double 230s num [1:10, 1:5] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ... 230s na.rm = FALSE 230s na.rm = FALSE 230s na.rm = TRUE 230s na.rm = TRUE 230s na.rm = FALSE 230s na.rm = FALSE 230s na.rm = TRUE 230s na.rm = TRUE 230s add_na = TRUE 230s mode: double 230s num [1:10, 1:5] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ... 230s na.rm = FALSE 230s na.rm = FALSE 230s na.rm = TRUE 230s na.rm = TRUE 230s na.rm = FALSE 230s na.rm = FALSE 230s na.rm = TRUE 230s na.rm = TRUE 230s mode: integer 230s int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 230s na.rm = FALSE 230s na.rm = FALSE 230s na.rm = TRUE 230s na.rm = TRUE 230s na.rm = FALSE 230s na.rm = FALSE 230s na.rm = TRUE 230s na.rm = TRUE 230s mode: double 230s num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 230s na.rm = FALSE 230s na.rm = FALSE 230s na.rm = TRUE 230s na.rm = TRUE 230s na.rm = FALSE 230s na.rm = FALSE 230s na.rm = TRUE 230s na.rm = TRUE 230s na.rm = FALSE 230s na.rm = FALSE 230s na.rm = TRUE 230s na.rm = TRUE 230s na.rm = FALSE 230s na.rm = FALSE 230s na.rm = TRUE 230s na.rm = TRUE 230s rowSdDiffs()...DONE 230s rowMadDiffs()... 230s add_na = FALSE 230s mode: integer 230s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 230s na.rm = FALSE 230s na.rm = FALSE 230s na.rm = TRUE 230s na.rm = TRUE 230s na.rm = FALSE 230s na.rm = FALSE 230s na.rm = TRUE 230s na.rm = TRUE 230s add_na = TRUE 230s mode: integer 230s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 230s na.rm = FALSE 230s na.rm = FALSE 230s na.rm = TRUE 230s na.rm = TRUE 230s na.rm = FALSE 230s na.rm = FALSE 230s na.rm = TRUE 230s na.rm = TRUE 230s add_na = FALSE 230s mode: double 230s num [1:10, 1:5] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ... 230s na.rm = FALSE 230s na.rm = FALSE 230s na.rm = TRUE 230s na.rm = TRUE 230s na.rm = FALSE 230s na.rm = FALSE 230s na.rm = TRUE 230s na.rm = TRUE 230s add_na = TRUE 230s mode: double 230s num [1:10, 1:5] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ... 230s na.rm = FALSE 230s na.rm = FALSE 230s na.rm = TRUE 230s na.rm = TRUE 230s na.rm = FALSE 230s na.rm = FALSE 230s na.rm = TRUE 230s na.rm = TRUE 230s mode: integer 230s int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 230s na.rm = FALSE 230s na.rm = FALSE 230s na.rm = TRUE 230s na.rm = TRUE 230s na.rm = FALSE 230s na.rm = FALSE 230s na.rm = TRUE 230s na.rm = TRUE 230s mode: double 230s num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 230s na.rm = FALSE 230s na.rm = FALSE 230s na.rm = TRUE 230s na.rm = TRUE 230s na.rm = FALSE 230s na.rm = FALSE 230s na.rm = TRUE 230s na.rm = TRUE 230s na.rm = FALSE 230s na.rm = FALSE 230s na.rm = TRUE 230s na.rm = TRUE 230s na.rm = FALSE 230s na.rm = FALSE 230s na.rm = TRUE 230s na.rm = TRUE 230s rowMadDiffs()...DONE 230s rowIQRDiffs()... 230s add_na = FALSE 230s mode: integer 230s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 230s na.rm = FALSE 230s na.rm = FALSE 230s na.rm = TRUE 230s na.rm = TRUE 230s na.rm = FALSE 230s na.rm = FALSE 230s na.rm = TRUE 230s na.rm = TRUE 230s add_na = TRUE 230s mode: integer 230s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 230s na.rm = FALSE 230s na.rm = FALSE 230s na.rm = TRUE 230s na.rm = TRUE 230s na.rm = FALSE 230s na.rm = FALSE 230s na.rm = TRUE 230s na.rm = TRUE 230s add_na = FALSE 230s mode: double 230s num [1:10, 1:5] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ... 230s na.rm = FALSE 230s na.rm = FALSE 230s na.rm = TRUE 230s na.rm = TRUE 230s na.rm = FALSE 230s na.rm = FALSE 230s na.rm = TRUE 230s na.rm = TRUE 230s add_na = TRUE 230s mode: double 230s num [1:10, 1:5] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ... 230s na.rm = FALSE 230s na.rm = FALSE 230s na.rm = TRUE 230s na.rm = TRUE 230s na.rm = FALSE 230s na.rm = FALSE 230s na.rm = TRUE 230s na.rm = TRUE 230s mode: integer 230s int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 230s na.rm = FALSE 230s na.rm = FALSE 230s na.rm = TRUE 230s na.rm = TRUE 230s na.rm = FALSE 230s na.rm = FALSE 230s na.rm = TRUE 230s na.rm = TRUE 230s mode: double 230s num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 230s na.rm = FALSE 230s na.rm = FALSE 230s na.rm = TRUE 230s na.rm = TRUE 230s na.rm = FALSE 230s na.rm = FALSE 230s na.rm = TRUE 230s na.rm = TRUE 230s na.rm = FALSE 230s na.rm = FALSE 230s na.rm = TRUE 230s na.rm = TRUE 230s na.rm = FALSE 230s na.rm = FALSE 230s na.rm = TRUE 230s na.rm = TRUE 230s rowIQRDiffs()...DONE 230s > 231s 231s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 231s Copyright (C) 2024 The R Foundation for Statistical Computing 231s Platform: x86_64-pc-linux-gnu 231s 231s R is free software and comes with ABSOLUTELY NO WARRANTY. 231s You are welcome to redistribute it under certain conditions. 231s Type 'license()' or 'licence()' for distribution details. 231s 231s R is a collaborative project with many contributors. 231s Type 'contributors()' for more information and 231s 'citation()' on how to cite R or R packages in publications. 231s 231s Type 'demo()' for some demos, 'help()' for on-line help, or 231s 'help.start()' for an HTML browser interface to help. 231s Type 'q()' to quit R. 231s 231s > library("matrixStats") 231s > 231s > fcns <- list( 231s + madDiff = c(rowMadDiffs, colMadDiffs), 231s + iqrDiff = c(rowIQRDiffs, colIQRDiffs) 231s + ) 231s > 231s > 231s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 231s > # Subsetted tests 231s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 231s > source("utils/validateIndicesFramework.R") 231s > # To check names attribute 231s > dimnames <- list(letters[1:6], LETTERS[1:6]) 231s > trim <- runif(1, min = 0, max = 0.5) 231s > for (fcn in names(fcns)) { 231s + cat(sprintf("subsetted tests on %s()...\n", fcn)) 231s + row_fcn <- fcns[[fcn]][[1L]] 231s + col_fcn <- fcns[[fcn]][[2L]] 231s + 231s + for (mode in c("numeric", "integer")) { 231s + x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6L, ncol = 6L) 231s + storage.mode(x) <- mode 231s + if (mode == "numeric") x[1:2, 3:4] <- Inf 231s + 231s + # Test with and without dimnames on x 231s + for (setDimnames in c(TRUE, FALSE)) { 231s + if (setDimnames) dimnames(x) <- dimnames 231s + else dimnames(x) <- NULL 231s + 231s + count <- 0L 231s + for (diff in 1:2) { 231s + for (rows in index_cases) { 231s + for (cols in index_cases) { 231s + count <- count + 1L 231s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 231s + useNames <- c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE) 231s + useNames <- useNames[count %% length(useNames) + 1] 231s + validateIndicesTestMatrix(x, rows, cols, 231s + ftest = row_fcn, fsure = row_fcn, 231s + na.rm = na.rm, diff = diff, trim = trim, useNames = useNames) 231s + validateIndicesTestMatrix(x, rows, cols, 231s + fcoltest = col_fcn, fsure = row_fcn, 231s + na.rm = na.rm, diff = diff, trim = trim, useNames = useNames) 231s + } 231s + } 231s + } 231s + } 231s + } 231s + cat(sprintf("%s()...DONE\n", fcn)) 231s + } 231s subsetted tests on madDiff()... 233s madDiff()...DONE 233s subsetted tests on iqrDiff()... 235s iqrDiff()...DONE 235s > 235s 235s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 235s Copyright (C) 2024 The R Foundation for Statistical Computing 235s Platform: x86_64-pc-linux-gnu 235s 235s R is free software and comes with ABSOLUTELY NO WARRANTY. 235s You are welcome to redistribute it under certain conditions. 235s Type 'license()' or 'licence()' for distribution details. 235s 235s R is a collaborative project with many contributors. 235s Type 'contributors()' for more information and 235s 'citation()' on how to cite R or R packages in publications. 235s 235s Type 'demo()' for some demos, 'help()' for on-line help, or 235s 'help.start()' for an HTML browser interface to help. 235s Type 'q()' to quit R. 235s 235s > library("matrixStats") 235s > 235s > fcns <- list( 235s + varDiff = c(rowVarDiffs, colVarDiffs), 235s + sdDiff = c(rowSdDiffs, colSdDiffs) 235s + ) 235s > 235s > 235s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 235s > # Subsetted tests 235s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 235s > source("utils/validateIndicesFramework.R") 235s > # To check names attribute 235s > dimnames <- list(letters[1:6], LETTERS[1:6]) 235s > trim <- runif(1, min = 0, max = 0.5) 235s > for (fcn in names(fcns)) { 235s + cat(sprintf("subsetted tests on %s()...\n", fcn)) 235s + row_fcn <- fcns[[fcn]][[1L]] 235s + col_fcn <- fcns[[fcn]][[2L]] 235s + 235s + for (mode in c("numeric", "integer")) { 235s + x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6L, ncol = 6L) 235s + storage.mode(x) <- mode 235s + if (mode == "numeric") x[1:2, 3:4] <- Inf 235s + 235s + # Test with and without dimnames on x 235s + for (setDimnames in c(TRUE, FALSE)) { 235s + if (setDimnames) dimnames(x) <- dimnames 235s + else dimnames(x) <- NULL 235s + 235s + count <- 0L 235s + for (diff in 1:2) { 235s + for (rows in index_cases) { 235s + for (cols in index_cases) { 235s + count <- count + 1L 235s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 235s + useNames <- c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE) 235s + useNames <- useNames[count %% length(useNames) + 1] 235s + 235s + validateIndicesTestMatrix(x, rows, cols, 235s + ftest = row_fcn, fsure = row_fcn, 235s + na.rm = na.rm, diff = diff, trim = trim, useNames = useNames) 235s + validateIndicesTestMatrix(x, rows, cols, 235s + fcoltest = col_fcn, fsure = row_fcn, 235s + na.rm = na.rm, diff = diff, trim = trim, useNames = useNames) 235s + } 235s + } 235s + } 235s + } 235s + } 235s + cat(sprintf("%s()...DONE\n", fcn)) 235s + } 235s subsetted tests on varDiff()... 236s varDiff()...DONE 236s subsetted tests on sdDiff()... 238s sdDiff()...DONE 238s > 238s 238s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 238s Copyright (C) 2024 The R Foundation for Statistical Computing 238s Platform: x86_64-pc-linux-gnu 238s 238s R is free software and comes with ABSOLUTELY NO WARRANTY. 238s You are welcome to redistribute it under certain conditions. 238s Type 'license()' or 'licence()' for distribution details. 238s 238s R is a collaborative project with many contributors. 238s Type 'contributors()' for more information and 238s 'citation()' on how to cite R or R packages in publications. 238s 238s Type 'demo()' for some demos, 'help()' for on-line help, or 238s 'help.start()' for an HTML browser interface to help. 238s Type 'q()' to quit R. 238s 238s > library("matrixStats") 238s > 238s > ## Always allow testing of the 'center' argument (as long as it's not defunct) 238s > options(matrixStats.center.onUse = "ignore") 238s > options(matrixStats.vars.formula.freq = Inf) 238s > 238s > ## Create isFALSE() if running on an old version of R 238s > if (!exists("isFALSE", mode="function")) { 238s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 238s + } 238s > 238s > rowVars_R <- function(x, na.rm = FALSE, center = NULL, ..., useNames = NA) { 238s + suppressWarnings({ 238s + res <- apply(x, MARGIN = 1L, FUN = var, na.rm = na.rm) 238s + }) 238s + stopifnot(!any(is.infinite(res))) 238s + 238s + # Keep naming support consistency same as rowVars() 238s + if (is.null(center) || ncol(x) <= 1L) { 238s + if (is.na(useNames) || isFALSE(useNames)) names(res) <- NULL 238s + } 238s + else if (isFALSE(useNames)) names(res) <- NULL 238s + res 238s + } 238s > 238s > colVars_R <- function(x, na.rm = FALSE, center = NULL, ..., useNames = NA) { 238s + suppressWarnings({ 238s + res <- apply(x, MARGIN = 2L, FUN = var, na.rm = na.rm) 238s + }) 238s + stopifnot(!any(is.infinite(res))) 238s + 238s + # Keep naming support consistency same as colVars() 238s + if (is.null(center) || ncol(x) <= 1L) { 238s + if (is.na(useNames) || isFALSE(useNames)) names(res) <- NULL 238s + } 238s + else if (isFALSE(useNames)) names(res) <- NULL 238s + res 238s + } 238s > 238s > 238s > rowVars_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = NA) { 238s + center <- rowWeightedMeans(x, cols = cols, na.rm = na.rm, useNames = FALSE) 238s + res <- rowVars(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 238s + stopifnot(!any(is.infinite(res))) 238s + res 238s + } 238s > 238s > colVars_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = NA) { 238s + center <- colWeightedMeans(x, rows = rows, na.rm = na.rm, useNames = FALSE) 238s + res <- colVars(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 238s + stopifnot(!any(is.infinite(res))) 238s + res 238s + } 238s > 238s > rowVars_center_naive <- function(x, rows = NULL, cols = NULL, center = NULL, na.rm = FALSE, ..., useNames = NA) { 238s + x <- sweep(x, MARGIN = 1, STATS = as.array(center), FUN = "-") 238s + x[is.infinite(center), ] <- NaN 238s + res <- rowVars(x, rows = rows, cols = cols, center = rep(0, times = nrow(x)), na.rm = na.rm, useNames = useNames) 238s + stopifnot(!any(is.infinite(res))) 238s + res 238s + } 238s > 238s > colVars_center_naive <- function(x, rows = NULL, cols = NULL, center = NULL, na.rm = FALSE, ..., useNames = NA) { 238s + x <- sweep(x, MARGIN = 2, STATS = as.array(center), FUN = "-") 238s + x[, is.infinite(center)] <- NaN 238s + res <- colVars(x, rows = rows, cols = cols, center = rep(0, times = ncol(x)), na.rm = na.rm, useNames = useNames) 238s + stopifnot(!any(is.infinite(res))) 238s + res 238s + } 238s > 238s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 238s > # With and without some NAs or Infs 238s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 238s > for (mode in c("integer", "double")) { 238s + if (mode == "integer") { 238s + specials <- c(0L, NA_integer_) 238s + delta <- 0L 238s + } else { 238s + specials <- c(0, NA_real_, Inf) 238s + delta <- 0.1 238s + } 238s + 238s + for (special in specials) { 238s + cat("special = ", special, "\n", sep = "") 238s + x <- matrix(1:50 + delta, nrow = 10L, ncol = 5L) 238s + x[3:7, c(2, 4)] <- special 238s + cat("mode: ", mode, "\n", sep = "") 238s + str(x) 238s + stopifnot(storage.mode(x) == mode) 238s + 238s + # To check names attribute 238s + dimnames <- list(letters[1:10], LETTERS[1:5]) 238s + 238s + # Test with and without dimnames on x 238s + for (setDimnames in c(TRUE, FALSE)) { 238s + if (setDimnames) dimnames(x) <- dimnames 238s + else dimnames(x) <- NULL 238s + # Row/column variance 238s + for (na.rm in c(FALSE, TRUE)) { 238s + # Check names attribute 238s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 238s + cat("na.rm = ", na.rm, "\n", sep = "") 238s + center <- rowMeans(x, na.rm = na.rm) 238s + 238s + r0 <- rowVars_R(x, na.rm = na.rm, useNames = useNames) 238s + r1 <- rowVars(x, na.rm = na.rm, useNames = useNames) 238s + r1b <- rowVars_center(x, na.rm = na.rm, useNames = useNames) 238s + r1c <- rowVars(x, center = center, na.rm = na.rm, useNames = useNames) 238s + 238s + tx <- t(x) 238s + r2 <- colVars(tx, na.rm = na.rm, useNames = useNames) 238s + r2b <- colVars_center(tx, na.rm = na.rm, useNames = useNames) 238s + r2c <- colVars(tx, center = center, na.rm = na.rm, useNames = useNames) 238s + tx <- NULL 238s + 238s + stopifnot(all.equal(r1, r2)) 238s + stopifnot(all.equal(r1, r0)) 238s + stopifnot(all.equal(r1b, r1c)) 238s + stopifnot(all.equal(r2, r0)) 238s + stopifnot(all.equal(r2b, r2c)) 238s + 238s + center <- colMeans(x, na.rm = na.rm) 238s + 238s + r3 <- colVars(x, center = center, na.rm = na.rm, useNames = useNames) 238s + r3b <- colVars_center_naive(x, center = center, na.rm = na.rm, useNames = useNames) 238s + r3c <- rowVars(t(x), center = center, na.rm = na.rm, useNames = useNames) 238s + r3d <- rowVars_center_naive(t(x), center = center, na.rm = na.rm, useNames = useNames) 238s + stopifnot(all.equal(r3b, r3)) 238s + stopifnot(all.equal(r3c, r3)) 238s + stopifnot(all.equal(r3d, r3)) 238s + 238s + stopifnot( 238s + !any(is.infinite(r0)), 238s + !any(is.infinite(r1)), 238s + !any(is.infinite(r2)), 238s + !any(is.infinite(r3)), 238s + !any(is.infinite(r1b)), 238s + !any(is.infinite(r1c)), 238s + !any(is.infinite(r2b)), 238s + !any(is.infinite(r2c)), 238s + !any(is.infinite(r3b)), 238s + !any(is.infinite(r3c)), 238s + !any(is.infinite(r3d)) 238s + ) 238s + } 238s + } 238s + } 238s + } # for (special ...) 238s + } 238s special = 0 238s mode: integer 238s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 238s na.rm = FALSE 238s na.rm = FALSE 238s na.rm = TRUE 238s na.rm = TRUE 238s na.rm = FALSE 238s na.rm = FALSE 238s na.rm = TRUE 238s na.rm = TRUE 238s special = NA 238s mode: integer 238s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 238s na.rm = FALSE 238s na.rm = FALSE 238s na.rm = TRUE 238s na.rm = TRUE 238s na.rm = FALSE 238s na.rm = FALSE 238s na.rm = TRUE 238s na.rm = TRUE 238s special = 0 238s mode: double 238s num [1:10, 1:5] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ... 238s na.rm = FALSE 238s na.rm = FALSE 238s na.rm = TRUE 238s na.rm = TRUE 238s na.rm = FALSE 238s na.rm = FALSE 238s na.rm = TRUE 238s na.rm = TRUE 238s special = NA 238s mode: double 238s num [1:10, 1:5] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ... 238s na.rm = FALSE 238s na.rm = FALSE 238s na.rm = TRUE 238s na.rm = TRUE 238s na.rm = FALSE 238s na.rm = FALSE 238s na.rm = TRUE 238s na.rm = TRUE 238s special = Inf 238s mode: double 238s num [1:10, 1:5] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ... 238s na.rm = FALSE 238s na.rm = FALSE 238s na.rm = TRUE 238s na.rm = TRUE 238s na.rm = FALSE 238s na.rm = FALSE 238s na.rm = TRUE 238s na.rm = TRUE 238s > 238s > 238s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 238s > # All NAs 238s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 238s > for (mode in c("integer", "double")) { 238s + x <- matrix(NA_real_, nrow = 10L, ncol = 5L) 238s + cat("mode: ", mode, "\n", sep = "") 238s + storage.mode(x) <- mode 238s + str(x) 238s + 238s + # Test with and without dimnames on x 238s + for (setDimnames in c(TRUE, FALSE)) { 238s + if (setDimnames) dimnames(x) <- dimnames 238s + else dimnames(x) <- NULL 238s + # Row/column variance 238s + for (na.rm in c(FALSE, TRUE)) { 238s + # Check names attribute 238s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 238s + cat("na.rm = ", na.rm, "\n", sep = "") 238s + 238s + r0 <- rowVars_R(x, na.rm = na.rm, useNames = useNames) 238s + r1 <- rowVars(x, na.rm = na.rm, useNames = useNames) 238s + r1b <- rowVars_center(x, na.rm = na.rm, useNames = useNames) 238s + r2 <- colVars(t(x), na.rm = na.rm, useNames = useNames) 238s + r2b <- colVars_center(t(x), na.rm = na.rm, useNames = useNames) 238s + stopifnot(all.equal(r1, r2)) 238s + stopifnot(all.equal(r1, r0)) 238s + stopifnot(all.equal(r2, r0)) 238s + stopifnot(all.equal(r1b, r2b)) 238s + stopifnot( 238s + !any(is.infinite(r0)), 238s + !any(is.infinite(r1)), 238s + !any(is.infinite(r2)), 238s + !any(is.infinite(r1b)), 238s + !any(is.infinite(r2b)) 238s + ) 238s + } 238s + } 238s + } 238s + } 238s mode: integer 238s int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 238s na.rm = FALSE 238s na.rm = FALSE 238s na.rm = TRUE 238s na.rm = TRUE 238s na.rm = FALSE 238s na.rm = FALSE 238s na.rm = TRUE 238s na.rm = TRUE 238s mode: double 238s num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 238s na.rm = FALSE 238s na.rm = FALSE 238s na.rm = TRUE 238s na.rm = TRUE 238s na.rm = FALSE 238s na.rm = FALSE 238s na.rm = TRUE 238s na.rm = TRUE 238s > 238s > 238s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 238s > # A 1x1 matrix 238s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 238s > x <- matrix(0, nrow = 1L, ncol = 1L) 238s > dimnames <- list("a", "A") 238s > # Test with and without dimnames on x 238s > for (setDimnames in c(TRUE, FALSE)) { 238s + if (setDimnames) dimnames(x) <- dimnames 238s + else dimnames(x) <- NULL 238s + # Row/column variance 238s + for (na.rm in c(FALSE, TRUE)) { 238s + # Check names attribute 238s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 238s + cat("na.rm = ", na.rm, "\n", sep = "") 238s + 238s + r0 <- rowVars_R(x, na.rm = na.rm, useNames = useNames) 238s + r1 <- rowVars(x, na.rm = na.rm, useNames = useNames) 238s + r1b <- rowVars_center(x, na.rm = na.rm, useNames = useNames) 238s + r2 <- colVars(t(x), na.rm = na.rm, useNames = useNames) 238s + r2b <- colVars_center(t(x), na.rm = na.rm, useNames = useNames) 238s + stopifnot(all.equal(r1, r2)) 238s + stopifnot(all.equal(r1, r0)) 238s + stopifnot(all.equal(r2, r0)) 238s + stopifnot(all.equal(r1b, r2b)) 238s + stopifnot( 238s + !any(is.infinite(r0)), 238s + !any(is.infinite(r1)), 238s + !any(is.infinite(r2)), 238s + !any(is.infinite(r1b)), 238s + !any(is.infinite(r2b)) 238s + ) 238s + } 238s + } 238s + } 238s na.rm = FALSE 238s na.rm = FALSE 238s na.rm = TRUE 238s na.rm = TRUE 238s na.rm = FALSE 238s na.rm = FALSE 238s na.rm = TRUE 238s na.rm = TRUE 238s > 238s > 238s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 238s > # center and .dim 238s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 238s > m <- matrix(1:12, nrow = 3L, ncol = 4L) 238s > a <- array(m, dim = c(3, 2, 2)) 238s > stopifnot(prod(dim(a)) == prod(dim(m))) 238s > 238s > y0 <- rowVars(m, dim. = dim(m)) 238s > print(y0) 238s [1] 15 15 15 238s > y1 <- rowVars(a, dim. = dim(m)) 238s > print(y1) 238s [1] 15 15 15 238s > stopifnot(identical(y1, y0)) 238s > stopifnot( 238s + !any(is.infinite(y0)), 238s + !any(is.infinite(y1)) 238s + ) 238s > 238s > mu <- rowMeans(m) 238s > y0 <- rowVars(m, center = mu, dim. = dim(m)) 238s > print(y0) 238s [1] 15 15 15 238s > y1 <- rowVars(a, center = mu, dim. = dim(m)) 238s > print(y1) 238s [1] 15 15 15 238s > stopifnot(identical(y1, y0)) 238s > stopifnot( 238s + !any(is.infinite(y0)), 238s + !any(is.infinite(y1)) 238s + ) 238s > 238s > 238s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 238s > # Corner cases 238s > # https://github.com/HenrikBengtsson/matrixStats/issues/195 238s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 238s > x <- matrix(c(1,2,3,4), nrow = 2L, ncol = 2L) 238s > x[1,1] <- NA_real_ 238s > x[1,2] <- Inf 238s > 238s > center <- colMeans2(x, na.rm = TRUE) 238s > y <- colVars(x, center = center, na.rm = TRUE) 238s > stopifnot(!any(is.infinite(y))) 238s > 238s > x <- t(x) 238s > center <- rowMeans2(x, na.rm = TRUE) 238s > y <- rowVars(x, center = center, na.rm = TRUE) 238s > stopifnot(!any(is.infinite(y))) 238s > 238s 238s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 238s Copyright (C) 2024 The R Foundation for Statistical Computing 238s Platform: x86_64-pc-linux-gnu 238s 238s R is free software and comes with ABSOLUTELY NO WARRANTY. 238s You are welcome to redistribute it under certain conditions. 238s Type 'license()' or 'licence()' for distribution details. 238s 238s R is a collaborative project with many contributors. 238s Type 'contributors()' for more information and 238s 'citation()' on how to cite R or R packages in publications. 238s 238s Type 'demo()' for some demos, 'help()' for on-line help, or 238s 'help.start()' for an HTML browser interface to help. 238s Type 'q()' to quit R. 238s 238s > library("matrixStats") 238s > 238s > ## Always allow testing of the 'center' argument (as long as it's not defunct) 238s > options(matrixStats.center.onUse = "ignore") 238s > 238s > ## Create isFALSE() if running on an old version of R 238s > if (!exists("isFALSE", mode="function")) { 238s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 238s + } 238s > 238s > rowVars_R <- function(x, na.rm = FALSE, center = NULL, ..., useNames = NA) { 238s + suppressWarnings({ 238s + res <- apply(x, MARGIN = 1L, FUN = var, na.rm = na.rm) 238s + }) 238s + stopifnot(!any(is.infinite(res))) 238s + 238s + # Keep naming support consistency same as rowVars() 238s + if (is.null(center) || ncol(x) <= 1L) { 238s + if (is.na(useNames) || isFALSE(useNames)) names(res) <- NULL 238s + } 238s + else if (isFALSE(useNames)) names(res) <- NULL 238s + res 238s + } 238s > 238s > colVars_R <- function(x, na.rm = FALSE, center = NULL, ..., useNames = NA) { 238s + suppressWarnings({ 238s + res <- apply(x, MARGIN = 2L, FUN = var, na.rm = na.rm) 238s + }) 238s + stopifnot(!any(is.infinite(res))) 238s + 238s + # Keep naming support consistency same as colVars() 238s + if (is.null(center) || nrow(x) <= 1L) { 238s + if (is.na(useNames) || isFALSE(useNames)) names(res) <- NULL 238s + } 238s + else if (isFALSE(useNames)) names(res) <- NULL 238s + res 238s + } 238s > 238s > 238s > rowVars_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = NA) { 238s + center <- rowWeightedMeans(x, cols = cols, na.rm = na.rm, useNames = FALSE) 238s + res <- rowVars(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 238s + stopifnot(!any(is.infinite(res))) 238s + res 238s + } 238s > 238s > colVars_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = NA) { 238s + center <- colWeightedMeans(x, rows = rows, na.rm = na.rm, useNames = FALSE) 238s + res <- colVars(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 238s + stopifnot(!any(is.infinite(res))) 238s + res 238s + } 238s > 238s > 238s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 238s > # Subsetted tests 238s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 238s > source("utils/validateIndicesFramework.R") 238s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 238s > storage.mode(x) <- "integer" 238s > 238s > # To check names attribute 238s > dimnames <- list(letters[1:6], LETTERS[1:6]) 238s > 238s > # Test with and without dimnames on x 238s > for (setDimnames in c(TRUE, FALSE)) { 238s + if (setDimnames) dimnames(x) <- dimnames 238s + else dimnames(x) <- NULL 238s + 238s + count <- 0L 238s + for (rows in index_cases) { 238s + for (cols in index_cases) { 238s + count <- count + 1L 238s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 238s + useNames <- c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE) 238s + useNames <- useNames[count %% length(useNames) + 1] 238s + 238s + validateIndicesTestMatrix(x, rows, cols, 238s + ftest = rowVars, fsure = rowVars_R, 238s + na.rm = na.rm, useNames = useNames) 238s + validateIndicesTestMatrix(x, rows, cols, 238s + ftest = rowVars_center, fsure = rowVars_R, 238s + na.rm = na.rm, center = TRUE, useNames = useNames) 238s + 238s + validateIndicesTestMatrix(x, rows, cols, 238s + fcoltest = colVars, fsure = rowVars_R, 238s + na.rm = na.rm, useNames = useNames) 238s + validateIndicesTestMatrix(x, rows, cols, 238s + fcoltest = colVars_center, fsure = rowVars_R, 238s + na.rm = na.rm, center = TRUE, useNames = useNames) 238s + } 238s + } 238s + } 239s > 239s 239s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 239s Copyright (C) 2024 The R Foundation for Statistical Computing 239s Platform: x86_64-pc-linux-gnu 239s 239s R is free software and comes with ABSOLUTELY NO WARRANTY. 239s You are welcome to redistribute it under certain conditions. 239s Type 'license()' or 'licence()' for distribution details. 239s 239s R is a collaborative project with many contributors. 239s Type 'contributors()' for more information and 239s 'citation()' on how to cite R or R packages in publications. 239s 239s Type 'demo()' for some demos, 'help()' for on-line help, or 239s 'help.start()' for an HTML browser interface to help. 239s Type 'q()' to quit R. 239s 239s > library("matrixStats") 239s > 239s > ## Create isFALSE() if running on an old version of R 239s > if (!exists("isFALSE", mode="function")) { 239s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 239s + } 239s > 239s > rowWeightedMeans_R <- function(x, w, na.rm = FALSE, ..., useNames = NA) { 239s + res <- apply(x, MARGIN = 1L, FUN = weighted.mean, w = w, na.rm = na.rm, ...) 239s + 239s + # Keep naming support consistency same as rowWeightedMeans() 239s + idxs <- which(is.na(w) | w != 0) 239s + nw <- length(idxs) 239s + if (na.rm) na.rm <- anyMissing(x) 239s + if ((!is.null(w) && nw == 0L) || isFALSE(na.rm)) { 239s + if (is.na(useNames) || !useNames) names(res) <- NULL 239s + } 239s + else if (isFALSE(useNames)) names(res) <- NULL 239s + 239s + res 239s + } 239s > 239s > colWeightedMeans_R <- function(x, w, na.rm = FALSE, ..., useNames = NA) { 239s + res <- apply(x, MARGIN = 2L, FUN = weighted.mean, w = w, na.rm = na.rm, ...) 239s + 239s + # Keep naming support consistency same as colWeightedMeans() 239s + idxs <- which(is.na(w) | w != 0) 239s + nw <- length(idxs) 239s + if (!is.null(w) && nw == 0L) { 239s + if (is.na(useNames) || !useNames) names(res) <- NULL 239s + } 239s + else if (isFALSE(useNames)) names(res) <- NULL 239s + 239s + res 239s + } 239s > 239s > set.seed(1) 239s > 239s > x <- matrix(rnorm(20), nrow = 5, ncol = 4) 239s > print(x) 239s [,1] [,2] [,3] [,4] 239s [1,] -0.6264538 -0.8204684 1.5117812 -0.04493361 239s [2,] 0.1836433 0.4874291 0.3898432 -0.01619026 239s [3,] -0.8356286 0.7383247 -0.6212406 0.94383621 239s [4,] 1.5952808 0.5757814 -2.2146999 0.82122120 239s [5,] 0.3295078 -0.3053884 1.1249309 0.59390132 239s > 239s > # To check names attribute 239s > dimnames <- list(letters[1:5], LETTERS[1:4]) 239s > 239s > # Non-weighted row averages 239s > x_est0 <- rowMeans(x) 239s > x_est1 <- rowWeightedMeans(x) 239s > print(x_est1) 239s [1] 0.004981341 0.261181337 0.056322931 0.194395865 0.435737906 239s > stopifnot(all.equal(x_est1, x_est0)) 239s > x_est2 <- colWeightedMeans(t(x)) 239s > stopifnot(all.equal(x_est2, x_est0)) 239s > # Check names attribute 239s > dimnames(x) <- dimnames 239s > x_est1 <- rowWeightedMeans(x, useNames = FALSE) 239s > x_est2 <- colWeightedMeans(t(x), useNames = FALSE) 239s > stopifnot(all.equal(x_est1, x_est0)) 239s > stopifnot(all.equal(x_est2, x_est0)) 239s > x_est0 <- rowMeans(x) 239s > x_est1 <- rowWeightedMeans(x, useNames = TRUE) 239s > x_est2 <- colWeightedMeans(t(x), useNames = TRUE) 239s > stopifnot(all.equal(x_est1, x_est0)) 239s > stopifnot(all.equal(x_est2, x_est0)) 239s > dimnames(x) <- NULL 239s > 239s > 239s > # Weighted row averages (uniform weights) 239s > w <- rep(2.5, times = ncol(x)) 239s > x_est0 <- rowMeans(x) 239s > x_est1 <- rowWeightedMeans(x, w = w) 239s > print(x_est1) 239s [1] 0.004981341 0.261181337 0.056322931 0.194395865 0.435737906 239s > stopifnot(all.equal(x_est1, x_est0)) 239s > x_est2 <- colWeightedMeans(t(x), w = w) 239s > stopifnot(all.equal(x_est2, x_est0)) 239s > # Test with and without dimnames on x 239s > for (setDimnames in c(TRUE, FALSE)) { 239s + if (setDimnames) dimnames(x) <- dimnames 239s + else dimnames(x) <- NULL 239s + # Check names attribute 239s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 239s + x_est0 <- rowWeightedMeans_R(x, w = w, useNames = useNames) 239s + x_est1 <- rowWeightedMeans(x, w = w, useNames = useNames) 239s + stopifnot(all.equal(x_est1, x_est0)) 239s + x_est0 <- colWeightedMeans_R(t(x), w = w, useNames = useNames) 239s + x_est1 <- colWeightedMeans(t(x), w = w, useNames = useNames) 239s + stopifnot(all.equal(x_est1, x_est0)) 239s + } 239s + } 239s > 239s > 239s > # Weighted row averages (excluding some columns) 239s > w <- c(1, 1, 0, 1) 239s > x_est0 <- rowMeans(x[, (w == 1), drop = FALSE]) 239s > x_est1 <- rowWeightedMeans(x, w = w) 239s > print(x_est1) 239s [1] -0.4972853 0.2182940 0.2821774 0.9974278 0.2060069 239s > stopifnot(all.equal(x_est1, x_est0)) 239s > x_est2 <- colWeightedMeans(t(x), w = w) 239s > stopifnot(all.equal(x_est2, x_est0)) 239s > # Test with and without dimnames on x 239s > for (setDimnames in c(TRUE, FALSE)) { 239s + if (setDimnames) dimnames(x) <- dimnames 239s + else dimnames(x) <- NULL 239s + # Check names attribute 239s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 239s + x_est0 <- rowWeightedMeans_R(x, w = w, useNames = useNames) 239s + x_est1 <- rowWeightedMeans(x, w = w, useNames = useNames) 239s + stopifnot(all.equal(x_est1, x_est0)) 239s + x_est0 <- colWeightedMeans_R(t(x), w = w, useNames = useNames) 239s + x_est1 <- colWeightedMeans(t(x), w = w, useNames = useNames) 239s + stopifnot(all.equal(x_est1, x_est0)) 239s + } 239s + } 239s > 239s > 239s > # Weighted row averages (excluding some columns) 239s > w <- c(0, 1, 0, 0) 239s > x_est0 <- rowMeans(x[, (w == 1), drop = FALSE]) 239s > x_est1 <- rowWeightedMeans(x, w = w) 239s > stopifnot(all.equal(x_est1, x_est0)) 239s > x_est2 <- colWeightedMeans(t(x), w = w) 239s > stopifnot(all.equal(x_est2, x_est0)) 239s > # Test with and without dimnames on x 239s > for (setDimnames in c(TRUE, FALSE)) { 239s + if (setDimnames) dimnames(x) <- dimnames 239s + else dimnames(x) <- NULL 239s + # Check names attribute 239s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 239s + x_est0 <- rowWeightedMeans_R(x, w = w, useNames = useNames) 239s + x_est1 <- rowWeightedMeans(x, w = w, useNames = useNames) 239s + stopifnot(all.equal(x_est1, x_est0)) 239s + x_est0 <- colWeightedMeans_R(t(x), w = w, useNames = useNames) 239s + x_est1 <- colWeightedMeans(t(x), w = w, useNames = useNames) 239s + stopifnot(all.equal(x_est1, x_est0)) 239s + } 239s + } 239s > 239s > 239s > # Weighted row averages (all zero weights) 239s > w <- c(0, 0, 0, 0) 239s > x_est0 <- rowMeans(x[, (w == 1), drop = FALSE]) 239s > x_est1 <- rowWeightedMeans(x, w = w) 239s > stopifnot(all.equal(x_est1, x_est0)) 239s > x_est2 <- colWeightedMeans(t(x), w = w) 239s > stopifnot(all.equal(x_est2, x_est0)) 239s > # Test with and without dimnames on x 239s > for (setDimnames in c(TRUE, FALSE)) { 239s + if (setDimnames) dimnames(x) <- dimnames 239s + else dimnames(x) <- NULL 239s + # Check names attribute 239s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 239s + x_est0 <- rowWeightedMeans_R(x, w = w, useNames = useNames) 239s + x_est1 <- rowWeightedMeans(x, w = w, useNames = useNames) 239s + stopifnot(all.equal(x_est1, x_est0)) 239s + x_est0 <- colWeightedMeans_R(t(x), w = w, useNames = useNames) 239s + x_est1 <- colWeightedMeans(t(x), w = w, useNames = useNames) 239s + stopifnot(all.equal(x_est1, x_est0)) 239s + } 239s + } 239s > 239s > 239s > # Weighted averages by rows and columns 239s > w <- 1:4 239s > x_est1 <- rowWeightedMeans(x, w = w) 239s > print(x_est1) 239s [1] 0.20882185 0.22632701 0.25526439 -0.06123714 0.54691290 239s > x_est2 <- colWeightedMeans(t(x), w = w) 239s > stopifnot(all.equal(x_est2, x_est1)) 239s > # Test with and without dimnames on x 239s > for (setDimnames in c(TRUE, FALSE)) { 239s + if (setDimnames) dimnames(x) <- dimnames 239s + else dimnames(x) <- NULL 239s + # Check names attribute 239s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 239s + x_est0 <- rowWeightedMeans_R(x, w = w, useNames = useNames) 239s + x_est1 <- rowWeightedMeans(x, w = w, useNames = useNames) 239s + stopifnot(all.equal(x_est1, x_est0)) 239s + x_est0 <- colWeightedMeans_R(t(x), w = w, useNames = useNames) 239s + x_est1 <- colWeightedMeans(t(x), w = w, useNames = useNames) 239s + stopifnot(all.equal(x_est1, x_est0)) 239s + } 239s + } 239s > 239s > 239s > x[sample(length(x), size = 0.3 * length(x))] <- NA 239s > print(x) 239s [,1] [,2] [,3] [,4] 239s [1,] -0.6264538 NA 1.5117812 -0.04493361 239s [2,] 0.1836433 NA NA -0.01619026 239s [3,] -0.8356286 0.7383247 -0.6212406 0.94383621 239s [4,] 1.5952808 NA -2.2146999 0.82122120 239s [5,] 0.3295078 NA NA 0.59390132 239s > 239s > # Non-weighted row averages with missing values 239s > x_est0 <- rowMeans(x, na.rm = TRUE) 239s > x_est1 <- rowWeightedMeans(x, na.rm = TRUE) 239s > print(x_est1) 239s [1] 0.28013125 0.08372653 0.05632293 0.06726737 0.46170455 239s > stopifnot(all.equal(x_est1, x_est0)) 239s > x_est2 <- colWeightedMeans(t(x), na.rm = TRUE) 239s > stopifnot(all.equal(x_est2, x_est0)) 239s > # Check names attribute 239s > dimnames(x) <- dimnames 239s > x_est1 <- rowWeightedMeans(x, na.rm = TRUE, useNames = FALSE) 239s > x_est2 <- colWeightedMeans(t(x), na.rm = TRUE, useNames = FALSE) 239s > stopifnot(all.equal(x_est1, x_est0)) 239s > stopifnot(all.equal(x_est2, x_est0)) 239s > x_est0 <- rowMeans(x, na.rm = TRUE) 239s > x_est1 <- rowWeightedMeans(x, na.rm = TRUE, useNames = TRUE) 239s > x_est2 <- colWeightedMeans(t(x), na.rm = TRUE, useNames = TRUE) 239s > stopifnot(all.equal(x_est1, x_est0)) 239s > stopifnot(all.equal(x_est2, x_est0)) 239s > dimnames(x) <- NULL 239s > 239s > 239s > # Weighted row averages with missing values 239s > x_est0 <- apply(x, MARGIN = 1L, FUN = weighted.mean, w = w, na.rm = TRUE) 239s > print(x_est0) 239s [1] 0.46614441 0.02377645 0.25526439 -0.22049176 0.54102261 239s > x_est1 <- rowWeightedMeans(x, w = w, na.rm = TRUE) 239s > print(x_est1) 239s [1] 0.46614441 0.02377645 0.25526439 -0.22049176 0.54102261 239s > stopifnot(all.equal(x_est1, x_est0)) 239s > x_est2 <- colWeightedMeans(t(x), w = w, na.rm = TRUE) 239s > stopifnot(all.equal(x_est2, x_est0)) 239s > # Test with and without dimnames on x 239s > for (setDimnames in c(TRUE, FALSE)) { 239s + if (setDimnames) dimnames(x) <- dimnames 239s + else dimnames(x) <- NULL 239s + # Check names attribute 239s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 239s + x_est0 <- rowWeightedMeans_R(x, w = w, na.rm = TRUE, useNames = useNames) 239s + x_est1 <- rowWeightedMeans(x, w = w, na.rm = TRUE, useNames = useNames) 239s + stopifnot(all.equal(x_est1, x_est0)) 239s + x_est0 <- colWeightedMeans_R(t(x), w = w, na.rm = TRUE, useNames = useNames) 239s + x_est1 <- colWeightedMeans(t(x), w = w, na.rm = TRUE, useNames = useNames) 239s + stopifnot(all.equal(x_est1, x_est0)) 239s + } 239s + } 239s > 239s > 239s > # Weighted averages by rows and columns 239s > w <- 1:4 239s > x_est1 <- rowWeightedMeans(x, w = w, na.rm = TRUE) 239s > x_est2 <- colWeightedMeans(t(x), w = w, na.rm = TRUE) 239s > stopifnot(all.equal(x_est2, x_est1)) 239s > # Test with and without dimnames on x 239s > for (setDimnames in c(TRUE, FALSE)) { 239s + if (setDimnames) dimnames(x) <- dimnames 239s + else dimnames(x) <- NULL 239s + # Check names attribute 239s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 239s + x_est0 <- rowWeightedMeans_R(x, w = w, na.rm = TRUE, useNames = useNames) 239s + x_est1 <- rowWeightedMeans(x, w = w, na.rm = TRUE, useNames = useNames) 239s + stopifnot(all.equal(x_est1, x_est0)) 239s + x_est0 <- colWeightedMeans_R(t(x), w = w, na.rm = TRUE, useNames = useNames) 239s + x_est1 <- colWeightedMeans(t(x), w = w, na.rm = TRUE, useNames = useNames) 239s + stopifnot(all.equal(x_est1, x_est0)) 239s + } 239s + } 239s > 239s > 239s > # w contains missing value 239s > w[1] <- NA_integer_ 239s > x_est1 <- rowWeightedMeans(x, w = w, na.rm = TRUE) 239s > x_est2 <- colWeightedMeans(t(x), w = w, na.rm = TRUE) 239s > stopifnot(all.equal(x_est2, x_est1)) 239s > # Test with and without dimnames on x 239s > for (setDimnames in c(TRUE, FALSE)) { 239s + if (setDimnames) dimnames(x) <- dimnames 239s + else dimnames(x) <- NULL 239s + # Check names attribute 239s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 239s + x_est0 <- rowWeightedMeans_R(x, w = w, na.rm = TRUE, useNames = useNames) 239s + x_est1 <- rowWeightedMeans(x, w = w, na.rm = TRUE, useNames = useNames) 239s + stopifnot(all.equal(x_est1, x_est0)) 239s + x_est0 <- colWeightedMeans_R(t(x), w = w, na.rm = TRUE, useNames = useNames) 239s + x_est1 <- colWeightedMeans(t(x), w = w, na.rm = TRUE, useNames = useNames) 239s + stopifnot(all.equal(x_est1, x_est0)) 239s + } 239s + } 240s > 240s > x_est1 <- rowWeightedMeans(x, w = w, na.rm = FALSE) 240s > x_est2 <- colWeightedMeans(t(x), w = w, na.rm = FALSE) 240s > stopifnot(all.equal(x_est2, x_est1)) 240s > # Test with and without dimnames on x 240s > for (setDimnames in c(TRUE, FALSE)) { 240s + if (setDimnames) dimnames(x) <- dimnames 240s + else dimnames(x) <- NULL 240s + # Check names attribute 240s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 240s + x_est0 <- rowWeightedMeans_R(x, w = w, na.rm = FALSE, useNames = useNames) 240s + x_est1 <- rowWeightedMeans(x, w = w, na.rm = FALSE, useNames = useNames) 240s + stopifnot(all.equal(x_est1, x_est0)) 240s + x_est0 <- colWeightedMeans_R(t(x), w = w, na.rm = FALSE, useNames = useNames) 240s + x_est1 <- colWeightedMeans(t(x), w = w, na.rm = FALSE, useNames = useNames) 240s + stopifnot(all.equal(x_est1, x_est0)) 240s + } 240s + } 240s > 240s 240s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 240s Copyright (C) 2024 The R Foundation for Statistical Computing 240s Platform: x86_64-pc-linux-gnu 240s 240s R is free software and comes with ABSOLUTELY NO WARRANTY. 240s You are welcome to redistribute it under certain conditions. 240s Type 'license()' or 'licence()' for distribution details. 240s 240s R is a collaborative project with many contributors. 240s Type 'contributors()' for more information and 240s 'citation()' on how to cite R or R packages in publications. 240s 240s Type 'demo()' for some demos, 'help()' for on-line help, or 240s 'help.start()' for an HTML browser interface to help. 240s Type 'q()' to quit R. 240s 240s > library("matrixStats") 240s > 240s > ## Create isFALSE() if running on an old version of R 240s > if (!exists("isFALSE", mode="function")) { 240s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 240s + } 240s > 240s > rowWeightedMeans_R <- function(x, w, na.rm = FALSE, ..., useNames = NA) { 240s + res <- apply(x, MARGIN = 1L, FUN = weighted.mean, w = w, na.rm = na.rm, ...) 240s + 240s + # Keep naming support consistency same as rowWeightedMeans() 240s + idxs <- which(is.na(w) | w != 0) 240s + nw <- length(idxs) 240s + if (na.rm) na.rm <- anyMissing(x) 240s + if ((!is.null(w) && nw == 0L) || isFALSE(na.rm)) { 240s + if (is.na(useNames) || !useNames) names(res) <- NULL 240s + } 240s + else if (isFALSE(useNames)) names(res) <- NULL 240s + 240s + res 240s + } 240s > 240s > colWeightedMeans_R <- function(x, w, na.rm = FALSE, ..., useNames = NA) { 240s + res <- apply(x, MARGIN = 1L, FUN = weighted.mean, w = w, na.rm = na.rm, ...) 240s + 240s + # Keep naming support consistency same as colWeightedMeans() 240s + idxs <- which(is.na(w) | w != 0) 240s + nw <- length(idxs) 240s + if (!is.null(w) && nw == 0L) { 240s + if (is.na(useNames) || !useNames) names(res) <- NULL 240s + } 240s + else if (isFALSE(useNames)) names(res) <- NULL 240s + 240s + res 240s + } 240s > 240s > 240s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 240s > # Subsetted tests 240s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 240s > source("utils/validateIndicesFramework.R") 240s > # To check names attribute 240s > dimnames <- list(letters[1:6], LETTERS[1:6]) 240s > for (mode in c("numeric", "integer", "logical")) { 240s + x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 240s + w <- runif(6, min = 0, max = 6) 240s + storage.mode(x) <- mode 240s + storage.mode(w) <- if (mode == "logical") "integer" else mode 240s + if (mode == "numeric") w[1] <- Inf 240s + 240s + # Test with and without dimnames on x 240s + for (setDimnames in c(TRUE, FALSE)) { 240s + if (setDimnames) dimnames(x) <- dimnames 240s + else dimnames(x) <- NULL 240s + 240s + count <- 0L 240s + for (rows in index_cases) { 240s + for (cols in index_cases) { 240s + count <- count + 1L 240s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 240s + useNames <- c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE) 240s + useNames <- useNames[count %% length(useNames) + 1] 240s + 240s + validateIndicesTestMatrix_w(x, w, rows, cols, 240s + ftest = rowWeightedMeans, fsure = rowWeightedMeans_R, 240s + na.rm = na.rm, useNames = useNames) 240s + validateIndicesTestMatrix_w(x, w, rows, cols, 240s + fcoltest = colWeightedMeans, fsure = colWeightedMeans_R, 240s + na.rm = na.rm, useNames = useNames) 240s + } 240s + } 240s + } 240s + } 241s > 241s 241s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 241s Copyright (C) 2024 The R Foundation for Statistical Computing 241s Platform: x86_64-pc-linux-gnu 241s 241s R is free software and comes with ABSOLUTELY NO WARRANTY. 241s You are welcome to redistribute it under certain conditions. 241s Type 'license()' or 'licence()' for distribution details. 241s 241s R is a collaborative project with many contributors. 241s Type 'contributors()' for more information and 241s 'citation()' on how to cite R or R packages in publications. 241s 241s Type 'demo()' for some demos, 'help()' for on-line help, or 241s 'help.start()' for an HTML browser interface to help. 241s Type 'q()' to quit R. 241s 241s > library("matrixStats") 241s > 241s > ## Create isFALSE() if running on an old version of R 241s > if (!exists("isFALSE", mode="function")) { 241s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 241s + } 241s > 241s > rowWeightedMedians_R <- function(x, w, na.rm = FALSE, ..., useNames = NA) { 241s + res <- apply(x, MARGIN = 1L, FUN = weightedMedian, w = w, na.rm = na.rm, ...) 241s + 241s + # Keep naming support consistency same as rowWeightedMedians() 241s + if (!is.null(w)) { 241s + if (isFALSE(useNames)) names(res) <- NULL 241s + } 241s + else if (is.na(useNames) || !useNames) names(res) <- NULL 241s + 241s + res 241s + } 241s > 241s > colWeightedMedians_R <- function(x, w, na.rm = FALSE, ..., useNames = NA) { 241s + res <- apply(x, MARGIN = 2L, FUN = weightedMedian, w = w, na.rm = na.rm, ...) 241s + 241s + # Keep naming support consistency same as colWeightedMedians() 241s + if (!is.null(w)) { 241s + if (isFALSE(useNames)) names(res) <- NULL 241s + } 241s + else if (is.na(useNames) || !useNames) names(res) <- NULL 241s + 241s + res 241s + } 241s > 241s > set.seed(1) 241s > 241s > x <- matrix(rnorm(20), nrow = 5, ncol = 4) 241s > print(x) 241s [,1] [,2] [,3] [,4] 241s [1,] -0.6264538 -0.8204684 1.5117812 -0.04493361 241s [2,] 0.1836433 0.4874291 0.3898432 -0.01619026 241s [3,] -0.8356286 0.7383247 -0.6212406 0.94383621 241s [4,] 1.5952808 0.5757814 -2.2146999 0.82122120 241s [5,] 0.3295078 -0.3053884 1.1249309 0.59390132 241s > 241s > # To check names attribute 241s > dimnames <- list(letters[1:5], LETTERS[1:4]) 241s > 241s > # Non-weighted row medians 241s > x_est0 <- rowMedians(x) 241s > x_est1 <- rowWeightedMedians(x) 241s > stopifnot(all.equal(x_est1, x_est0)) 241s > x_est2 <- colWeightedMedians(t(x)) 241s > stopifnot(all.equal(x_est2, x_est0)) 241s > # Test with and without dimnames on x 241s > for (setDimnames in c(TRUE, FALSE)) { 241s + if (setDimnames) dimnames(x) <- dimnames 241s + else dimnames(x) <- NULL 241s + # Check names attribute 241s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 241s + x_est0 <- rowMedians(x, useNames = useNames) 241s + x_est1 <- rowWeightedMedians(x, useNames = useNames) 241s + x_est2 <- colWeightedMedians(t(x), useNames = useNames) 241s + stopifnot(all.equal(x_est1, x_est0)) 241s + stopifnot(all.equal(x_est2, x_est0)) 241s + } 241s + } 241s > 241s > 241s > # Weighted row medians (uniform weights) 241s > w <- rep(2.5, times = ncol(x)) 241s > x_est0 <- rowMedians(x) 241s > x_est1 <- rowWeightedMedians(x, w = w) 241s > stopifnot(all.equal(x_est1, x_est0)) 241s > x_est2 <- colWeightedMedians(t(x), w = w) 241s > stopifnot(all.equal(x_est2, x_est0)) 241s > # Test with and without dimnames on x 241s > for (setDimnames in c(TRUE, FALSE)) { 241s + if (setDimnames) dimnames(x) <- dimnames 241s + else dimnames(x) <- NULL 241s + # Check names attribute 241s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 241s + x_est0 <- rowWeightedMedians_R(x, w = w, useNames = useNames) 241s + x_est1 <- rowWeightedMedians(x, w = w, useNames = useNames) 241s + stopifnot(all.equal(x_est1, x_est0)) 241s + x_est0 <- colWeightedMedians_R(t(x), w = w, useNames = useNames) 241s + x_est1 <- colWeightedMedians(t(x), w = w, useNames = useNames) 241s + stopifnot(all.equal(x_est1, x_est0)) 241s + } 241s + } 241s > 241s > 241s > # Weighted row medians (excluding some columns) 241s > w <- c(1, 1, 0, 1) 241s > x_est0 <- rowMedians(x[, (w == 1), drop = FALSE]) 241s > x_est1 <- rowWeightedMedians(x, w = w) 241s > stopifnot(all.equal(x_est1, x_est0)) 241s > x_est2 <- colWeightedMedians(t(x), w = w) 241s > stopifnot(all.equal(x_est2, x_est0)) 241s > # Test with and without dimnames on x 241s > for (setDimnames in c(TRUE, FALSE)) { 241s + if (setDimnames) dimnames(x) <- dimnames 241s + else dimnames(x) <- NULL 241s + # Check names attribute 241s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 241s + x_est0 <- rowWeightedMedians_R(x, w = w, useNames = useNames) 241s + x_est1 <- rowWeightedMedians(x, w = w, useNames = useNames) 241s + stopifnot(all.equal(x_est1, x_est0)) 241s + x_est0 <- colWeightedMedians_R(t(x), w = w, useNames = useNames) 241s + x_est1 <- colWeightedMedians(t(x), w = w, useNames = useNames) 241s + stopifnot(all.equal(x_est1, x_est0)) 241s + } 241s + } 241s > 241s > # Weighted row medians (excluding some columns) 241s > w <- c(0, 1, 0, 0) 241s > x_est0 <- rowMedians(x[, (w == 1), drop = FALSE]) 241s > x_est1 <- rowWeightedMedians(x, w = w) 241s > stopifnot(all.equal(x_est1, x_est0)) 241s > x_est2 <- colWeightedMedians(t(x), w = w) 241s > stopifnot(all.equal(x_est2, x_est0)) 241s > # Test with and without dimnames on x 241s > for (setDimnames in c(TRUE, FALSE)) { 241s + if (setDimnames) dimnames(x) <- dimnames 241s + else dimnames(x) <- NULL 241s + # Check names attribute 241s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 241s + x_est0 <- rowWeightedMedians_R(x, w = w, useNames = useNames) 241s + x_est1 <- rowWeightedMedians(x, w = w, useNames = useNames) 241s + stopifnot(all.equal(x_est1, x_est0)) 241s + x_est0 <- colWeightedMedians_R(t(x), w = w, useNames = useNames) 241s + x_est1 <- colWeightedMedians(t(x), w = w, useNames = useNames) 241s + stopifnot(all.equal(x_est1, x_est0)) 241s + } 241s + } 241s > 241s > # Weighted row medians (all zero weights) 241s > w <- c(0, 0, 0, 0) 241s > x_est0 <- rowMedians(x[, (w == 1), drop = FALSE]) 241s > x_est1 <- rowWeightedMedians(x, w = w) 241s > stopifnot(all.equal(x_est1, x_est0)) 241s > x_est2 <- colWeightedMedians(t(x), w = w) 241s > stopifnot(all.equal(x_est2, x_est0)) 241s > # Test with and without dimnames on x 241s > for (setDimnames in c(TRUE, FALSE)) { 241s + if (setDimnames) dimnames(x) <- dimnames 241s + else dimnames(x) <- NULL 241s + # Check names attribute 241s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 241s + x_est0 <- rowWeightedMedians_R(x, w = w, useNames = useNames) 241s + x_est1 <- rowWeightedMedians(x, w = w, useNames = useNames) 241s + stopifnot(all.equal(x_est1, x_est0)) 241s + x_est0 <- colWeightedMedians_R(t(x), w = w, useNames = useNames) 241s + x_est1 <- colWeightedMedians(t(x), w = w, useNames = useNames) 241s + stopifnot(all.equal(x_est1, x_est0)) 241s + } 241s + } 241s > 241s > # Weighted medians by rows and columns 241s > w <- 1:4 241s > x_est1 <- rowWeightedMedians(x, w = w) 241s > x_est2 <- colWeightedMedians(t(x), w = w) 241s > stopifnot(all.equal(x_est2, x_est1)) 241s > # Test with and without dimnames on x 241s > for (setDimnames in c(TRUE, FALSE)) { 241s + if (setDimnames) dimnames(x) <- dimnames 241s + else dimnames(x) <- NULL 241s + # Check names attribute 241s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 241s + x_est0 <- rowWeightedMedians_R(x, w = w, useNames = useNames) 241s + x_est1 <- rowWeightedMedians(x, w = w, useNames = useNames) 241s + stopifnot(all.equal(x_est1, x_est0)) 241s + x_est0 <- colWeightedMedians_R(t(x), w = w, useNames = useNames) 241s + x_est1 <- colWeightedMedians(t(x), w = w, useNames = useNames) 241s + stopifnot(all.equal(x_est1, x_est0)) 241s + } 241s + } 241s > 241s > 241s > # Weighted row medians with missing values 241s > x_est0 <- apply(x, MARGIN = 1L, FUN = weightedMedian, w = w, na.rm = TRUE) 241s > print(x_est0) 241s [1] -0.04493361 0.23519330 0.73832471 0.65759463 0.59390132 241s > x_est1 <- rowWeightedMedians(x, w = w, na.rm = TRUE) 241s > print(x_est1) 241s [1] -0.04493361 0.23519330 0.73832471 0.65759463 0.59390132 241s > stopifnot(all.equal(x_est1, x_est0)) 241s > x_est2 <- colWeightedMedians(t(x), w = w) 241s > stopifnot(all.equal(x_est2, x_est0)) 241s > # Test with and without dimnames on x 241s > for (setDimnames in c(TRUE, FALSE)) { 241s + if (setDimnames) dimnames(x) <- dimnames 241s + else dimnames(x) <- NULL 241s + # Check names attribute 241s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 241s + x_est0 <- rowWeightedMedians_R(x, w = w, na.rm = TRUE, useNames = useNames) 241s + x_est1 <- rowWeightedMedians(x, w = w, na.rm = TRUE, useNames = useNames) 241s + stopifnot(all.equal(x_est1, x_est0)) 241s + x_est0 <- colWeightedMedians_R(t(x), w = w, na.rm = TRUE, useNames = useNames) 241s + x_est1 <- colWeightedMedians(t(x), w = w, na.rm = TRUE, useNames = useNames) 241s + stopifnot(all.equal(x_est1, x_est0)) 241s + } 241s + } 241s > 241s > # Weighted medians by rows and columns 241s > w <- 1:4 241s > x_est1 <- rowWeightedMedians(x, w = w, na.rm = TRUE) 241s > x_est2 <- colWeightedMedians(t(x), w = w, na.rm = TRUE) 241s > stopifnot(all.equal(x_est2, x_est1)) 241s > # Test with and without dimnames on x 241s > for (setDimnames in c(TRUE, FALSE)) { 241s + if (setDimnames) dimnames(x) <- dimnames 241s + else dimnames(x) <- NULL 241s + # Check names attribute 241s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 241s + x_est0 <- rowWeightedMedians_R(x, w = w, na.rm = TRUE, useNames = useNames) 241s + x_est1 <- rowWeightedMedians(x, w = w, na.rm = TRUE, useNames = useNames) 241s + stopifnot(all.equal(x_est1, x_est0)) 241s + x_est0 <- colWeightedMedians_R(t(x), w = w, na.rm = TRUE, useNames = useNames) 241s + x_est1 <- colWeightedMedians(t(x), w = w, na.rm = TRUE, useNames = useNames) 241s + stopifnot(all.equal(x_est1, x_est0)) 241s + } 241s + } 241s > 241s > 241s > # Inf weight 241s > x <- matrix(1:2, nrow = 1, ncol = 2) 241s > w <- c(7, Inf) 241s > x_est1 <- rowWeightedMedians(x, w = w) 241s > x_est2 <- colWeightedMedians(t(x), w = w) 241s > stopifnot(identical(2, x_est1)) 241s > stopifnot(identical(2, x_est2)) 241s > # Test with and without dimnames on x 241s > dimnames <- list("a", LETTERS[1:2]) 241s > for (setDimnames in c(TRUE, FALSE)) { 241s + if (setDimnames) dimnames(x) <- dimnames 241s + else dimnames(x) <- NULL 241s + # Check names attribute 241s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 241s + x_est0 <- rowWeightedMedians_R(x, w = w, useNames = useNames) 241s + x_est1 <- rowWeightedMedians(x, w = w, useNames = useNames) 241s + stopifnot(all.equal(x_est1, x_est0)) 241s + x_est0 <- colWeightedMedians_R(t(x), w = w, useNames = useNames) 241s + x_est1 <- colWeightedMedians(t(x), w = w, useNames = useNames) 241s + stopifnot(all.equal(x_est1, x_est0)) 241s + } 241s + } 241s > 241s 241s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 241s Copyright (C) 2024 The R Foundation for Statistical Computing 241s Platform: x86_64-pc-linux-gnu 241s 241s R is free software and comes with ABSOLUTELY NO WARRANTY. 241s You are welcome to redistribute it under certain conditions. 241s Type 'license()' or 'licence()' for distribution details. 241s 241s R is a collaborative project with many contributors. 241s Type 'contributors()' for more information and 241s 'citation()' on how to cite R or R packages in publications. 241s 241s Type 'demo()' for some demos, 'help()' for on-line help, or 241s 'help.start()' for an HTML browser interface to help. 241s Type 'q()' to quit R. 241s 241s > library("matrixStats") 241s > 241s > ## Create isFALSE() if running on an old version of R 241s > if (!exists("isFALSE", mode="function")) { 241s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 241s + } 241s > 241s > rowWeightedMedians_R <- function(x, w, na.rm = FALSE, ..., useNames = NA) { 241s + res <- apply(x, MARGIN = 1L, FUN = weightedMedian, w = w, na.rm = na.rm, ...) 241s + 241s + # Keep naming support consistency same as rowWeightedMedians() 241s + if (!is.null(w)) { 241s + if (isFALSE(useNames)) names(res) <- NULL 241s + } 241s + else if (is.na(useNames) || !useNames) names(res) <- NULL 241s + 241s + res 241s + } 241s > 241s > 241s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 241s > # Subsetted tests 241s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 241s > source("utils/validateIndicesFramework.R") 241s > # To check names attribute 241s > dimnames <- list(letters[1:6], LETTERS[1:6]) 241s > for (mode in c("numeric", "integer", "logical")) { 241s + x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 241s + w <- runif(6, min = 0, max = 6) 241s + storage.mode(x) <- mode 241s + storage.mode(w) <- if (mode == "logical") "integer" else mode 241s + if (mode == "numeric") w[1] <- Inf 241s + 241s + # Test with and without dimnames on x 241s + for (setDimnames in c(TRUE, FALSE)) { 241s + if (setDimnames) dimnames(x) <- dimnames 241s + else dimnames(x) <- NULL 241s + 241s + count <- 0L 241s + for (rows in index_cases) { 241s + for (cols in index_cases) { 241s + count <- count + 1L 241s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 241s + useNames <- c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE) 241s + useNames <- useNames[count %% length(useNames) + 1] 241s + 241s + validateIndicesTestMatrix_w(x, w, rows, cols, 241s + ftest = rowWeightedMedians, 241s + fsure = rowWeightedMedians_R, 241s + na.rm = na.rm, useNames = useNames) 241s + validateIndicesTestMatrix_w(x, w, rows, cols, 241s + fcoltest = colWeightedMedians, 241s + fsure = rowWeightedMedians_R, 241s + na.rm = na.rm, useNames = useNames) 241s + } 241s + } 241s + } 241s + } 242s > 242s 242s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 242s Copyright (C) 2024 The R Foundation for Statistical Computing 242s Platform: x86_64-pc-linux-gnu 242s 242s R is free software and comes with ABSOLUTELY NO WARRANTY. 242s You are welcome to redistribute it under certain conditions. 242s Type 'license()' or 'licence()' for distribution details. 242s 242s R is a collaborative project with many contributors. 242s Type 'contributors()' for more information and 242s 'citation()' on how to cite R or R packages in publications. 242s 242s Type 'demo()' for some demos, 'help()' for on-line help, or 242s 'help.start()' for an HTML browser interface to help. 242s Type 'q()' to quit R. 242s 242s > library("matrixStats") 242s > 242s > set.seed(1) 242s > 242s > x <- matrix(rnorm(20), nrow = 5L, ncol = 4L) 242s > print(x) 242s [,1] [,2] [,3] [,4] 242s [1,] -0.6264538 -0.8204684 1.5117812 -0.04493361 242s [2,] 0.1836433 0.4874291 0.3898432 -0.01619026 242s [3,] -0.8356286 0.7383247 -0.6212406 0.94383621 242s [4,] 1.5952808 0.5757814 -2.2146999 0.82122120 242s [5,] 0.3295078 -0.3053884 1.1249309 0.59390132 242s > 242s > # To check names attribute 242s > dimnames <- list(letters[1:5], LETTERS[1:4]) 242s > 242s > # Weighted row variances (uniform weights - all w = 1) 242s > # Non-weighted row variances 242s > x_est0 <- rowVars(x) 242s > w <- rep(1, times = ncol(x)) 242s > x_est1 <- rowWeightedVars(x, w = w) 242s > print(x_est1) 242s [1] 1.11767161 0.05022969 0.83582537 2.76819528 0.35351857 242s > stopifnot(all.equal(x_est1, x_est0)) 242s > x_est2 <- colWeightedVars(t(x), w = w) 242s > stopifnot(all.equal(x_est2, x_est0)) 242s > # Check names attribute 242s > dimnames(x) <- dimnames 242s > x_est1 <- rowWeightedVars(x, w = w, useNames = FALSE) 242s > x_est2 <- colWeightedVars(t(x), w = w, useNames = FALSE) 242s > stopifnot(all.equal(x_est1, x_est0)) 242s > stopifnot(all.equal(x_est2, x_est0)) 242s > x_est0 <- rowVars(x, useNames = TRUE) 242s > if (!matrixStats:::isUseNamesNADefunct()) { 242s + x_est1 <- rowWeightedVars(x, w = w, useNames = NA) 242s + x_est2 <- colWeightedVars(t(x), w = w, useNames = NA) 242s + stopifnot(all.equal(x_est1, x_est0)) 242s + stopifnot(all.equal(x_est2, x_est0)) 242s + } 242s > x_est1 <- rowWeightedVars(x, w = w, useNames = TRUE) 242s > x_est2 <- colWeightedVars(t(x), w = w, useNames = TRUE) 242s > stopifnot(all.equal(x_est1, x_est0)) 242s > stopifnot(all.equal(x_est2, x_est0)) 242s > dimnames(x) <- NULL 242s > 242s > 242s > # Weighted row variances (uniform weights - all w = 3) 242s > x3 <- cbind(x, x, x) 242s > x_est0 <- rowVars(x3) 242s > w <- rep(3, times = ncol(x)) 242s > x_est1 <- rowWeightedVars(x, w = w) 242s > print(x_est1) 242s [1] 0.91445859 0.04109702 0.68385712 2.26488705 0.28924246 242s > stopifnot(all.equal(x_est1, x_est0)) 242s > x_est2 <- colWeightedVars(t(x), w = w) 242s > stopifnot(all.equal(x_est2, x_est0)) 242s > # Check names attribute 242s > dimnames(x) <- dimnames 242s > x_est1 <- rowWeightedVars(x, w = w, useNames = FALSE) 242s > x_est2 <- colWeightedVars(t(x), w = w, useNames = FALSE) 242s > stopifnot(all.equal(x_est1, x_est0)) 242s > stopifnot(all.equal(x_est2, x_est0)) 242s > x3 <- cbind(x, x, x) 242s > x_est0 <- rowVars(x3, useNames = TRUE) 242s > if (!matrixStats:::isUseNamesNADefunct()) { 242s + x_est1 <- rowWeightedVars(x, w = w, useNames = NA) 242s + x_est2 <- colWeightedVars(t(x), w = w, useNames = NA) 242s + stopifnot(all.equal(x_est1, x_est0)) 242s + stopifnot(all.equal(x_est2, x_est0)) 242s + } 242s > x_est1 <- rowWeightedVars(x, w = w, useNames = TRUE) 242s > x_est2 <- colWeightedVars(t(x), w = w, useNames = TRUE) 242s > stopifnot(all.equal(x_est1, x_est0)) 242s > stopifnot(all.equal(x_est2, x_est0)) 242s > dimnames(x) <- NULL 242s > 242s > 242s > # Weighted row variances (excluding some columns) 242s > w <- c(1, 1, 0, 1) 242s > x_est0 <- rowVars(x[, (w == 1), drop = FALSE]) 242s > x_est1 <- rowWeightedVars(x, w = w) 242s > print(x_est1) 242s [1] 0.16287693 0.06430861 0.94767651 0.28313135 0.21361984 242s > stopifnot(all.equal(x_est1, x_est0)) 242s > x_est2 <- colWeightedVars(t(x), w = w) 242s > stopifnot(all.equal(x_est2, x_est0)) 242s > # Check names attribute 242s > dimnames(x) <- dimnames 242s > x_est1 <- rowWeightedVars(x, w = w, useNames = FALSE) 242s > x_est2 <- colWeightedVars(t(x), w = w, useNames = FALSE) 242s > stopifnot(all.equal(x_est1, x_est0)) 242s > stopifnot(all.equal(x_est2, x_est0)) 242s > x_est0 <- rowVars(x[, (w == 1), drop = FALSE], useNames = TRUE) 242s > if (!matrixStats:::isUseNamesNADefunct()) { 242s + x_est1 <- rowWeightedVars(x, w = w, useNames = NA) 242s + x_est2 <- colWeightedVars(t(x), w = w, useNames = NA) 242s + stopifnot(all.equal(x_est1, x_est0)) 242s + stopifnot(all.equal(x_est2, x_est0)) 242s + } 242s > x_est1 <- rowWeightedVars(x, w = w, useNames = TRUE) 242s > x_est2 <- colWeightedVars(t(x), w = w, useNames = TRUE) 242s > stopifnot(all.equal(x_est1, x_est0)) 242s > stopifnot(all.equal(x_est2, x_est0)) 242s > dimnames(x) <- NULL 242s > 242s > 242s > # Weighted row variances (excluding some columns) 242s > w <- c(0, 1, 0, 0) 242s > x_est0 <- rowVars(x[, (w == 1), drop = FALSE]) 242s > x_est1 <- rowWeightedVars(x, w = w) 242s > #stopifnot(all.equal(x_est1, x_est0)) 242s > x_est2 <- colWeightedVars(t(x), w = w) 242s > stopifnot(all.equal(x_est2, x_est1)) 242s > # Check names attribute 242s > dimnames(x) <- dimnames 242s > x_est1 <- rowWeightedVars(x, w = w, useNames = FALSE) 242s > x_est2 <- colWeightedVars(t(x), w = w, useNames = FALSE) 242s > stopifnot(all.equal(x_est1, x_est0)) 242s > stopifnot(all.equal(x_est2, x_est0)) 242s > x_est0 <- rowVars(x[, (w == 1), drop = FALSE], useNames = TRUE) 242s > if (!matrixStats:::isUseNamesNADefunct()) { 242s + x_est1 <- rowWeightedVars(x, w = w, useNames = NA) 242s + x_est2 <- colWeightedVars(t(x), w = w, useNames = NA) 242s + stopifnot(all.equal(x_est1, x_est0)) 242s + stopifnot(all.equal(x_est2, x_est0)) 242s + } 242s > x_est1 <- rowWeightedVars(x, w = w, useNames = TRUE) 242s > x_est2 <- colWeightedVars(t(x), w = w, useNames = TRUE) 242s > stopifnot(all.equal(x_est1, x_est0)) 242s > stopifnot(all.equal(x_est2, x_est0)) 242s > dimnames(x) <- NULL 242s > 242s > 242s > # Weighted row variances (all zero weights) 242s > w <- c(0, 0, 0, 0) 242s > x_est0 <- rowVars(x[, (w == 1), drop = FALSE]) 242s > x_est1 <- rowWeightedVars(x, w = w) 242s > stopifnot(all.equal(x_est1, x_est0)) 242s > x_est2 <- colWeightedVars(t(x), w = w) 242s > stopifnot(all.equal(x_est2, x_est0)) 242s > # Check names attribute 242s > dimnames(x) <- dimnames 242s > x_est1 <- rowWeightedVars(x, w = w, useNames = FALSE) 242s > x_est2 <- colWeightedVars(t(x), w = w, useNames = FALSE) 242s > stopifnot(all.equal(x_est1, x_est0)) 242s > stopifnot(all.equal(x_est2, x_est0)) 242s > x_est0 <- rowVars(x[, (w == 1), drop = FALSE], useNames = TRUE) 242s > if (!matrixStats:::isUseNamesNADefunct()) { 242s + x_est1 <- rowWeightedVars(x, w = w, useNames = NA) 242s + x_est2 <- colWeightedVars(t(x), w = w, useNames = NA) 242s + stopifnot(all.equal(x_est1, x_est0)) 242s + stopifnot(all.equal(x_est2, x_est0)) 242s + } 242s > x_est1 <- rowWeightedVars(x, w = w, useNames = TRUE) 242s > x_est2 <- colWeightedVars(t(x), w = w, useNames = TRUE) 242s > stopifnot(all.equal(x_est1, x_est0)) 242s > stopifnot(all.equal(x_est2, x_est0)) 242s > dimnames(x) <- NULL 242s > 242s > # Weighted variances by rows and columns 242s > w <- 1:4 242s > # Test with and without dimnames on x 242s > for (setDimnames in c(TRUE, FALSE)) { 242s + if (setDimnames) dimnames(x) <- dimnames 242s + else dimnames(x) <- NULL 242s + # Check names attribute 242s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 242s + x_est1 <- rowWeightedVars(x, w = w, useNames = useNames) 242s + print(x_est1) 242s + x_est2 <- colWeightedVars(t(x), w = w, useNames = useNames) 242s + stopifnot(all.equal(x_est2, x_est1)) 242s + } 242s + } 242s a b c d e 242s 0.90747094 0.05040463 0.65089440 2.28697479 0.27902734 242s [1] 0.90747094 0.05040463 0.65089440 2.28697479 0.27902734 242s [1] 0.90747094 0.05040463 0.65089440 2.28697479 0.27902734 242s [1] 0.90747094 0.05040463 0.65089440 2.28697479 0.27902734 242s > 242s > 242s > x[sample(length(x), size = 0.3 * length(x))] <- NA 242s > print(x) 242s [,1] [,2] [,3] [,4] 242s [1,] -0.6264538 NA 1.5117812 -0.04493361 242s [2,] 0.1836433 NA NA -0.01619026 242s [3,] -0.8356286 0.7383247 -0.6212406 0.94383621 242s [4,] 1.5952808 NA -2.2146999 0.82122120 242s [5,] 0.3295078 NA NA 0.59390132 242s > 242s > # Non-weighted row variances with missing values 242s > x_est0 <- rowVars(x, na.rm = TRUE) 242s > x_est1 <- rowWeightedVars(x, w = rep(1, times = ncol(x)), na.rm = TRUE) 242s > print(x_est1) 242s [1] 1.22226258 0.01996673 0.83582537 4.05532299 0.03495197 242s > stopifnot(all.equal(x_est1, x_est0)) 242s > x_est2 <- colWeightedVars(t(x), w = rep(1, times = ncol(x)), na.rm = TRUE) 242s > stopifnot(all.equal(x_est2, x_est0)) 242s > # Check names attribute 242s > dimnames(x) <- dimnames 242s > x_est1 <- rowWeightedVars(x, w = rep(1, times = ncol(x)), na.rm = TRUE, useNames = FALSE) 242s > x_est2 <- colWeightedVars(t(x), w = rep(1, times = ncol(x)), na.rm = TRUE, useNames = FALSE) 242s > stopifnot(all.equal(x_est1, x_est0)) 242s > stopifnot(all.equal(x_est2, x_est0)) 242s > x_est0 <- rowVars(x, na.rm = TRUE, useNames = TRUE) 242s > x_est1 <- rowWeightedVars(x, w = rep(1, times = ncol(x)), na.rm = TRUE, useNames = TRUE) 242s > x_est2 <- colWeightedVars(t(x), w = rep(1, times = ncol(x)), na.rm = TRUE, useNames = TRUE) 242s > stopifnot(all.equal(x_est1, x_est0)) 242s > stopifnot(all.equal(x_est2, x_est0)) 242s > dimnames(x) <- NULL 242s > 242s > 242s > # Weighted row variances with missing values 242s > # Test with and without dimnames on x 242s > for (setDimnames in c(TRUE, FALSE)) { 242s + if (setDimnames) dimnames(x) <- dimnames 242s + else dimnames(x) <- NULL 242s + # Check names attribute 242s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 242s + x_est1 <- rowWeightedVars(x, w = w, na.rm = TRUE, useNames = useNames) 242s + print(x_est1) 242s + x_est2 <- colWeightedVars(t(x), w = w, na.rm = TRUE, useNames = useNames) 242s + stopifnot(all.equal(x_est2, x_est1)) 242s + } 242s + } 242s a b c d e 242s 0.788377504 0.007986693 0.650894398 2.795470241 0.013980790 242s [1] 0.788377504 0.007986693 0.650894398 2.795470241 0.013980790 242s [1] 0.788377504 0.007986693 0.650894398 2.795470241 0.013980790 242s [1] 0.788377504 0.007986693 0.650894398 2.795470241 0.013980790 242s > 242s > 242s > # Weighted variances by rows and columns 242s > w <- 1:4 242s > # Test with and without dimnames on x 242s > for (setDimnames in c(TRUE, FALSE)) { 242s + if (setDimnames) dimnames(x) <- dimnames 242s + else dimnames(x) <- NULL 242s + # Check names attribute 242s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 242s + x_est1 <- rowWeightedVars(x, w = w, na.rm = TRUE, useNames = useNames) 242s + print(x_est1) 242s + x_est2 <- colWeightedVars(t(x), w = w, na.rm = TRUE, useNames = useNames) 242s + stopifnot(all.equal(x_est2, x_est1)) 242s + } 242s + } 242s a b c d e 242s 0.788377504 0.007986693 0.650894398 2.795470241 0.013980790 242s [1] 0.788377504 0.007986693 0.650894398 2.795470241 0.013980790 242s [1] 0.788377504 0.007986693 0.650894398 2.795470241 0.013980790 242s [1] 0.788377504 0.007986693 0.650894398 2.795470241 0.013980790 242s > 242s > 242s > # Weighted row standard deviation (excluding some columns) 242s > w <- c(1, 1, 0, 1) 242s > ## FIXME: rowVars()/rowSds() needs na.rm = FALSE (wrong default) 242s > x_est0 <- rowSds(x[, (w == 1), drop = FALSE], na.rm = FALSE) 242s > x_est1 <- rowWeightedSds(x, w = w) 242s > print(x_est1) 242s [1] NA NA 0.9734868 NA NA 242s > stopifnot(all.equal(x_est1, x_est0)) 242s > x_est2 <- colWeightedSds(t(x), w = w, na.rm = FALSE) 242s > stopifnot(all.equal(x_est2, x_est0)) 242s > # Check names attribute 242s > dimnames(x) <- dimnames 242s > x_est1 <- rowWeightedSds(x, w = w, na.rm = FALSE, useNames = FALSE) 242s > x_est2 <- colWeightedSds(t(x), w = w, na.rm = FALSE, useNames = FALSE) 242s > stopifnot(all.equal(x_est1, x_est0)) 242s > stopifnot(all.equal(x_est2, x_est0)) 242s > x_est0 <- rowSds(x[, (w == 1), drop = FALSE], na.rm = FALSE, useNames = TRUE) 242s > if (!matrixStats:::isUseNamesNADefunct()) { 242s + x_est1 <- rowWeightedSds(x, w = w, na.rm = FALSE, useNames = NA) 242s + x_est2 <- colWeightedSds(t(x), w = w, na.rm = FALSE, useNames = NA) 242s + stopifnot(all.equal(x_est1, x_est0)) 242s + stopifnot(all.equal(x_est2, x_est0)) 242s + } 242s > x_est1 <- rowWeightedSds(x, w = w, na.rm = FALSE, useNames = TRUE) 242s > x_est2 <- colWeightedSds(t(x), w = w, na.rm = FALSE, useNames = TRUE) 242s > stopifnot(all.equal(x_est1, x_est0)) 242s > stopifnot(all.equal(x_est2, x_est0)) 242s > dimnames(x) <- NULL 242s > 242s > 242s > # Weighted row MADs (excluding some columns) 242s > w <- c(1, 1, 0, 1) 242s > x_est0 <- rowMads(x[, (w == 1), drop = FALSE]) 242s > x_est1 <- rowWeightedMads(x, w = w) 242s > print(x_est1) 242s [1] NA NA 0.3046914 NA NA 242s > stopifnot(all.equal(x_est1, x_est0)) 242s > x_est2 <- colWeightedMads(t(x), w = w) 242s > stopifnot(all.equal(x_est2, x_est0)) 242s > # Check names attribute 242s > dimnames(x) <- dimnames 242s > x_est1 <- rowWeightedMads(x, w = w, useNames = FALSE) 242s > x_est2 <- colWeightedMads(t(x), w = w, useNames = FALSE) 242s > stopifnot(all.equal(x_est1, x_est0)) 242s > stopifnot(all.equal(x_est2, x_est0)) 242s > x_est0 <- rowMads(x[, (w == 1), drop = FALSE], useNames = TRUE) 242s > if (!matrixStats:::isUseNamesNADefunct()) { 242s + x_est1 <- rowWeightedMads(x, w = w, useNames = NA) 242s + x_est2 <- colWeightedMads(t(x), w = w, useNames = NA) 242s + stopifnot(all.equal(x_est1, x_est0)) 242s + stopifnot(all.equal(x_est2, x_est0)) 242s + } 242s > x_est1 <- rowWeightedMads(x, w = w, useNames = TRUE) 242s > x_est2 <- colWeightedMads(t(x), w = w, useNames = TRUE) 242s > stopifnot(all.equal(x_est1, x_est0)) 242s > stopifnot(all.equal(x_est2, x_est0)) 242s > dimnames(x) <- NULL 242s > 242s 242s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 242s Copyright (C) 2024 The R Foundation for Statistical Computing 242s Platform: x86_64-pc-linux-gnu 242s 242s R is free software and comes with ABSOLUTELY NO WARRANTY. 242s You are welcome to redistribute it under certain conditions. 242s Type 'license()' or 'licence()' for distribution details. 242s 242s R is a collaborative project with many contributors. 242s Type 'contributors()' for more information and 242s 'citation()' on how to cite R or R packages in publications. 242s 242s Type 'demo()' for some demos, 'help()' for on-line help, or 242s 'help.start()' for an HTML browser interface to help. 242s Type 'q()' to quit R. 242s 242s > library("matrixStats") 242s > 242s > fcns <- list( 242s + weightedVar = c(rowWeightedVars, colWeightedVars), 242s + weightedSd = c(rowWeightedSds, colWeightedSds), 242s + weightedMad = c(rowWeightedMads, colWeightedMads) 242s + ) 242s > 242s > 242s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 242s > # Subsetted tests 242s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 242s > source("utils/validateIndicesFramework.R") 242s > # To check names attribute 242s > dimnames <- list(letters[1:6], LETTERS[1:6]) 242s > for (fcn in names(fcns)) { 242s + cat(sprintf("subsetted tests on matrix %s()...\n", fcn)) 242s + row_fcn <- fcns[[fcn]][[1]] 242s + col_fcn <- fcns[[fcn]][[2]] 242s + 242s + for (mode in c("numeric", "integer")) { 242s + x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 242s + w <- runif(6, min = 0, max = 6) 242s + storage.mode(x) <- mode 242s + storage.mode(w) <- mode 242s + if (mode == "numeric") w[1] <- Inf 242s + 242s + # Test with and without dimnames on x 242s + for (setDimnames in c(TRUE, FALSE)) { 242s + if (setDimnames) dimnames(x) <- dimnames 242s + else dimnames(x) <- NULL 242s + 242s + count <- 0L 242s + for (rows in index_cases) { 242s + for (cols in index_cases) { 242s + count <- count + 1L 242s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 242s + useNames <- c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE) 242s + useNames <- useNames[count %% length(useNames) + 1] 242s + 242s + validateIndicesTestMatrix_w(x, w, rows, cols, 242s + ftest = row_fcn, fsure = row_fcn, 242s + na.rm = na.rm, useNames = useNames) 242s + validateIndicesTestMatrix_w(x, w, rows, cols, 242s + fcoltest = col_fcn, fsure = row_fcn, 242s + na.rm = na.rm, useNames = useNames) 242s + } 242s + } 242s + } 242s + } 242s + cat(sprintf("%s()...DONE\n", fcn)) 242s + } 242s subsetted tests on matrix weightedVar()... 243s weightedVar()...DONE 243s subsetted tests on matrix weightedSd()... 244s weightedSd()...DONE 244s subsetted tests on matrix weightedMad()... 244s weightedMad()...DONE 244s > 244s 244s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 244s Copyright (C) 2024 The R Foundation for Statistical Computing 244s Platform: x86_64-pc-linux-gnu 244s 244s R is free software and comes with ABSOLUTELY NO WARRANTY. 244s You are welcome to redistribute it under certain conditions. 244s Type 'license()' or 'licence()' for distribution details. 244s 244s R is a collaborative project with many contributors. 244s Type 'contributors()' for more information and 244s 'citation()' on how to cite R or R packages in publications. 244s 244s Type 'demo()' for some demos, 'help()' for on-line help, or 244s 'help.start()' for an HTML browser interface to help. 244s Type 'q()' to quit R. 244s 244s > library("matrixStats") 244s > 244s > signTabulate0 <- function(x, ...) { 244s + nneg <- sum(x < 0, na.rm = TRUE) 244s + nzero <- sum(x == 0, na.rm = TRUE) 244s + npos <- sum(x > 0, na.rm = TRUE) 244s + nna <- sum(is.na(x)) 244s + nneginf <- sum(is.infinite(x) & x < 0, na.rm = TRUE) 244s + nposinf <- sum(is.infinite(x) & x > 0, na.rm = TRUE) 244s + res <- c(nneg, nzero, npos, nna, nneginf, nposinf) 244s + res <- as.double(res) 244s + names(res) <- c("-1", "0", "+1", "NA", "-Inf", "+Inf") 244s + if (is.integer(x)) res <- res[1:4] 244s + res 244s + } # signTabulate0() 244s > 244s > 244s > # Simulate data 244s > set.seed(0xBEEF) 244s > n <- 100L 244s > x <- runif(n) 244s > x[sample(n, size = 0.1 * n)] <- 0 244s > x[sample(n, size = 0.1 * n)] <- NA_real_ 244s > x[sample(n, size = 0.1 * n)] <- -Inf 244s > x[sample(n, size = 0.1 * n)] <- +Inf 244s > 244s > # Doubles 244s > message("Doubles:") 244s > counts0 <- signTabulate0(x) 244s Doubles: 244s Integers: 244s > print(counts0) 244s -1 0 +1 NA -Inf +Inf 244s 9 7 77 7 9 10 244s > counts1 <- signTabulate(x) 244s > print(counts1) 244s -1 0 +1 NA -Inf +Inf 244s 9 7 77 7 9 10 244s > stopifnot(identical(counts1, counts0)) 244s > 244s > # Integers 244s > message("Integers:") 244s > x <- suppressWarnings(as.integer(x)) 244s > counts0 <- signTabulate0(x) 244s > print(counts0) 244s -1 0 +1 NA 244s 0 74 0 26 244s > counts1 <- signTabulate(x) 244s > print(counts1) 244s -1 0 +1 NA 244s 0 74 0 26 244s > stopifnot(identical(counts1, counts0)) 244s > 244s 244s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 244s Copyright (C) 2024 The R Foundation for Statistical Computing 244s Platform: x86_64-pc-linux-gnu 244s 244s R is free software and comes with ABSOLUTELY NO WARRANTY. 244s You are welcome to redistribute it under certain conditions. 244s Type 'license()' or 'licence()' for distribution details. 244s 244s R is a collaborative project with many contributors. 244s Type 'contributors()' for more information and 244s 'citation()' on how to cite R or R packages in publications. 244s 244s Type 'demo()' for some demos, 'help()' for on-line help, or 244s 'help.start()' for an HTML browser interface to help. 244s Type 'q()' to quit R. 244s 244s > library("matrixStats") 244s > 244s > signTabulate0 <- function(x, ...) { 244s + nneg <- sum(x < 0, na.rm = TRUE) 244s + nzero <- sum(x == 0, na.rm = TRUE) 244s + npos <- sum(x > 0, na.rm = TRUE) 244s + nna <- sum(is.na(x)) 244s + nneginf <- sum(is.infinite(x) & x < 0, na.rm = TRUE) 244s + nposinf <- sum(is.infinite(x) & x > 0, na.rm = TRUE) 244s + res <- c(nneg, nzero, npos, nna, nneginf, nposinf) 244s + res <- as.double(res) 244s + names(res) <- c("-1", "0", "+1", "NA", "-Inf", "+Inf") 244s + if (is.integer(x)) res <- res[1:4] 244s + res 244s + } # signTabulate0() 244s > 244s > 244s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 244s > # Subsetted tests 244s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 244s > source("utils/validateIndicesFramework.R") 244s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 244s > x[2:3, 4:5] <- +Inf 244s > x[4:5, 1:2] <- -Inf 244s > for (idxs in index_cases) { 244s + validateIndicesTestVector(x, idxs, 244s + ftest = signTabulate, fsure = signTabulate0) 244s + } 245s > 245s 245s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 245s Copyright (C) 2024 The R Foundation for Statistical Computing 245s Platform: x86_64-pc-linux-gnu 245s 245s R is free software and comes with ABSOLUTELY NO WARRANTY. 245s You are welcome to redistribute it under certain conditions. 245s Type 'license()' or 'licence()' for distribution details. 245s 245s R is a collaborative project with many contributors. 245s Type 'contributors()' for more information and 245s 'citation()' on how to cite R or R packages in publications. 245s 245s Type 'demo()' for some demos, 'help()' for on-line help, or 245s 'help.start()' for an HTML browser interface to help. 245s Type 'q()' to quit R. 245s 245s > library("matrixStats") 245s > options(warn = 1) 245s > 245s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 245s > # Consistency checks 245s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 245s > set.seed(1) 245s > 245s > sum2_R <- function(x, na.rm = FALSE, idxs = NULL) { 245s + if (is.null(idxs)) { 245s + sum(x, na.rm = na.rm) 245s + } else { 245s + sum(x[idxs], na.rm = na.rm) 245s + } 245s + } # sum2_R() 245s > 245s > 245s > cat("Consistency checks:\n") 245s Consistency checks: 245s > for (kk in 1:20) { 245s + cat("Random test #", kk, "\n", sep = "") 245s + 245s + # Simulate data in a matrix of any shape 245s + n <- sample(1e3, size = 1L) 245s + x <- rnorm(n, sd = 100) 245s + 245s + # Add NAs? 245s + if ((kk %% 4) %in% c(3, 0)) { 245s + cat("Adding NAs\n") 245s + nna <- sample(n, size = 1L) 245s + na_values <- c(NA_real_, NaN) 245s + t <- sample(na_values, size = nna, replace = TRUE) 245s + x[sample(length(x), size = nna)] <- t 245s + } 245s + 245s + # Integer or double? 245s + if ((kk %% 4) %in% c(2, 0)) { 245s + cat("Coercing to integers\n") 245s + storage.mode(x) <- "integer" 245s + } 245s + 245s + na.rm <- sample(c(TRUE, FALSE), size = 1L) 245s + 245s + # Sum over all 245s + y0 <- sum2_R(x, na.rm = na.rm) 245s + y1 <- sum2(x, na.rm = na.rm) 245s + stopifnot(all.equal(y1, y0)) 245s + 245s + # Sum over subset 245s + nidxs <- sample(n, size = 1L) 245s + idxs <- sample(n, size = nidxs) 245s + y0 <- sum2_R(x, na.rm = na.rm, idxs = idxs) 245s + y1 <- sum2(x, na.rm = na.rm, idxs = idxs) 245s + stopifnot(all.equal(y1, y0)) 245s + 245s + if (storage.mode(x) == "integer") { 245s + storage.mode(x) <- "logical" 245s + 245s + y0 <- sum2_R(x, na.rm = na.rm) 245s + y1 <- sum2(x, na.rm = na.rm) 245s + stopifnot(all.equal(y1, y0)) 245s + 245s + y0 <- sum2_R(x, na.rm = na.rm, idxs = idxs) 245s + y1 <- sum2(x, na.rm = na.rm, idxs = idxs) 245s + stopifnot(all.equal(y1, y0)) 245s + } 245s + } # for (kk ...) 245s Random test #1 245s Random test #2 245s Coercing to integers 245s Random test #3 245s Adding NAs 245s Random test #4 245s Adding NAs 245s Coercing to integers 245s Random test #5 245s Random test #6 245s Coercing to integers 245s Random test #7 245s Adding NAs 245s Random test #8 245s Adding NAs 245s Coercing to integers 245s Random test #9 245s Random test #10 245s Coercing to integers 245s Random test #11 245s Adding NAs 245s Random test #12 245s Adding NAs 245s Coercing to integers 245s Random test #13 245s Random test #14 245s Coercing to integers 245s Random test #15 245s Adding NAs 245s Random test #16 245s Adding NAs 245s Coercing to integers 245s Random test #17 245s Random test #18 245s Coercing to integers 245s Random test #19 245s Adding NAs 245s Random test #20 245s Adding NAs 245s Coercing to integers 245s > 245s > 245s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 245s > # All missing values 245s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 245s > for (n in 0:2) { 245s + for (na.rm in c(FALSE, TRUE)) { 245s + x <- rep(NA_real_, times = n) 245s + y0 <- sum(x, na.rm = na.rm) 245s + y <- sum2(x, na.rm = na.rm) 245s + stopifnot(all.equal(y, y0)) 245s + 245s + x <- rep(NA_integer_, times = n) 245s + y0 <- sum(x, na.rm = na.rm) 245s + y <- sum2(x, na.rm = na.rm) 245s + stopifnot(all.equal(y, y0)) 245s + 245s + x <- rep(NA, times = n) 245s + y0 <- sum(x, na.rm = na.rm) 245s + y <- sum2(x, na.rm = na.rm) 245s + stopifnot(all.equal(y, y0)) 245s + } 245s + } 245s > 245s > 245s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 245s > # Special cases 245s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 245s > for (na.rm in c(FALSE, TRUE)) { 245s + # Summing over zero elements (integers) 245s + x <- integer(0) 245s + s1 <- sum(x, na.rm = na.rm) 245s + s2 <- sum2(x, na.rm = na.rm) 245s + stopifnot(identical(s1, s2)) 245s + 245s + x <- 1:10 245s + idxs <- integer(0) 245s + s1 <- sum(x[idxs], na.rm = na.rm) 245s + s2 <- sum2(x, idxs = idxs, na.rm = na.rm) 245s + stopifnot(identical(s1, s2)) 245s + 245s + # Summing over NA_integer_:s 245s + x <- rep(NA_integer_, times = 10L) 245s + s1 <- sum(x, na.rm = na.rm) 245s + s2 <- sum2(x, na.rm = na.rm) 245s + stopifnot(identical(s1, s2)) 245s + 245s + x <- rep(NA_integer_, times = 10L) 245s + idxs <- 1:5 245s + s1 <- sum(x[idxs], na.rm = na.rm) 245s + s2 <- sum2(x, idxs = idxs, na.rm = na.rm) 245s + stopifnot(identical(s1, s2)) 245s + 245s + 245s + # Summing over zero elements (doubles) 245s + x <- double(0) 245s + s1 <- sum(x) 245s + s2 <- sum2(x) 245s + stopifnot( 245s + identical(s1, 0), 245s + identical(s1, s2) 245s + ) 245s + 245s + x <- as.double(1:10) 245s + idxs <- integer(0) 245s + s1 <- sum(x[idxs]) 245s + s2 <- sum2(x, idxs = idxs) 245s + stopifnot( 245s + identical(s1, 0), 245s + identical(s1, s2) 245s + ) 245s + 245s + # Summing over NA_real_:s 245s + x <- rep(NA_real_, times = 10L) 245s + s1 <- sum(x, na.rm = na.rm) 245s + s2 <- sum2(x, na.rm = na.rm) 245s + stopifnot( 245s + !na.rm || s1 == 0, 245s + identical(s1, s2) 245s + ) 245s + 245s + x <- rep(NA_real_, times = 10L) 245s + idxs <- 1:5 245s + s1 <- sum(x[idxs], na.rm = na.rm) 245s + s2 <- sum2(x, idxs = idxs, na.rm = na.rm) 245s + stopifnot( 245s + !na.rm || s1 == 0, 245s + identical(s1, s2) 245s + ) 245s + 245s + # Summing over -Inf:s 245s + x <- rep(-Inf, times = 3L) 245s + s1 <- sum(x, na.rm = na.rm) 245s + s2 <- sum2(x, na.rm = na.rm) 245s + stopifnot( 245s + is.infinite(s1) && s1 < 0, 245s + identical(s1, s2) 245s + ) 245s + 245s + # Summing over +Inf:s 245s + x <- rep(+Inf, times = 3L) 245s + s1 <- sum(x, na.rm = na.rm) 245s + s2 <- sum2(x, na.rm = na.rm) 245s + stopifnot(identical(s1, s2)) 245s + stopifnot( 245s + is.infinite(s1) && s1 > 0, 245s + identical(s1, s2) 245s + ) 245s + 245s + # Summing over mix of -Inf:s and +Inf:s 245s + x <- rep(c(-Inf, +Inf), times = 3L) 245s + s1 <- sum(x, na.rm = na.rm) 245s + s2 <- sum2(x, na.rm = na.rm) 245s + stopifnot( 245s + is.nan(s1), 245s + identical(s1, s2) 245s + ) 245s + 245s + # Summing over mix of -Inf:s and +Inf:s and numerics 245s + x <- rep(c(-Inf, +Inf, 3.14), times = 2L) 245s + s1 <- sum(x, na.rm = na.rm) 245s + s2 <- sum2(x, na.rm = na.rm) 245s + stopifnot( 245s + is.nan(s1), 245s + identical(s1, s2) 245s + ) 245s + 245s + # Summing over mix of NaN, NA, +Inf, and numerics 245s + x <- c(NaN, NA, +Inf, 3.14) 245s + s1 <- sum(x, na.rm = na.rm) 245s + s2 <- sum2(x, na.rm = na.rm) 245s + if (na.rm) { 245s + stopifnot( 245s + is.infinite(s1) && s1 > 0, 245s + identical(s2, s1) 245s + ) 245s + } else { 245s + stopifnot(is.na(s1), is.na(s2)) 245s + ## NOTE, due to compiler optimization, it is not guaranteed that NA is 245s + ## returned here (as one would expect). NaN might very well be returned, 245s + ## when both NA and NaN are involved. This is an accepted feature in R, 245s + ## which is documented in help("is.nan"). See also 245s + ## https://stat.ethz.ch/pipermail/r-devel/2017-April/074009.html. 245s + ## Thus, we cannot guarantee that s1 is identical to s0. 245s + } 245s + 245s + # Summing over mix of NaN, NA, +Inf, and numerics 245s + x <- c(NA, NaN, +Inf, 3.14) 245s + s1 <- sum(x, na.rm = na.rm) 245s + s2 <- sum2(x, na.rm = na.rm) 245s + if (na.rm) { 245s + stopifnot( 245s + is.infinite(s1) && s1 > 0, 245s + identical(s2, s1) 245s + ) 245s + } else { 245s + stopifnot(is.na(s1), is.na(s2)) 245s + ## NOTE, due to compiler optimization, it is not guaranteed that NA is 245s + ## returned here (as one would expect). NaN might very well be returned, 245s + ## when both NA and NaN are involved. This is an accepted feature in R, 245s + ## which is documented in help("is.nan"). See also 245s + ## https://stat.ethz.ch/pipermail/r-devel/2017-April/074009.html. 245s + ## Thus, we cannot guarantee that s1 is identical to s0. 245s + } 245s + } 245s > 245s > 245s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 245s > # Summing of large integers 245s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 245s > x <- c(.Machine$integer.max, 1L, -.Machine$integer.max) 245s > 245s > # Total gives integer overflow 245s > s1 <- sum(x[1:2]) # NA_integer_ w/ warning 245s > s2 <- sum2(x[1:2]) # NA_integer_ w/ warning 245s Warning in sum2(x[1:2]) : 245s Integer overflow. Use sum2(..., mode = "double") to avoid this. 245s > stopifnot( 245s + getRversion() >= "3.5.0" || identical(s1, NA_integer_), 245s + identical(s2, NA_integer_) 245s + ) 245s > 245s > ## Assert above warning 245s > res <- tryCatch({ 245s + s2 <- sum2(x[1:2]) 245s + }, warning = identity) 245s > stopifnot(inherits(res, "warning")) 245s > 245s > 245s > # Total gives integer overflow (coerce to numeric) 245s > s1 <- sum(as.numeric(x[1:2])) # 2147483648 245s > s2 <- sum2(as.numeric(x[1:2])) # 2147483648 245s > s3 <- sum2(x[1:2], mode = "double") # 2147483648 245s > stopifnot( 245s + identical(s1, 2147483648), 245s + identical(s1, s2), 245s + identical(s1, s3) 245s + ) 245s > 245s > # Cumulative sum would give integer overflow but not the total 245s > s1 <- sum(x) # 1L 245s > s2 <- sum2(x) # 1L 245s > stopifnot( 245s + identical(s1, 1L), 245s + identical(s1, s2) 245s + ) 245s > 245s > # Input is double but coersing result to integer 245s > x <- c(1, 2, 3.1) 245s > s1 <- sum2(x) 245s > s2 <- sum2(x, mode = "integer") 245s Warning in sum2(x, mode = "integer") : 245s sum2(x, mode = "integer") called with typeof(x) == "double"; did you mean to use as.integer(sum2(x))? 245s > stopifnot( 245s + identical(as.integer(s1), s2) 245s + ) 245s > 245s > ## Assert above warning 245s > res <- tryCatch({ 245s + s2 <- sum2(x, mode = "integer") 245s + }, warning = identity) 245s > stopifnot(inherits(res, "warning")) 245s > 245s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 245s > # Summing of large doubles 245s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 245s > ## Double overflow 245s > x <- rep(.Machine$double.xmax, times = 2L) 245s > y0 <- sum(x) 245s > print(y0) 245s [1] Inf 245s > y <- sum2(x) 245s > print(y) 245s [1] Inf 245s > stopifnot( 245s + is.infinite(y) && y > 0, 245s + identical(y, y0) 245s + ) 245s > 245s > x <- rep(-.Machine$double.xmax, times = 2L) 245s > y0 <- sum(x) 245s > print(y0) 245s [1] -Inf 245s > y <- sum2(x) 245s > print(y) 245s [1] -Inf 245s > stopifnot( 245s + is.infinite(y) && y < 0, 245s + identical(y, y0) 245s + ) 245s > 245s > 245s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 245s > # Argument 'idxs' 245s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 245s > x <- 1:10 245s > idxs_list <- list( 245s + integer = 1:5, 245s + double = as.double(1:5), 245s + logical = (x <= 5) 245s + ) 245s > 245s > for (idxs in idxs_list) { 245s + cat("idxs:\n") 245s + str(idxs) 245s + s1 <- sum(x[idxs], na.rm = TRUE) 245s + s2 <- sum2(x, idxs = idxs, na.rm = TRUE) 245s + stopifnot(identical(s1, s2)) 245s + } 245s idxs: 245s int [1:5] 1 2 3 4 5 245s idxs: 245s num [1:5] 1 2 3 4 5 245s idxs: 245s logi [1:10] TRUE TRUE TRUE TRUE TRUE FALSE ... 245s > 245s 245s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 245s Copyright (C) 2024 The R Foundation for Statistical Computing 245s Platform: x86_64-pc-linux-gnu 245s 245s R is free software and comes with ABSOLUTELY NO WARRANTY. 245s You are welcome to redistribute it under certain conditions. 245s Type 'license()' or 'licence()' for distribution details. 245s 245s R is a collaborative project with many contributors. 245s Type 'contributors()' for more information and 245s 'citation()' on how to cite R or R packages in publications. 245s 245s Type 'demo()' for some demos, 'help()' for on-line help, or 245s 'help.start()' for an HTML browser interface to help. 245s Type 'q()' to quit R. 245s 245s > library("matrixStats") 245s > 245s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 245s > # Subsetted tests 245s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 245s > source("utils/validateIndicesFramework.R") 245s > x <- runif(6, min = -6, max = 6) 245s > storage.mode(x) <- "integer" 245s > for (idxs in index_cases) { 245s + validateIndicesTestVector(x, idxs, 245s + ftest = sum2, fsure = sum, 245s + na.rm = FALSE) 245s + validateIndicesTestVector(x, idxs, 245s + ftest = sum2, fsure = sum, 245s + na.rm = TRUE) 245s + } 245s > 245s 245s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 245s Copyright (C) 2024 The R Foundation for Statistical Computing 245s Platform: x86_64-pc-linux-gnu 245s 245s R is free software and comes with ABSOLUTELY NO WARRANTY. 245s You are welcome to redistribute it under certain conditions. 245s Type 'license()' or 'licence()' for distribution details. 245s 245s R is a collaborative project with many contributors. 245s Type 'contributors()' for more information and 245s 'citation()' on how to cite R or R packages in publications. 245s 245s Type 'demo()' for some demos, 'help()' for on-line help, or 245s 'help.start()' for an HTML browser interface to help. 245s Type 'q()' to quit R. 245s 245s > library(matrixStats) 245s > source("utils/validateIndicesFramework.R") 245s > 245s > oopts <- options(matrixStats.validateIndices = "ignore") 245s > 245s > ftest <- function(x, idxs) validateIndices(idxs, length(x)) 245s > 245s > x <- 1:6 245s > for (idxs in index_cases) { 245s + for (mode in c("integer", "numeric", "logical")) { 245s + if (!is.null(idxs)) { 245s + suppressWarnings({storage.mode(idxs) <- mode}) 245s + } 245s + validateIndicesTestVector(x, idxs, ftest = ftest, fsure = identity) 245s + } 245s + } 245s > 245s > ftest <- function(x, idxs) validateIndices(idxs, length(x)) 245s > 245s > for (idxs in index_error_cases) { 245s + validateIndicesTestVector(x, idxs, ftest = ftest, fsure = identity) 245s + } 245s > 245s > 245s > ftest <- function(x, rows, cols) { 245s + vr <- validateIndices(rows, dim(x)[1], FALSE) 245s + vc <- validateIndices(cols, dim(x)[2], FALSE) 245s + 245s + stopifnot(all((vr > 0 & vr <= dim(x)[1]) | is.na(vr))) 245s + stopifnot(all((vc > 0 & vc <= dim(x)[2]) | is.na(vc))) 245s + suppressWarnings(x <- x[vr, vc, drop = FALSE]) 245s + x 245s + } 245s > 245s > x <- matrix(1:36, nrow = 6, ncol = 6) 245s > for (rows in index_cases) { 245s + for (cols in index_cases) { 245s + validateIndicesTestMatrix(x, rows, cols, ftest = ftest, fsure = identity) 245s + } 245s + } 245s > 245s > # Testing for 64-bit builds (64 bits = 8 bytes) 245s > if (.Machine$sizeof.pointer == 8L) { 245s + validateIndices(c(1.25*2^40, 3, 1*2^38, 1, 1.4*2^39), maxIdx = 1*2^41) 245s + } 245s [1] 1.374390e+12 3.000000e+00 2.748779e+11 1.000000e+00 7.696581e+11 245s > 245s > options(oopts) 245s > 245s 245s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 245s Copyright (C) 2024 The R Foundation for Statistical Computing 245s Platform: x86_64-pc-linux-gnu 245s 245s R is free software and comes with ABSOLUTELY NO WARRANTY. 245s You are welcome to redistribute it under certain conditions. 245s Type 'license()' or 'licence()' for distribution details. 245s 245s R is a collaborative project with many contributors. 245s Type 'contributors()' for more information and 245s 'citation()' on how to cite R or R packages in publications. 245s 245s Type 'demo()' for some demos, 'help()' for on-line help, or 245s 'help.start()' for an HTML browser interface to help. 245s Type 'q()' to quit R. 245s 246s > library("matrixStats") 246s > 246s > set.seed(1) 246s > x <- rnorm(1e4) 246s > 246s > 246s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 246s > # Variance estimators 246s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 246s > sigma2_a <- var(x) 246s > cat(sprintf("var(x) = %g\n", sigma2_a)) 246s var(x) = 1.02487 246s > 246s > sigma2_b <- varDiff(x) 246s > cat(sprintf("varDiff(x) = %g\n", sigma2_b)) 246s varDiff(x) = 1.01224 246s > 246s > d <- abs(sigma2_b - sigma2_a) 246s > cat(sprintf("Absolute difference = %g\n", d)) 246s Absolute difference = 0.0126268 246s > stopifnot(d < 0.02) 246s > 246s > 246s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 246s > # Standard deviation estimators 246s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 246s > sigma_a <- sd(x) 246s > cat(sprintf("sd(x) = %g\n", sigma_a)) 246s sd(x) = 1.01236 246s > 246s > sigma_b <- sdDiff(x) 246s > cat(sprintf("sdDiff(x) = %g\n", sigma_b)) 246s sdDiff(x) = 1.0061 246s > 246s > d <- abs(sigma_b - sigma_a) 246s > cat(sprintf("Absolute difference = %g\n", d)) 246s Absolute difference = 0.00625567 246s > stopifnot(d < 0.01) 246s > 246s > # Sanity checks 246s > stopifnot(abs(sigma2_a - sigma_a ^ 2) < 1e-9) 246s > stopifnot(abs(sigma2_b - sigma_b ^ 2) < 1e-9) 246s > 246s > 246s > sigma_a2 <- mad(x) 246s > cat(sprintf("mad(x) = %g\n", sigma_a2)) 246s mad(x) = 0.998376 246s > 246s > sigma_b2 <- madDiff(x) 246s > cat(sprintf("madDiff(x) = %g\n", sigma_b2)) 246s madDiff(x) = 1.02513 246s > 246s > d <- abs(sigma_b2 - sigma_a2) 246s > cat(sprintf("Absolute difference = %g\n", d)) 246s Absolute difference = 0.0267497 246s > stopifnot(d < 0.05) 246s > 246s > 246s > sigma_a3 <- IQR(x) 246s > cat(sprintf("IQR(x) = %g\n", sigma_a3)) 246s IQR(x) = 1.35105 246s > 246s > sigma_b3 <- iqrDiff(x) 246s > cat(sprintf("iqrDiff(x) = %g\n", sigma_b3)) 246s iqrDiff(x) = 1.37797 246s > 246s > d <- abs(sigma_b3 - sigma_a3) 246s > cat(sprintf("Absolute difference = %g\n", d)) 246s Absolute difference = 0.0269152 246s > stopifnot(d < 0.05) 246s > 246s > 246s > 246s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 246s > # Trimmed estimators 246s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 246s > y <- x 246s > outliers <- sample(length(x), size = 0.1 * length(x)) 246s > y[outliers] <- 100 * y[outliers] 246s > 246s > sigma_ao <- sd(y[-outliers]) 246s > cat(sprintf("sd(y) = %g\n", sigma_ao)) 246s sd(y) = 1.01166 246s > 246s > sigma_bo <- sdDiff(y[-outliers]) 246s > cat(sprintf("sdDiff(y) = %g\n", sigma_bo)) 246s sdDiff(y) = 1.00743 246s > 246s > d <- abs(sigma_b - sigma_a) 246s > cat(sprintf("Absolute difference = %g\n", d)) 246s Absolute difference = 0.00625567 246s > stopifnot(d < 0.01) 246s > 246s > sigma_bot <- sdDiff(y, trim = 0.05) 246s > cat(sprintf("sdDiff(y, trim = 0.05) = %g\n", sigma_bot)) 246s sdDiff(y, trim = 0.05) = 7.74327 246s > 246s > d <- abs(sigma_bot - sigma_a) 246s > cat(sprintf("Absolute difference = %g\n", d)) 246s Absolute difference = 6.73091 246s > #stopifnot(d < 1e-3) 246s > 246s > sigma_cot <- madDiff(y, trim = 0.05) 246s > cat(sprintf("madDiff(y, trim = 0.05) = %g\n", sigma_cot)) 246s madDiff(y, trim = 0.05) = 1.15278 246s > 246s > sigma_dot <- iqrDiff(y, trim = 0.05) 246s > cat(sprintf("iqrDiff(y, trim = 0.05) = %g\n", sigma_dot)) 246s iqrDiff(y, trim = 0.05) = 1.55762 246s > 246s > 246s > fcns <- list( 246s + varDiff = varDiff, 246s + sdDiff = sdDiff, 246s + madDiff = madDiff, 246s + iqrDiff = iqrDiff 246s + ) 246s > 246s > for (name in names(fcns)) { 246s + cat(sprintf("%s()...\n", name)) 246s + fcn <- fcns[[name]] 246s + 246s + for (mode in c("integer", "double")) { 246s + cat("mode: ", mode, "", sep = "") 246s + for (n in 0:3) { 246s + x <- runif(n, min = -5, max = 5) 246s + storage.mode(x) <- mode 246s + str(x) 246s + 246s + y <- fcn(x) 246s + yt <- fcn(x, trim = 0.1) 246s + str(list("non-trimmed" = y, trimmed = yt)) 246s + } # for (mode ...) 246s + } 246s + 246s + cat(sprintf("%s()...DONE\n", name)) 246s + } # for (name ...) 246s varDiff()... 246s mode: integer int(0) 246s List of 2 246s $ non-trimmed: num NA 246s $ trimmed : num NA 246s int -4 246s List of 2 246s $ non-trimmed: num NA 246s $ trimmed : num NA 246s int [1:2] 3 2 246s List of 2 246s $ non-trimmed: num NA 246s $ trimmed : num NA 246s int [1:3] 1 4 -1 246s List of 2 246s $ non-trimmed: num 16 246s $ trimmed : num 16 246s mode: double num(0) 246s List of 2 246s $ non-trimmed: num NA 246s $ trimmed : num NA 246s num -0.794 246s List of 2 246s $ non-trimmed: num NA 246s $ trimmed : num NA 246s num [1:2] 0.897 -3.728 246s List of 2 246s $ non-trimmed: num NA 246s $ trimmed : num NA 246s num [1:3] 2.07 -1.13 1.94 246s List of 2 246s $ non-trimmed: num 9.83 246s $ trimmed : num 9.83 246s varDiff()...DONE 246s sdDiff()... 246s mode: integer int(0) 246s List of 2 246s $ non-trimmed: num NA 246s $ trimmed : num NA 246s int 2 246s List of 2 246s $ non-trimmed: num NA 246s $ trimmed : num NA 246s int [1:2] -4 1 246s List of 2 246s $ non-trimmed: num NA 246s $ trimmed : num NA 246s int [1:3] -2 1 -1 246s List of 2 246s $ non-trimmed: num 2.5 246s $ trimmed : num 2.5 246s mode: double num(0) 246s List of 2 246s $ non-trimmed: num NA 246s $ trimmed : num NA 246s num -3.78 246s List of 2 246s $ non-trimmed: num NA 246s $ trimmed : num NA 246s num [1:2] -2.04 2.38 246s List of 2 246s $ non-trimmed: num NA 246s $ trimmed : num NA 246s num [1:3] 1.42 -2.14 1.14 246s List of 2 246s $ non-trimmed: num 3.42 246s $ trimmed : num 3.42 246s sdDiff()...DONE 246s madDiff()... 246s mode: integer int(0) 246s List of 2 246s $ non-trimmed: num NA 246s $ trimmed : num NA 246s int -1 246s List of 2 246s $ non-trimmed: num NA 246s $ trimmed : num NA 246s int [1:2] -1 4 246s List of 2 246s $ non-trimmed: num NA 246s $ trimmed : num NA 246s int [1:3] -1 0 -3 246s List of 2 246s $ non-trimmed: num 2.1 246s $ trimmed : num 2.1 246s mode: double num(0) 246s List of 2 246s $ non-trimmed: num NA 246s $ trimmed : num NA 246s num -1.13 246s List of 2 246s $ non-trimmed: num NA 246s $ trimmed : num NA 246s num [1:2] -1.7 -1.21 246s List of 2 246s $ non-trimmed: num NA 246s $ trimmed : num NA 246s num [1:3] -2.39 -0.464 3.086 246s List of 2 246s $ non-trimmed: num 0.851 246s $ trimmed : num 0.851 246s madDiff()...DONE 246s iqrDiff()... 246s mode: integer int(0) 246s List of 2 246s $ non-trimmed: num NA 246s $ trimmed : num NA 246s int 3 246s List of 2 246s $ non-trimmed: num 0 246s $ trimmed : num 0 246s int [1:2] -3 4 246s List of 2 246s $ non-trimmed: num 0 246s $ trimmed : num 0 246s int [1:3] 0 -2 -2 246s List of 2 246s $ non-trimmed: num 0.707 246s $ trimmed : num 0.707 246s mode: double num(0) 246s List of 2 246s $ non-trimmed: num NA 246s $ trimmed : num NA 246s num -4.46 246s List of 2 246s $ non-trimmed: num 0 246s $ trimmed : num 0 246s num [1:2] 3.67 1.02 246s List of 2 246s $ non-trimmed: num 0 246s $ trimmed : num 0 246s num [1:3] -0.537 -2.733 2.857 246s List of 2 246s $ non-trimmed: num 2.75 246s $ trimmed : num 2.75 246s iqrDiff()...DONE 246s > 246s 246s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 246s Copyright (C) 2024 The R Foundation for Statistical Computing 246s Platform: x86_64-pc-linux-gnu 246s 246s R is free software and comes with ABSOLUTELY NO WARRANTY. 246s You are welcome to redistribute it under certain conditions. 246s Type 'license()' or 'licence()' for distribution details. 246s 246s R is a collaborative project with many contributors. 246s Type 'contributors()' for more information and 246s 'citation()' on how to cite R or R packages in publications. 246s 246s Type 'demo()' for some demos, 'help()' for on-line help, or 246s 'help.start()' for an HTML browser interface to help. 246s Type 'q()' to quit R. 246s 246s > library("matrixStats") 246s > 246s > fcns <- list( 246s + varDiff = varDiff, 246s + sdDiff = sdDiff, 246s + madDiff = madDiff, 246s + iqrDiff = iqrDiff 246s + ) 246s > 246s > 246s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 246s > # Subsetted tests 246s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 246s > source("utils/validateIndicesFramework.R") 246s > for (name in names(fcns)) { 246s + cat(sprintf("subsetted tests on %s()...\n", name)) 246s + fcn <- fcns[[name]] 246s + 246s + for (mode in c("numeric", "integer")) { 246s + x <- runif(6, min = -6, max = 6) 246s + storage.mode(x) <- mode 246s + trim <- runif(1, min = 0, max = 0.5) 246s + if (mode == "numeric") x[1] <- Inf 246s + 246s + for (diff in 1:2) { 246s + for (idxs in index_cases) { 246s + validateIndicesTestVector(x, idxs, 246s + ftest = fcn, fsure = fcn, 246s + na.rm = TRUE, diff = diff, trim = trim) 246s + validateIndicesTestVector(x, idxs, 246s + ftest = fcn, fsure = fcn, 246s + na.rm = FALSE, diff = diff, trim = trim) 246s + } 246s + } 246s + } 246s + cat(sprintf("%s()...DONE\n", name)) 246s + } 246s subsetted tests on varDiff()... 246s varDiff()...DONE 246s subsetted tests on sdDiff()... 246s sdDiff()...DONE 246s subsetted tests on madDiff()... 246s madDiff()...DONE 246s subsetted tests on iqrDiff()... 246s iqrDiff()...DONE 246s > 246s 246s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 246s Copyright (C) 2024 The R Foundation for Statistical Computing 246s Platform: x86_64-pc-linux-gnu 246s 246s R is free software and comes with ABSOLUTELY NO WARRANTY. 246s You are welcome to redistribute it under certain conditions. 246s Type 'license()' or 'licence()' for distribution details. 246s 246s R is a collaborative project with many contributors. 246s Type 'contributors()' for more information and 246s 'citation()' on how to cite R or R packages in publications. 246s 246s Type 'demo()' for some demos, 'help()' for on-line help, or 246s 'help.start()' for an HTML browser interface to help. 246s Type 'q()' to quit R. 246s 246s > library("matrixStats") 246s > 246s > for (mode in c("logical", "integer", "double")) { 246s + cat("mode: ", mode, "", sep = "") 246s + n <- 2L 246s + x <- runif(n, min = -5, max = 5) 246s + if (mode == "logical") { 246s + x <- x > 0 246s + } 246s + storage.mode(x) <- mode 246s + str(x) 246s + 246s + cat("All weights are 1\n") 246s + w <- rep(1, times = n) 246s + m0 <- weighted.mean(x, w) 246s + m1 <- weightedMean(x, w) 246s + str(list(m0 = m0, m1 = m1)) 246s + stopifnot(identical(m1, m0)) 246s + 246s + cat("First weight is 5\n") 246s + # Pull the mean towards zero 246s + w[1] <- 5 246s + str(w) 246s + m0 <- weighted.mean(x, w) 246s + m1 <- weightedMean(x, w) 246s + str(list(m0 = m0, m1 = m1)) 246s + stopifnot(identical(m1, m0)) 246s + 246s + cat("All weights are 0\n") 246s + # All weights set to zero 246s + w <- rep(0, times = n) 246s + m0 <- weighted.mean(x, w) 246s + m1 <- weightedMean(x, w) 246s + str(list(m0 = m0, m1 = m1)) 246s + stopifnot(identical(m1, m0)) 246s + 246s + cat("First weight is 8.5\n") 246s + # Put even more weight on the zero 246s + w[1] <- 8.5 246s + m0 <- weighted.mean(x, w) 246s + m1 <- weightedMean(x, w) 246s + str(list(m0 = m0, m1 = m1)) 246s + stopifnot(identical(m1, m0)) 246s + 246s + cat("First weight is Inf\n") 246s + # All weight on the first value 246s + w[1] <- Inf 246s + m0 <- weighted.mean(x, w) 246s + m1 <- weightedMean(x, w) 246s + str(list(m0 = m0, m1 = m1)) 246s + stopifnot(identical(m1, m0)) 246s + 246s + cat("Last weight is Inf\n") 246s + # All weight on the last value 246s + w[1] <- 1 246s + w[n] <- Inf 246s + m0 <- weighted.mean(x, w) 246s + m1 <- weightedMean(x, w) 246s + str(list(m0 = m0, m1 = m1)) 246s + stopifnot(identical(m1, m0)) 246s + } # for (mode ...) 246s mode: logical logi [1:2] FALSE FALSE 246s All weights are 1 246s List of 2 246s $ m0: num 0 246s $ m1: num 0 246s First weight is 5 246s num [1:2] 5 1 246s List of 2 246s $ m0: num 0 246s $ m1: num 0 246s All weights are 0 246s List of 2 246s $ m0: num NaN 246s $ m1: num NaN 246s First weight is 8.5 246s List of 2 246s $ m0: num 0 246s $ m1: num 0 246s First weight is Inf 246s List of 2 246s $ m0: num NaN 246s $ m1: num NaN 246s Last weight is Inf 246s List of 2 246s $ m0: num NaN 246s $ m1: num NaN 246s mode: integer int [1:2] 3 -1 246s All weights are 1 246s List of 2 246s $ m0: num 1 246s $ m1: num 1 246s First weight is 5 246s num [1:2] 5 1 246s List of 2 246s $ m0: num 2.33 246s $ m1: num 2.33 246s All weights are 0 246s List of 2 246s $ m0: num NaN 246s $ m1: num NaN 246s First weight is 8.5 246s List of 2 246s $ m0: num 3 246s $ m1: num 3 246s First weight is Inf 246s List of 2 246s $ m0: num NaN 246s $ m1: num NaN 246s Last weight is Inf 246s List of 2 246s $ m0: num NaN 246s $ m1: num NaN 246s mode: double num [1:2] 4.38 4.09 246s All weights are 1 246s List of 2 246s $ m0: num 4.24 246s $ m1: num 4.24 246s First weight is 5 246s num [1:2] 5 1 246s List of 2 246s $ m0: num 4.33 246s $ m1: num 4.33 246s All weights are 0 246s List of 2 246s $ m0: num NaN 246s $ m1: num NaN 246s First weight is 8.5 246s List of 2 246s $ m0: num 4.38 246s $ m1: num 4.38 246s First weight is Inf 246s List of 2 246s $ m0: num NaN 246s $ m1: num NaN 246s Last weight is Inf 246s List of 2 246s $ m0: num NaN 246s $ m1: num NaN 246s > 246s > 246s > message("*** Testing for missing values") 246s > # NA tests 246s > xs <- list(A = c(1, 2, 3), B = c(NA, 2, 3), C = c(NA, 2, 3)) 246s > ws <- list(A = c(1, 1, 1), B = c(NA, 1, 1), C = c(1, NA, 1)) 246s *** Testing for missing values 246s > ## NOTE: The (B, B) case with na.rm = TRUE is interesting because 246s > ## even if NAs in 'w' are not dropped by na.rm = TRUE, this one 246s > ## is because 'x' is dropped and therefore that first element 246s > ## is skipped in the computation. It basically does 246s > ## keep <- !is.na(x); x <- x[keep]; w <- w[keep] 246s > ## without looking at 'w'. 246s > for (x in xs) { 246s + for (mode in c("logical", "integer", "double")) { 246s + storage.mode(x) <- mode 246s + for (w in ws) { 246s + for (na.rm in c(FALSE, TRUE)) { 246s + cat(sprintf("mode: %s, na.rm = %s\n", mode, na.rm)) 246s + str(list(x = x, w = w)) 246s + m0 <- weighted.mean(x, w, na.rm = na.rm) 246s + m1 <- weightedMean(x, w, na.rm = na.rm) 246s + str(list(m0 = m0, m1 = m1)) 246s + stopifnot(all.equal(m1, m0)) 246s + } 246s + } 246s + } 246s + } 246s mode: logical, na.rm = FALSE 246s List of 2 246s $ x: logi [1:3] TRUE TRUE TRUE 246s $ w: num [1:3] 1 1 1 246s List of 2 246s $ m0: num 1 246s $ m1: num 1 246s mode: logical, na.rm = TRUE 246s List of 2 246s $ x: logi [1:3] TRUE TRUE TRUE 246s $ w: num [1:3] 1 1 1 246s List of 2 246s $ m0: num 1 246s $ m1: num 1 246s mode: logical, na.rm = FALSE 246s List of 2 246s $ x: logi [1:3] TRUE TRUE TRUE 246s $ w: num [1:3] NA 1 1 246s List of 2 246s $ m0: num NA 246s $ m1: num NA 246s mode: logical, na.rm = TRUE 246s List of 2 246s $ x: logi [1:3] TRUE TRUE TRUE 246s $ w: num [1:3] NA 1 1 246s List of 2 246s $ m0: num NA 246s $ m1: num NA 246s mode: logical, na.rm = FALSE 246s List of 2 246s $ x: logi [1:3] TRUE TRUE TRUE 246s $ w: num [1:3] 1 NA 1 246s List of 2 246s $ m0: num NA 246s $ m1: num NA 246s mode: logical, na.rm = TRUE 246s List of 2 246s $ x: logi [1:3] TRUE TRUE TRUE 246s $ w: num [1:3] 1 NA 1 246s List of 2 246s $ m0: num NA 246s $ m1: num NA 246s mode: integer, na.rm = FALSE 246s List of 2 246s $ x: int [1:3] 1 1 1 246s $ w: num [1:3] 1 1 1 246s List of 2 246s $ m0: num 1 246s $ m1: num 1 246s mode: integer, na.rm = TRUE 246s List of 2 246s $ x: int [1:3] 1 1 1 246s $ w: num [1:3] 1 1 1 246s List of 2 246s $ m0: num 1 246s $ m1: num 1 246s mode: integer, na.rm = FALSE 246s List of 2 246s $ x: int [1:3] 1 1 1 246s $ w: num [1:3] NA 1 1 246s List of 2 246s $ m0: num NA 246s $ m1: num NA 246s mode: integer, na.rm = TRUE 246s List of 2 246s $ x: int [1:3] 1 1 1 246s $ w: num [1:3] NA 1 1 246s List of 2 246s $ m0: num NA 246s $ m1: num NA 246s mode: integer, na.rm = FALSE 246s List of 2 246s $ x: int [1:3] 1 1 1 246s $ w: num [1:3] 1 NA 1 246s List of 2 246s $ m0: num NA 246s $ m1: num NA 246s mode: integer, na.rm = TRUE 246s List of 2 246s $ x: int [1:3] 1 1 1 246s $ w: num [1:3] 1 NA 1 246s List of 2 246s $ m0: num NA 246s $ m1: num NA 246s mode: double, na.rm = FALSE 246s List of 2 246s $ x: num [1:3] 1 1 1 246s $ w: num [1:3] 1 1 1 246s List of 2 246s $ m0: num 1 246s $ m1: num 1 246s mode: double, na.rm = TRUE 246s List of 2 246s $ x: num [1:3] 1 1 1 246s $ w: num [1:3] 1 1 1 246s List of 2 246s $ m0: num 1 246s $ m1: num 1 246s mode: double, na.rm = FALSE 246s List of 2 246s $ x: num [1:3] 1 1 1 246s $ w: num [1:3] NA 1 1 246s List of 2 246s $ m0: num NA 246s $ m1: num NA 246s mode: double, na.rm = TRUE 246s List of 2 246s $ x: num [1:3] 1 1 1 246s $ w: num [1:3] NA 1 1 246s List of 2 246s $ m0: num NA 246s $ m1: num NA 246s mode: double, na.rm = FALSE 246s List of 2 246s $ x: num [1:3] 1 1 1 246s $ w: num [1:3] 1 NA 1 246s List of 2 246s $ m0: num NA 246s $ m1: num NA 246s mode: double, na.rm = TRUE 246s List of 2 246s $ x: num [1:3] 1 1 1 246s $ w: num [1:3] 1 NA 1 246s List of 2 246s $ m0: num NA 246s $ m1: num NA 246s mode: logical, na.rm = FALSE 246s List of 2 246s $ x: logi [1:3] NA TRUE TRUE 246s $ w: num [1:3] 1 1 1 246s List of 2 246s $ m0: num NA 246s $ m1: num NA 246s mode: logical, na.rm = TRUE 246s List of 2 246s $ x: logi [1:3] NA TRUE TRUE 246s $ w: num [1:3] 1 1 1 246s List of 2 246s $ m0: num 1 246s $ m1: num 1 246s mode: logical, na.rm = FALSE 246s List of 2 246s $ x: logi [1:3] NA TRUE TRUE 246s $ w: num [1:3] NA 1 1 246s List of 2 246s $ m0: num NA 246s $ m1: num NA 246s mode: logical, na.rm = TRUE 246s List of 2 246s $ x: logi [1:3] NA TRUE TRUE 246s $ w: num [1:3] NA 1 1 246s List of 2 246s $ m0: num 1 246s $ m1: num 1 246s mode: logical, na.rm = FALSE 246s List of 2 246s $ x: logi [1:3] NA TRUE TRUE 246s $ w: num [1:3] 1 NA 1 246s List of 2 246s $ m0: num NA 246s $ m1: num NA 246s mode: logical, na.rm = TRUE 246s List of 2 246s $ x: logi [1:3] NA TRUE TRUE 246s $ w: num [1:3] 1 NA 1 246s List of 2 246s $ m0: num NA 246s $ m1: num NA 246s mode: integer, na.rm = FALSE 246s List of 2 246s $ x: int [1:3] NA 1 1 246s $ w: num [1:3] 1 1 1 246s List of 2 246s $ m0: num NA 246s $ m1: num NA 246s mode: integer, na.rm = TRUE 246s List of 2 246s $ x: int [1:3] NA 1 1 246s $ w: num [1:3] 1 1 1 246s List of 2 246s $ m0: num 1 246s $ m1: num 1 246s mode: integer, na.rm = FALSE 246s List of 2 246s $ x: int [1:3] NA 1 1 246s $ w: num [1:3] NA 1 1 246s List of 2 246s $ m0: num NA 246s $ m1: num NA 246s mode: integer, na.rm = TRUE 246s List of 2 246s $ x: int [1:3] NA 1 1 246s $ w: num [1:3] NA 1 1 246s List of 2 246s $ m0: num 1 246s $ m1: num 1 246s mode: integer, na.rm = FALSE 246s List of 2 246s $ x: int [1:3] NA 1 1 246s $ w: num [1:3] 1 NA 1 246s List of 2 246s $ m0: num NA 246s $ m1: num NA 246s mode: integer, na.rm = TRUE 246s List of 2 246s $ x: int [1:3] NA 1 1 246s $ w: num [1:3] 1 NA 1 246s List of 2 246s $ m0: num NA 246s $ m1: num NA 246s mode: double, na.rm = FALSE 246s List of 2 246s $ x: num [1:3] NA 1 1 246s $ w: num [1:3] 1 1 1 246s List of 2 246s $ m0: num NA 246s $ m1: num NA 246s mode: double, na.rm = TRUE 246s List of 2 246s $ x: num [1:3] NA 1 1 246s $ w: num [1:3] 1 1 1 246s List of 2 246s $ m0: num 1 246s $ m1: num 1 246s mode: double, na.rm = FALSE 246s List of 2 246s $ x: num [1:3] NA 1 1 246s $ w: num [1:3] NA 1 1 246s List of 2 246s $ m0: num NA 246s $ m1: num NA 246s mode: double, na.rm = TRUE 246s List of 2 246s $ x: num [1:3] NA 1 1 246s $ w: num [1:3] NA 1 1 246s List of 2 246s $ m0: num 1 246s $ m1: num 1 246s mode: double, na.rm = FALSE 246s List of 2 246s $ x: num [1:3] NA 1 1 246s $ w: num [1:3] 1 NA 1 246s List of 2 246s $ m0: num NA 246s $ m1: num NA 246s mode: double, na.rm = TRUE 246s List of 2 246s $ x: num [1:3] NA 1 1 246s $ w: num [1:3] 1 NA 1 246s List of 2 246s $ m0: num NA 246s $ m1: num NA 246s mode: logical, na.rm = FALSE 246s List of 2 246s $ x: logi [1:3] NA TRUE TRUE 246s $ w: num [1:3] 1 1 1 246s List of 2 246s $ m0: num NA 246s $ m1: num NA 246s mode: logical, na.rm = TRUE 246s List of 2 246s $ x: logi [1:3] NA TRUE TRUE 246s $ w: num [1:3] 1 1 1 246s List of 2 246s $ m0: num 1 246s $ m1: num 1 246s mode: logical, na.rm = FALSE 246s List of 2 246s $ x: logi [1:3] NA TRUE TRUE 246s $ w: num [1:3] NA 1 1 246s List of 2 246s $ m0: num NA 246s $ m1: num NA 246s mode: logical, na.rm = TRUE 246s List of 2 246s $ x: logi [1:3] NA TRUE TRUE 246s $ w: num [1:3] NA 1 1 246s List of 2 246s $ m0: num 1 246s $ m1: num 1 246s mode: logical, na.rm = FALSE 246s List of 2 246s $ x: logi [1:3] NA TRUE TRUE 246s $ w: num [1:3] 1 NA 1 246s List of 2 246s $ m0: num NA 246s $ m1: num NA 246s mode: logical, na.rm = TRUE 246s List of 2 246s $ x: logi [1:3] NA TRUE TRUE 246s $ w: num [1:3] 1 NA 1 246s List of 2 246s $ m0: num NA 246s $ m1: num NA 246s mode: integer, na.rm = FALSE 246s List of 2 246s $ x: int [1:3] NA 1 1 246s $ w: num [1:3] 1 1 1 246s List of 2 246s $ m0: num NA 246s $ m1: num NA 246s mode: integer, na.rm = TRUE 246s List of 2 246s $ x: int [1:3] NA 1 1 246s $ w: num [1:3] 1 1 1 246s List of 2 246s $ m0: num 1 246s $ m1: num 1 246s mode: integer, na.rm = FALSE 246s List of 2 246s $ x: int [1:3] NA 1 1 246s $ w: num [1:3] NA 1 1 246s List of 2 246s $ m0: num NA 246s $ m1: num NA 246s mode: integer, na.rm = TRUE 246s List of 2 246s $ x: int [1:3] NA 1 1 246s $ w: num [1:3] NA 1 1 246s List of 2 246s $ m0: num 1 246s $ m1: num 1 246s mode: integer, na.rm = FALSE 246s List of 2 246s $ x: int [1:3] NA 1 1 246s $ w: num [1:3] 1 NA 1 246s List of 2 246s $ m0: num NA 246s $ m1: num NA 246s mode: integer, na.rm = TRUE 246s List of 2 246s $ x: int [1:3] NA 1 1 246s $ w: num [1:3] 1 NA 1 246s List of 2 246s $ m0: num NA 246s $ m1: num NA 246s mode: double, na.rm = FALSE 246s List of 2 246s $ x: num [1:3] NA 1 1 246s $ w: num [1:3] 1 1 1 246s List of 2 246s $ m0: num NA 246s $ m1: num NA 246s mode: double, na.rm = TRUE 246s List of 2 246s $ x: num [1:3] NA 1 1 246s $ w: num [1:3] 1 1 1 246s List of 2 246s $ m0: num 1 246s $ m1: num 1 246s mode: double, na.rm = FALSE 246s List of 2 246s $ x: num [1:3] NA 1 1 246s $ w: num [1:3] NA 1 1 246s List of 2 246s $ m0: num NA 246s $ m1: num NA 246s mode: double, na.rm = TRUE 246s List of 2 246s $ x: num [1:3] NA 1 1 246s $ w: num [1:3] NA 1 1 246s List of 2 246s $ m0: num 1 246s $ m1: num 1 246s mode: double, na.rm = FALSE 246s List of 2 246s $ x: num [1:3] NA 1 1 246s $ w: num [1:3] 1 NA 1 246s List of 2 246s $ m0: num NA 246s $ m1: num NA 246s mode: double, na.rm = TRUE 246s List of 2 246s $ x: num [1:3] NA 1 1 246s $ w: num [1:3] 1 NA 1 246s List of 2 246s $ m0: num NA 246s $ m1: num NA 246s > 246s 246s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 246s Copyright (C) 2024 The R Foundation for Statistical Computing 246s Platform: x86_64-pc-linux-gnu 246s 246s R is free software and comes with ABSOLUTELY NO WARRANTY. 246s You are welcome to redistribute it under certain conditions. 246s Type 'license()' or 'licence()' for distribution details. 246s 246s R is a collaborative project with many contributors. 246s Type 'contributors()' for more information and 246s 'citation()' on how to cite R or R packages in publications. 246s 246s Type 'demo()' for some demos, 'help()' for on-line help, or 246s 'help.start()' for an HTML browser interface to help. 246s Type 'q()' to quit R. 246s 246s > library("matrixStats") 246s > 246s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 246s > # Subsetted tests 246s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 246s > source("utils/validateIndicesFramework.R") 246s > for (mode in c("numeric", "integer")) { 246s + x <- runif(6, min = -6, max = 6) 246s + w <- runif(6, min = 0, max = 6) 246s + storage.mode(x) <- mode 246s + storage.mode(w) <- mode 246s + if (mode == "numeric") w[1] <- Inf 246s + 246s + for (idxs in index_cases) { 246s + validateIndicesTestVector_w(x, w, idxs, 246s + ftest = weightedMean, fsure = weighted.mean, 246s + na.rm = TRUE, refine = TRUE) 246s + validateIndicesTestVector_w(x, w, idxs, 246s + ftest = weightedMean, fsure = weighted.mean, 246s + na.rm = FALSE, refine = TRUE) 246s + } 246s + } 246s > 247s 247s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 247s Copyright (C) 2024 The R Foundation for Statistical Computing 247s Platform: x86_64-pc-linux-gnu 247s 247s R is free software and comes with ABSOLUTELY NO WARRANTY. 247s You are welcome to redistribute it under certain conditions. 247s Type 'license()' or 'licence()' for distribution details. 247s 247s R is a collaborative project with many contributors. 247s Type 'contributors()' for more information and 247s 'citation()' on how to cite R or R packages in publications. 247s 247s Type 'demo()' for some demos, 'help()' for on-line help, or 247s 'help.start()' for an HTML browser interface to help. 247s Type 'q()' to quit R. 247s 247s > library("matrixStats") 247s > 247s > x <- 1:5 247s > y <- weightedMedian(x) 247s > y <- weightedMedian(x, w = c(NA, Inf, NA, Inf, NA), na.rm = TRUE) 247s > print(y) 247s [1] 3 247s > 247s > y <- weightedMedian(x, w = c(NA, Inf, NA, Inf, NA), na.rm = FALSE) 247s > print(y) 247s [1] NA 247s > stopifnot(is.na(y)) 247s > 247s > x <- 1:10 247s > n <- length(x) 247s > 247s > y1 <- median(x) # 5.5 247s > y2 <- weightedMedian(x) # 5.5 247s > stopifnot(all.equal(y1, y2)) 247s > 247s > 247s > w <- rep(1, times = n) 247s > y1 <- weightedMedian(x, w) # 5.5 (default) 247s > y2a <- weightedMedian(x, ties = "weighted") # 5.5 (default) 247s > y2b <- weightedMedian(x, ties = "min") # 5 247s > y2c <- weightedMedian(x, ties = "max") # 6 247s > stopifnot(all.equal(y2a, y1)) 247s > 247s > y3 <- weightedMedian(x, w) # 5.5 (default) 247s > 247s > 247s > # Pull the median towards zero 247s > w[1] <- 5 247s > y1 <- weightedMedian(x, w) # 3.5 247s > y <- c(rep(0, times = w[1]), x[-1]) # Only possible for integer weights 247s > y2 <- median(y) # 3.5 247s > stopifnot(all.equal(y1, y2)) 247s > 247s > # Put even more weight on the zero 247s > w[1] <- 8.5 247s > y <- weightedMedian(x, w) # 2 247s > 247s > # All weight on the first value 247s > w[1] <- Inf 247s > y <- weightedMedian(x, w) # 1 247s > 247s > # All weight on the last value 247s > w[1] <- 1 247s > w[n] <- Inf 247s > y <- weightedMedian(x, w) # 10 247s > 247s > # All weights set to zero 247s > w <- rep(0, times = n) 247s > y <- weightedMedian(x, w) # NA 247s > 247s > x <- 1:4 247s > w <- rep(1, times = 4) 247s > for (mode in c("integer", "double")) { 247s + storage.mode(x) <- mode 247s + for (ties in c("weighted", "mean", "min", "max")) { 247s + cat(sprintf("ties = %s\n", ties)) 247s + y <- weightedMedian(x, w, ties = ties) 247s + } 247s + } 247s ties = weighted 247s ties = mean 247s ties = min 247s ties = max 247s ties = weighted 247s ties = mean 247s ties = min 247s ties = max 247s > 247s > set.seed(0x42) 247s > 247s > y <- weightedMedian(x = double(0L)) 247s > print(y) 247s [1] NA 247s > stopifnot(length(y) == 1L) 247s > stopifnot(is.na(y)) 247s > 247s > y <- weightedMedian(x = x[1]) 247s > print(y) 247s [1] 1 247s > stopifnot(length(y) == 1L) 247s > stopifnot(all.equal(y, x[1])) 247s > 247s > 247s > n <- 1e3 247s > x <- runif(n) 247s > w <- runif(n, min = 0, max = 1) 247s > for (mode in c("integer", "double")) { 247s + storage.mode(x) <- mode 247s + for (ties in c("weighted", "mean", "min", "max")) { 247s + y <- weightedMedian(x, w, ties = ties) 247s + cat(sprintf("mode = %s, ties = %s, result = %g\n", mode, ties, y)) 247s + } 247s + } 247s mode = integer, ties = weighted, result = 0 247s mode = integer, ties = mean, result = 0 247s mode = integer, ties = min, result = 0 247s mode = integer, ties = max, result = 0 247s mode = double, ties = weighted, result = 0 247s mode = double, ties = mean, result = 0 247s mode = double, ties = min, result = 0 247s mode = double, ties = max, result = 0 247s > 247s > 247s > # A large vector 247s > n <- 1e5 247s > x <- runif(n) 247s > w <- runif(n, min = 0, max = 1) 247s > y <- weightedMedian(x, w) 247s > 247s > y <- weightedMedian(x, w, ties = "min") 247s > 247s > 247s > # Single Number 247s > xs <- c(1, NA_integer_) 247s > ws <- c(1, NA_integer_) 247s > for (x in xs) { 247s + for (w in ws) { 247s + y <- weightedMedian(x = x, w = w) 247s + if (is.na(w)) z <- NA_real_ 247s + else z <- x[1] 247s + stopifnot(all.equal(y, z)) 247s + } 247s + } 247s > 247s > ## Logical 247s > x1 <- c(TRUE, FALSE, TRUE) 247s > w0 <- c(0, 0, 0) 247s > stopifnot(!is.finite(weightedMedian(x1, w0)), 247s + !is.infinite(weightedMedian(x1, w0))) 247s > 247s > w1 <- c(1, 1, 1) 247s > stopifnot(weightedMedian(x1, w1) == 1) 247s > 247s > w2 <- c(1, 2, 3) 247s > stopifnot(weightedMedian(x1, w2) == 1) 247s > 247s > ### NA 247s > stopifnot(is.na(weightedMedian(c(TRUE, FALSE, NA), 247s + c(1, 2, 3))), 247s + all.equal(weightedMedian(c(TRUE, FALSE, NA), 247s + c(1, 2, 3), 247s + na.rm = TRUE), 247s + weightedMedian(c(TRUE, FALSE), 247s + c(1, 2)))) 247s > ### Identical to as.integer() 247s > x <- rcauchy(100) 247s > w <- abs(rcauchy(100)) 247s > stopifnot(all.equal(weightedMedian(x > 0, w), 247s + weightedMedian(as.integer(x > 0), w))) 247s > 247s > 247s > 247s 247s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 247s Copyright (C) 2024 The R Foundation for Statistical Computing 247s Platform: x86_64-pc-linux-gnu 247s 247s R is free software and comes with ABSOLUTELY NO WARRANTY. 247s You are welcome to redistribute it under certain conditions. 247s Type 'license()' or 'licence()' for distribution details. 247s 247s R is a collaborative project with many contributors. 247s Type 'contributors()' for more information and 247s 'citation()' on how to cite R or R packages in publications. 247s 247s Type 'demo()' for some demos, 'help()' for on-line help, or 247s 'help.start()' for an HTML browser interface to help. 247s Type 'q()' to quit R. 247s 247s > library("matrixStats") 247s > 247s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 247s > # Subsetted tests 247s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 247s > source("utils/validateIndicesFramework.R") 247s > for (mode in c("numeric", "integer")) { 247s + x <- runif(6, min = -6, max = 6) 247s + w <- runif(6, min = 0, max = 6) 247s + storage.mode(x) <- mode 247s + storage.mode(w) <- mode 247s + if (mode == "numeric") w[1] <- Inf 247s + 247s + for (idxs in index_cases) { 247s + validateIndicesTestVector_w(x, w, idxs, 247s + ftest = weightedMedian, 247s + fsure = weightedMedian, 247s + na.rm = TRUE) 247s + validateIndicesTestVector_w(x, w, idxs, 247s + ftest = weightedMedian, 247s + fsure = weightedMedian, 247s + na.rm = FALSE) 247s + 247s + for (ties in c("weighted", "mean", "min", "max")) { 247s + validateIndicesTestVector_w(x, w, idxs, 247s + ftest = weightedMedian, 247s + fsure = weightedMedian, 247s + na.rm = TRUE, ties = ties) 247s + validateIndicesTestVector_w(x, w, idxs, 247s + ftest = weightedMedian, 247s + fsure = weightedMedian, 247s + na.rm = FALSE, ties = ties) 247s + } 247s + } 247s + } 247s > 247s 247s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 247s Copyright (C) 2024 The R Foundation for Statistical Computing 247s Platform: x86_64-pc-linux-gnu 247s 247s R is free software and comes with ABSOLUTELY NO WARRANTY. 247s You are welcome to redistribute it under certain conditions. 247s Type 'license()' or 'licence()' for distribution details. 247s 247s R is a collaborative project with many contributors. 247s Type 'contributors()' for more information and 247s 'citation()' on how to cite R or R packages in publications. 247s 247s Type 'demo()' for some demos, 'help()' for on-line help, or 247s 'help.start()' for an HTML browser interface to help. 247s Type 'q()' to quit R. 247s 247s > library("matrixStats") 247s > 247s > weightedVar_R <- function(x, w) { 247s + mu <- weighted.mean(x, w = w) 247s + sum(w * (x - mu) ^ 2) / (sum(w) - 1) 247s + } 247s > 247s > 247s > n <- 10 247s > x <- as.double(1:n) 247s > 247s > message("*** weightedVar() ...") 247s > 247s > message("- Zero elements") 247s > m0 <- var(integer(0)) 247s > m1 <- weightedVar(integer(0), w = integer(0)) 247s *** weightedVar() ... 247s - Zero elements 247s > str(list(m0 = m0, m1 = m1)) 247s List of 2 247s $ m0: num NA 247s $ m1: int NA 247s > stopifnot(all.equal(m1, m0)) 247s > 247s > 247s > message("- One elements") 247s > m0 <- var(1) 247s > m1 <- weightedVar(1) 247s - One elements 247s > str(list(m0 = m0, m1 = m1)) 247s List of 2 247s $ m0: num NA 247s $ m1: num NA 247s - Uniform weights (all w = 1) 247s > stopifnot(all.equal(m1, m0)) 247s > 247s > 247s > message("- Uniform weights (all w = 1)") 247s > m0 <- var(x) 247s > w <- rep(1, times = n) 247s > m1 <- weightedVar(x, w = w) 247s > str(list(m0 = m0, m1 = m1)) 247s List of 2 247s $ m0: num 9.17 247s $ m1: num 9.17 247s > stopifnot(all.equal(m1, m0)) 247s > 247s > 247s > message("- Uniform weights (all w = 3)") 247s > m0 <- var(rep(x, each = 3)) 247s - Uniform weights (all w = 3) 247s > w <- rep(3, times = n) 247s > m1 <- weightedVar(x, w = w) 247s > str(list(m0 = m0, m1 = m1)) 247s List of 2 247s $ m0: num 8.53 247s $ m1: num 8.53 247s > stopifnot(all.equal(m1, m0)) 247s > 247s > 247s > message("- Uniform weights on the first five elements") 247s - Uniform weights on the first five elements 247s > idxs <- 1:5 247s > m0 <- var(x[1:5]) 247s > w <- rep(0, times = n) 247s > w[idxs] <- 1 247s > m1 <- weightedVar(x, w = w) 247s > str(list(m0 = m0, m1 = m1)) 247s List of 2 247s $ m0: num 2.5 247s $ m1:- Uniform weights on every second elements 247s num 2.5 247s > stopifnot(all.equal(m1, m0)) 247s > 247s > 247s > message("- Uniform weights on every second elements") 247s > idxs <- seq(from = 1, to = n, by = 2) 247s > m0 <- var(x[idxs]) 247s > w <- rep(0, times = n) 247s > w[idxs] <- 1 247s > m1 <- weightedVar(x, w = w) 247s > str(list(m0 = m0, m1 = m1)) 247s List of 2 247s $ m0: num 10 247s $ m1: num 10 247s > stopifnot(all.equal(m1, m0)) 247s > 247s > 247s > message("- All weights are zero") 247s - All weights are zero 247s > idxs <- integer(0L) 247s > m0 <- var(x[idxs]) 247s > w <- rep(0, times = n) 247s > w[idxs] <- 1 247s > m1 <- weightedVar(x, w = w) 247s > str(list(m0 = m0, m1 = m1)) 247s List of 2 247s $ m0: num NA 247s $ m1: num NA 247s > stopifnot(all.equal(m1, m0)) 247s > 247s > message("- Infinite weight on first element") 247s - Infinite weight on first element 247s > idxs <- 1L 247s > m0 <- var(x[idxs]) 247s > w <- rep(0, times = n) 247s > w[idxs] <- Inf 247s > m1 <- weightedVar(x, w = w) 247s > str(list(m0 = m0, m1 = m1)) 247s List of 2 247s $ m0: num NA 247s $ m1: num NA 247s > stopifnot(all.equal(m1, m0)) 247s > 247s > message("- Missing-value weight on first element") 247s - Missing-value weight on first element 247s > idxs <- 1L 247s > w <- rep(1, times = n) 247s > w[idxs] <- NA_real_ 247s > m1 <- weightedVar(x, w = w) 247s > str(list(m1 = m1)) 247s List of 1 247s $ m1:- Frequency weights 247s num NA 247s > stopifnot(identical(m1, NA_real_)) 247s > 247s > 247s > message("- Frequency weights") 247s > 247s > ## From https://en.wikipedia.org/wiki/Weighted_arithmetic_mean 247s > y <- c(2, 2, 4, 5, 5, 5) 247s > x <- unique(y) 247s > w <- table(y) 247s > stopifnot(names(w) == x) 247s > 247s > m0 <- weightedVar(x, w = w) 247s > m1 <- var(y) 247s > stopifnot(all.equal(m1, m0)) 247s > m2 <- weightedVar(x, w = w) 247s > str(list(m0 = m0, m1 = m1, m2 = m2)) 247s List of 3 247s $ m0: num 2.17 247s $ m1: num 2.17 247s $ m2: num 2.17 247s > stopifnot(all.equal(m2, m0)) 247s > 247s > ## From https://github.com/HenrikBengtsson/matrixStats/issues/72 247s > large <- c(21, 8, 26, 1, 15, 33, 12, 25, 0, 84) 247s > years <- c(41706, 9301, 33678, 3082, 27040, 44188, 10049, 30591, 2275, 109831) 247s > 247s > m0 <- weightedVar(large, w = years) 247s > m1 <- weightedVar(large, w = years) 247s > str(list(m0 = m0, m1 = m1)) 247s List of 2 247s $ m0: num 899 247s $ m1:*** weightedVar() ... DONE 247s num 899 247s > stopifnot(all.equal(m1, m0)) 247s > 247s > message("*** weightedVar() ... DONE") 247s > 247s 247s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 247s Copyright (C) 2024 The R Foundation for Statistical Computing 247s Platform: x86_64-pc-linux-gnu 247s 247s R is free software and comes with ABSOLUTELY NO WARRANTY. 247s You are welcome to redistribute it under certain conditions. 247s Type 'license()' or 'licence()' for distribution details. 247s 247s R is a collaborative project with many contributors. 247s Type 'contributors()' for more information and 247s 'citation()' on how to cite R or R packages in publications. 247s 247s Type 'demo()' for some demos, 'help()' for on-line help, or 247s 'help.start()' for an HTML browser interface to help. 247s Type 'q()' to quit R. 247s 247s > library("matrixStats") 247s > 247s > fcns <- list( 247s + weightedVar = weightedVar, 247s + weightedSd = weightedSd, 247s + weightedMad = weightedMad 247s + ) 247s > 247s > for (name in names(fcns)) { 247s + cat(sprintf("%s()...\n", name)) 247s + fcn <- fcns[[name]] 247s + 247s + for (mode in c("integer", "double")) { 247s + cat("mode: ", mode, "\n", sep = "") 247s + n <- 15L 247s + x <- runif(n, min = -5, max = 5) 247s + storage.mode(x) <- mode 247s + str(x) 247s + 247s + for (add_na in c(FALSE, TRUE)) { 247s + cat("add_na: ", add_na, "\n", sep = "") 247s + if (add_na) { 247s + x[c(5, 7)] <- NA 247s + } 247s + str(x) 247s + 247s + for (na.rm in c(FALSE, TRUE)) { 247s + cat("na.rm: ", na.rm, "\n", sep = "") 247s + 247s + cat("Weights are not specified (all are 1)\n") 247s + m1 <- fcn(x, na.rm = na.rm) 247s + str(list(m1 = m1)) 247s + 247s + cat("All weights are 1\n") 247s + w <- rep(1, times = n) 247s + m1 <- fcn(x, w, na.rm = na.rm) 247s + str(list(m1 = m1)) 247s + 247s + cat("First weight is 5\n") 247s + # Pull the mean towards zero 247s + w[1] <- 5 247s + str(w) 247s + m1 <- fcn(x, w, na.rm = na.rm) 247s + str(list(m1 = m1)) 247s + 247s + cat("All weights are 0\n") 247s + # All weights set to zero 247s + w <- rep(0, times = n) 247s + m1 <- fcn(x, w, na.rm = na.rm) 247s + str(list(m1 = m1)) 247s + 247s + cat("First weight is 8.5\n") 247s + # Put even more weight on the zero 247s + w[1] <- 8.5 247s + m1 <- fcn(x, w, na.rm = na.rm) 247s + str(list(m1 = m1)) 247s + 247s + cat("First weight is Inf\n") 247s + # All weight on the first value 247s + w[1] <- Inf 247s + m1 <- fcn(x, w, na.rm = na.rm) 247s + str(list(m1 = m1)) 247s + 247s + cat("Last weight is Inf\n") 247s + # All weight on the last value 247s + w[1] <- 1 247s + w[n] <- Inf 247s + m1 <- fcn(x, w, na.rm = na.rm) 247s + str(list(m1 = m1)) 247s + 247s + cat("Last weight is NA\n") 247s + # All weight on the last value 247s + w[1] <- 1 247s + w[n] <- NA_real_ 247s + m1 <- fcn(x, w, na.rm = na.rm) 247s + str(list(m1 = m1)) 247s + } # for (na.rm ...) 247s + } # for (add_na ...) 247s + } # for (mode ...) 247s + 247s + cat(sprintf("%s()...DONE\n", name)) 247s + } # for (name ...) 247s weightedVar()... 247s mode: integer 247s int [1:15] 0 -2 2 1 -1 1 0 3 0 1 ... 247s add_na: FALSE 247s int [1:15] 0 -2 2 1 -1 1 0 3 0 1 ... 247s na.rm: FALSE 247s Weights are not specified (all are 1) 247s List of 1 247s $ m1: num 2.41 247s All weights are 1 247s List of 1 247s $ m1: num 2.41 247s First weight is 5 247s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 247s List of 1 247s $ m1: num 1.92 247s All weights are 0 247s List of 1 247s $ m1: int NA 247s First weight is 8.5 247s List of 1 247s $ m1: int NA 247s First weight is Inf 247s List of 1 247s $ m1: int NA 247s Last weight is Inf 247s List of 1 247s $ m1: int NA 247s Last weight is NA 247s List of 1 247s $ m1: int NA 247s na.rm: TRUE 247s Weights are not specified (all are 1) 247s List of 1 247s $ m1: num 2.41 247s All weights are 1 247s List of 1 247s $ m1: num 2.41 247s First weight is 5 247s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 247s List of 1 247s $ m1: num 1.92 247s All weights are 0 247s List of 1 247s $ m1: int NA 247s First weight is 8.5 247s List of 1 247s $ m1: int NA 247s First weight is Inf 247s List of 1 247s $ m1: int NA 247s Last weight is Inf 247s List of 1 247s $ m1: int NA 247s Last weight is NA 247s List of 1 247s $ m1: int NA 247s add_na: TRUE 247s int [1:15] 0 -2 2 1 NA 1 NA 3 0 1 ... 247s na.rm: FALSE 247s Weights are not specified (all are 1) 247s List of 1 247s $ m1: int NA 247s All weights are 1 247s List of 1 247s $ m1: int NA 247s First weight is 5 247s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 247s List of 1 247s $ m1: int NA 247s All weights are 0 247s List of 1 247s $ m1: int NA 247s First weight is 8.5 247s List of 1 247s $ m1: int NA 247s First weight is Inf 247s List of 1 247s $ m1: int NA 247s Last weight is Inf 247s List of 1 247s $ m1: int NA 247s Last weight is NA 247s List of 1 247s $ m1: int NA 247s na.rm: TRUE 247s Weights are not specified (all are 1) 247s List of 1 247s $ m1: num 2.56 247s All weights are 1 247s List of 1 247s $ m1: num 2.56 247s First weight is 5 247s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 247s List of 1 247s $ m1: num 2.01 247s All weights are 0 247s List of 1 247s $ m1: int NA 247s First weight is 8.5 247s List of 1 247s $ m1: int NA 247s First weight is Inf 247s List of 1 247s $ m1: int NA 247s Last weight is Inf 247s List of 1 247s $ m1: int NA 247s Last weight is NA 247s List of 1 247s $ m1: int NA 247s mode: double 247s num [1:15] 3.38 -2.6 -3.99 -2.93 3.24 ... 247s add_na: FALSE 247s num [1:15] 3.38 -2.6 -3.99 -2.93 3.24 ... 247s na.rm: FALSE 247s Weights are not specified (all are 1) 247s List of 1 247s $ m1: num 12.6 247s All weights are 1 247s List of 1 247s $ m1: num 12.6 247s First weight is 5 247s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 247s List of 1 247s $ m1: num 11.4 247s All weights are 0 247s List of 1 247s $ m1: num NA 247s First weight is 8.5 247s List of 1 247s $ m1: num NA 247s First weight is Inf 247s List of 1 247s $ m1: num NA 247s Last weight is Inf 247s List of 1 247s $ m1: num NA 247s Last weight is NA 247s List of 1 247s $ m1: num NA 247s na.rm: TRUE 247s Weights are not specified (all are 1) 247s List of 1 247s $ m1: num 12.6 247s All weights are 1 247s List of 1 247s $ m1: num 12.6 247s First weight is 5 247s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 247s List of 1 247s $ m1: num 11.4 247s All weights are 0 247s List of 1 247s $ m1: num NA 247s First weight is 8.5 247s List of 1 247s $ m1: num NA 247s First weight is Inf 247s List of 1 247s $ m1: num NA 247s Last weight is Inf 247s List of 1 247s $ m1: num NA 247s Last weight is NA 247s List of 1 247s $ m1: num NA 247s add_na: TRUE 247s num [1:15] 3.38 -2.6 -3.99 -2.93 NA ... 247s na.rm: FALSE 247s Weights are not specified (all are 1) 247s List of 1 247s $ m1: num NA 247s All weights are 1 247s List of 1 247s $ m1: num NA 247s First weight is 5 247s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 247s List of 1 247s $ m1: num NA 247s All weights are 0 247s List of 1 247s $ m1: num NA 247s First weight is 8.5 247s List of 1 247s $ m1: num NA 247s First weight is Inf 247s List of 1 247s $ m1: num NA 247s Last weight is Inf 247s List of 1 247s $ m1: num NA 247s Last weight is NA 247s List of 1 247s $ m1: num NA 247s na.rm: TRUE 247s Weights are not specified (all are 1) 247s List of 1 247s $ m1: num 14 247s All weights are 1 247s List of 1 247s $ m1: num 14 247s First weight is 5 247s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 247s List of 1 247s $ m1: num 12.4 247s All weights are 0 247s List of 1 247s $ m1: num NA 247s First weight is 8.5 247s List of 1 247s $ m1: num NA 247s First weight is Inf 247s List of 1 247s $ m1: num NA 247s Last weight is Inf 247s List of 1 247s $ m1: num NA 247s Last weight is NA 247s List of 1 247s $ m1: num NA 247s weightedVar()...DONE 247s weightedSd()... 247s mode: integer 247s int [1:15] -1 0 -2 -1 0 -1 0 -3 0 -1 ... 247s add_na: FALSE 247s int [1:15] -1 0 -2 -1 0 -1 0 -3 0 -1 ... 247s na.rm: FALSE 247s Weights are not specified (all are 1) 247s List of 1 247s $ m1: num 1.81 247s All weights are 1 247s List of 1 247s $ m1: num 1.81 247s First weight is 5 247s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 247s List of 1 247s $ m1: num 1.65 247s All weights are 0 247s List of 1 247s $ m1: num NA 247s First weight is 8.5 247s List of 1 247s $ m1: num NA 247s First weight is Inf 247s List of 1 247s $ m1: num NA 247s Last weight is Inf 247s List of 1 247s $ m1: num NA 247s Last weight is NA 247s List of 1 247s $ m1: num NA 247s na.rm: TRUE 247s Weights are not specified (all are 1) 247s List of 1 247s $ m1: num 1.81 247s All weights are 1 247s List of 1 247s $ m1: num 1.81 247s First weight is 5 247s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 247s List of 1 247s $ m1: num 1.65 247s All weights are 0 247s List of 1 247s $ m1: num NA 247s First weight is 8.5 247s List of 1 247s $ m1: num NA 247s First weight is Inf 247s List of 1 247s $ m1: num NA 247s Last weight is Inf 247s List of 1 247s $ m1: num NA 247s Last weight is NA 247s List of 1 247s $ m1: num NA 247s add_na: TRUE 247s int [1:15] -1 0 -2 -1 NA -1 NA -3 0 -1 ... 247s na.rm: FALSE 247s Weights are not specified (all are 1) 247s List of 1 247s $ m1: num NA 247s All weights are 1 247s List of 1 247s $ m1: num NA 247s First weight is 5 247s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 247s List of 1 247s $ m1: num NA 247s All weights are 0 247s List of 1 247s $ m1: num NA 247s First weight is 8.5 247s List of 1 247s $ m1: num NA 247s First weight is Inf 247s List of 1 247s $ m1: num NA 247s Last weight is Inf 247s List of 1 247s $ m1: num NA 247s Last weight is NA 247s List of 1 247s $ m1: num NA 247s na.rm: TRUE 247s Weights are not specified (all are 1) 247s List of 1 247s $ m1: num 1.96 247s All weights are 1 247s List of 1 247s $ m1: num 1.96 247s First weight is 5 247s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 247s List of 1 247s $ m1: num 1.75 247s All weights are 0 247s List of 1 247s $ m1: num NA 247s First weight is 8.5 247s List of 1 247s $ m1: num NA 247s First weight is Inf 247s List of 1 247s $ m1: num NA 247s Last weight is Inf 247s List of 1 247s $ m1: num NA 247s Last weight is NA 247s List of 1 247s $ m1: num NA 247s mode: double 247s num [1:15] 1.735 3.296 -3.08 0.726 2.303 ... 247s add_na: FALSE 247s num [1:15] 1.735 3.296 -3.08 0.726 2.303 ... 247s na.rm: FALSE 247s Weights are not specified (all are 1) 247s List of 1 247s $ m1: num 3.03 247s All weights are 1 247s List of 1 247s $ m1: num 3.03 247s First weight is 5 247s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 247s List of 1 247s $ m1: num 2.77 247s All weights are 0 247s List of 1 247s $ m1: num NA 247s First weight is 8.5 247s List of 1 247s $ m1: num NA 247s First weight is Inf 247s List of 1 247s $ m1: num NA 247s Last weight is Inf 247s List of 1 247s $ m1: num NA 247s Last weight is NA 247s List of 1 247s $ m1: num NA 247s na.rm: TRUE 247s Weights are not specified (all are 1) 247s List of 1 247s $ m1: num 3.03 247s All weights are 1 247s List of 1 247s $ m1: num 3.03 247s First weight is 5 247s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 247s List of 1 247s $ m1: num 2.77 247s All weights are 0 247s List of 1 247s $ m1: num NA 247s First weight is 8.5 247s List of 1 247s $ m1: num NA 247s First weight is Inf 247s List of 1 247s $ m1: num NA 247s Last weight is Inf 247s List of 1 247s $ m1: num NA 247s Last weight is NA 247s List of 1 247s $ m1: num NA 247s add_na: TRUE 247s num [1:15] 1.735 3.296 -3.08 0.726 NA ... 247s na.rm: FALSE 247s Weights are not specified (all are 1) 247s List of 1 247s $ m1: num NA 247s All weights are 1 247s List of 1 247s $ m1: num NA 247s First weight is 5 247s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 247s List of 1 247s $ m1: num NA 247s All weights are 0 247s List of 1 247s $ m1: num NA 247s First weight is 8.5 247s List of 1 247s $ m1: num NA 247s First weight is Inf 247s List of 1 247s $ m1: num NA 247s Last weight is Inf 247s List of 1 247s $ m1: num NA 247s Last weight is NA 247s List of 1 247s $ m1: num NA 247s na.rm: TRUE 247s Weights are not specified (all are 1) 247s List of 1 247s $ m1: num 3.01 247s All weights are 1 247s List of 1 247s $ m1: num 3.01 247s First weight is 5 247s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 247s List of 1 247s $ m1: num 2.78 247s All weights are 0 247s List of 1 247s $ m1: num NA 247s First weight is 8.5 247s List of 1 247s $ m1: num NA 247s First weight is Inf 247s List of 1 247s $ m1: num NA 247s Last weight is Inf 247s List of 1 247s $ m1: num NA 247s Last weight is NA 247s List of 1 247s $ m1: num NA 247s weightedSd()...DONE 247s weightedMad()... 247s mode: integer 247s int [1:15] -4 -2 4 0 2 0 -2 -3 3 0 ... 247s add_na: FALSE 247s int [1:15] -4 -2 4 0 2 0 -2 -3 3 0 ... 247s na.rm: FALSE 247s Weights are not specified (all are 1) 247s List of 1 247s $ m1: num 2.97 247s All weights are 1 247s List of 1 247s $ m1: num 2.97 247s First weight is 5 247s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 247s List of 1 247s $ m1: num 2.97 247s All weights are 0 247s List of 1 247s $ m1: int NA 247s First weight is 8.5 247s List of 1 247s $ m1: int 0 247s First weight is Inf 247s List of 1 247s $ m1: int 0 247s Last weight is Inf 247s List of 1 247s $ m1: int 0 247s Last weight is NA 247s List of 1 247s $ m1: int NA 247s na.rm: TRUE 247s Weights are not specified (all are 1) 247s List of 1 247s $ m1: num 2.97 247s All weights are 1 247s List of 1 247s $ m1: num 2.97 247s First weight is 5 247s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 247s List of 1 247s $ m1: num 2.97 247s All weights are 0 247s List of 1 247s $ m1: int NA 247s First weight is 8.5 247s List of 1 247s $ m1: int 0 247s First weight is Inf 247s List of 1 247s $ m1: int 0 247s Last weight is Inf 247s List of 1 247s $ m1: int 0 247s Last weight is NA 247s List of 1 247s $ m1: int NA 247s add_na: TRUE 247s int [1:15] -4 -2 4 0 NA 0 NA -3 3 0 ... 247s na.rm: FALSE 247s Weights are not specified (all are 1) 247s List of 1 247s $ m1: num NA 247s All weights are 1 247s List of 1 247s $ m1: int NA 247s First weight is 5 247s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 247s List of 1 247s $ m1: int NA 247s All weights are 0 247s List of 1 247s $ m1: int NA 247s First weight is 8.5 247s List of 1 247s $ m1: int 0 247s First weight is Inf 247s List of 1 247s $ m1: int 0 247s Last weight is Inf 247s List of 1 247s $ m1: int 0 247s Last weight is NA 247s List of 1 247s $ m1: int NA 247s na.rm: TRUE 247s Weights are not specified (all are 1) 247s List of 1 247s $ m1: num 2.97 247s All weights are 1 247s List of 1 247s $ m1: num 2.97 247s First weight is 5 247s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 247s List of 1 247s $ m1: num 4.45 247s All weights are 0 247s List of 1 247s $ m1: int NA 247s First weight is 8.5 247s List of 1 247s $ m1: int 0 247s First weight is Inf 247s List of 1 247s $ m1: int 0 247s Last weight is Inf 247s List of 1 247s $ m1: int 0 247s Last weight is NA 247s List of 1 247s $ m1: int NA 247s mode: double 247s num [1:15] -2.5 1.27 2.84 4.81 1.46 ... 247s add_na: FALSE 247s num [1:15] -2.5 1.27 2.84 4.81 1.46 ... 247s na.rm: FALSE 247s Weights are not specified (all are 1) 247s List of 1 247s $ m1: num 2.83 247s All weights are 1 247s List of 1 247s $ m1: num 2.83 247s First weight is 5 247s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 247s List of 1 247s $ m1: num 2.48 247s All weights are 0 247s List of 1 247s $ m1: num NA 247s First weight is 8.5 247s List of 1 247s $ m1: num 0 247s First weight is Inf 247s List of 1 247s $ m1: num 0 247s Last weight is Inf 247s List of 1 247s $ m1: num 0 247s Last weight is NA 247s List of 1 247s $ m1: num NA 247s na.rm: TRUE 247s Weights are not specified (all are 1) 247s List of 1 247s $ m1: num 2.83 247s All weights are 1 247s List of 1 247s $ m1: num 2.83 247s First weight is 5 247s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 247s List of 1 247s $ m1: num 2.48 247s All weights are 0 247s List of 1 247s $ m1: num NA 247s First weight is 8.5 247s List of 1 247s $ m1: num 0 247s First weight is Inf 247s List of 1 247s $ m1: num 0 247s Last weight is Inf 247s List of 1 247s $ m1: num 0 247s Last weight is NA 247s List of 1 247s $ m1: num NA 247s add_na: TRUE 247s num [1:15] -2.5 1.27 2.84 4.81 NA ... 247s na.rm: FALSE 247s Weights are not specified (all are 1) 247s List of 1 247s $ m1: num NA 247s All weights are 1 247s List of 1 247s $ m1: num NA 247s First weight is 5 247s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 247s List of 1 247s $ m1: num NA 247s All weights are 0 247s List of 1 247s $ m1: num NA 247s First weight is 8.5 247s List of 1 247s $ m1: num 0 247s First weight is Inf 247s List of 1 247s $ m1: num 0 247s Last weight is Inf 247s List of 1 247s $ m1: num 0 247s Last weight is NA 247s List of 1 247s $ m1: num NA 247s na.rm: TRUE 247s Weights are not specified (all are 1) 247s List of 1 247s $ m1: num 3.13 247s All weights are 1 247s List of 1 247s $ m1: num 3.13 247s First weight is 5 247s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 247s List of 1 247s $ m1: num 1.35 247s All weights are 0 247s List of 1 247s $ m1: num NA 247s First weight is 8.5 247s List of 1 247s $ m1: num 0 247s First weight is Inf 247s List of 1 247s $ m1: num 0 247s Last weight is Inf 247s List of 1 247s $ m1: num 0 247s Last weight is NA 247s List of 1 247s $ m1: num NA 247s weightedMad()...DONE 247s > 248s 248s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 248s Copyright (C) 2024 The R Foundation for Statistical Computing 248s Platform: x86_64-pc-linux-gnu 248s 248s R is free software and comes with ABSOLUTELY NO WARRANTY. 248s You are welcome to redistribute it under certain conditions. 248s Type 'license()' or 'licence()' for distribution details. 248s 248s R is a collaborative project with many contributors. 248s Type 'contributors()' for more information and 248s 'citation()' on how to cite R or R packages in publications. 248s 248s Type 'demo()' for some demos, 'help()' for on-line help, or 248s 'help.start()' for an HTML browser interface to help. 248s Type 'q()' to quit R. 248s 248s > library("matrixStats") 248s > 248s > fcns <- list( 248s + weightedVar = weightedVar, 248s + weightedSd = weightedSd, 248s + weightedMad = weightedMad 248s + ) 248s > 248s > 248s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 248s > # Subsetted tests 248s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 248s > source("utils/validateIndicesFramework.R") 248s > for (name in names(fcns)) { 248s + cat(sprintf("subsetted tests on %s()...\n", name)) 248s + fcn <- fcns[[name]] 248s + 248s + for (mode in c("numeric", "integer")) { 248s + x <- runif(6, min = -6, max = 6) 248s + w <- runif(6, min = 0, max = 6) 248s + storage.mode(x) <- mode 248s + storage.mode(w) <- mode 248s + if (mode == "numeric") w[1] <- Inf 248s + 248s + for (idxs in index_cases) { 248s + validateIndicesTestVector_w(x, w, idxs, 248s + ftest = fcn, fsure = fcn, 248s + na.rm = TRUE) 248s + validateIndicesTestVector_w(x, w, idxs, 248s + ftest = fcn, fsure = fcn, 248s + na.rm = FALSE) 248s + } 248s + } 248s + cat(sprintf("%s()...DONE\n", name)) 248s + } 248s subsetted tests on weightedVar()... 248s weightedVar()...DONE 248s subsetted tests on weightedSd()... 248s weightedSd()...DONE 248s subsetted tests on weightedMad()... 248s weightedMad()...DONE 248s > 248s 248s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 248s Copyright (C) 2024 The R Foundation for Statistical Computing 248s Platform: x86_64-pc-linux-gnu 248s 248s R is free software and comes with ABSOLUTELY NO WARRANTY. 248s You are welcome to redistribute it under certain conditions. 248s Type 'license()' or 'licence()' for distribution details. 248s 248s R is a collaborative project with many contributors. 248s Type 'contributors()' for more information and 248s 'citation()' on how to cite R or R packages in publications. 248s 248s Type 'demo()' for some demos, 'help()' for on-line help, or 248s 'help.start()' for an HTML browser interface to help. 248s Type 'q()' to quit R. 248s 248s > library("matrixStats") 248s > 248s > x_OP_y_R <- function(x, y, OP, na.rm = FALSE) { 248s + if (na.rm) { 248s + xnok <- is.na(x) 248s + ynok <- is.na(y) 248s + anok <- xnok & ynok 248s + unit <- switch(OP, 248s + "+" = 0, 248s + "-" = NA_real_, 248s + "*" = 1, 248s + "/" = NA_real_, 248s + stop("Unknown 'OP' operator: ", OP) 248s + ) 248s + x[xnok] <- unit 248s + y[ynok] <- unit 248s + } 248s + 248s + ans <- switch(OP, 248s + "+" = x + y, 248s + "-" = x - y, 248s + "*" = x * y, 248s + "/" = x / y, 248s + stop("Unknown 'OP' operator: ", OP) 248s + ) 248s + 248s + if (na.rm) { 248s + ans[anok] <- NA_real_ 248s + } 248s + 248s + ans 248s + } # x_OP_y_R() 248s > 248s > 248s > 248s > t_tx_OP_y_R <- function(x, y, OP, na.rm = FALSE) { 248s + t(x_OP_y_R(x = t(x), y = y, OP = OP, na.rm = na.rm)) 248s + } 248s > 248s > 248s > 248s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 248s > # No missing values 248s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 248s > x <- matrix(1:16, nrow = 4, ncol = 4) 248s > y <- 1:nrow(x) 248s > storage.mode(y) <- storage.mode(x) 248s > 248s > for (OP in c("+", "-", "*", "/")) { 248s + for (na.rm in c(FALSE, TRUE)) { 248s + cat(sprintf("OP = '%s', na.rm = %s\n", OP, na.rm)) 248s + 248s + a0 <- x_OP_y_R(x, y, OP, na.rm = na.rm) 248s + a1 <- x_OP_y(x, y, OP, na.rm = na.rm) 248s + str(a1) 248s + stopifnot(all.equal(a1, a0)) 248s + 248s + b0 <- t_tx_OP_y_R(x, y, OP, na.rm = na.rm) 248s + b1 <- t_tx_OP_y(x, y, OP, na.rm = na.rm) 248s + str(b1) 248s + stopifnot(all.equal(b1, b0)) 248s + } 248s + } 248s OP = '+', na.rm = FALSE 248s int [1:4, 1:4] 2 4 6 8 6 8 10 12 10 12 ... 248s int [1:4, 1:4] 2 3 4 5 7 8 9 10 12 13 ... 248s OP = '+', na.rm = TRUE 248s int [1:4, 1:4] 2 4 6 8 6 8 10 12 10 12 ... 248s int [1:4, 1:4] 2 3 4 5 7 8 9 10 12 13 ... 248s OP = '-', na.rm = FALSE 248s int [1:4, 1:4] 0 0 0 0 4 4 4 4 8 8 ... 248s int [1:4, 1:4] 0 1 2 3 3 4 5 6 6 7 ... 248s OP = '-', na.rm = TRUE 248s int [1:4, 1:4] 0 0 0 0 4 4 4 4 8 8 ... 248s int [1:4, 1:4] 0 1 2 3 3 4 5 6 6 7 ... 248s OP = '*', na.rm = FALSE 248s int [1:4, 1:4] 1 4 9 16 5 12 21 32 9 20 ... 248s int [1:4, 1:4] 1 2 3 4 10 12 14 16 27 30 ... 248s OP = '*', na.rm = TRUE 248s int [1:4, 1:4] 1 4 9 16 5 12 21 32 9 20 ... 248s int [1:4, 1:4] 1 2 3 4 10 12 14 16 27 30 ... 248s OP = '/', na.rm = FALSE 248s num [1:4, 1:4] 1 1 1 1 5 ... 248s num [1:4, 1:4] 1 2 3 4 2.5 ... 248s OP = '/', na.rm = TRUE 248s num [1:4, 1:4] 1 1 1 1 5 ... 248s num [1:4, 1:4] 1 2 3 4 2.5 ... 248s > 248s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 248s > # Missing values in x, y, or both. 248s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 248s > for (which in c("x", "y", "both")) { 248s + x <- matrix(1:16, nrow = 4, ncol = 4) 248s + y <- 1:nrow(x) 248s + storage.mode(y) <- storage.mode(x) 248s + 248s + if (which == "x") { 248s + x[3:6] <- NA_real_ 248s + } else if (which == "y") { 248s + y[c(1, 3)] <- NA_real_ 248s + } else if (which == "both") { 248s + x[3:6] <- NA_real_ 248s + y[c(1, 3)] <- NA_real_ 248s + } 248s + 248s + for (OP in c("+", "-", "*", "/")) { 248s + for (na.rm in c(FALSE, TRUE)) { 248s + cat(sprintf("OP = '%s', na.rm = %s\n", OP, na.rm)) 248s + a0 <- x_OP_y_R(x, y, OP, na.rm = na.rm) 248s + a1 <- x_OP_y(x, y, OP, na.rm = na.rm) 248s + str(a1) 248s + stopifnot(all.equal(a1, a0)) 248s + 248s + b0 <- t_tx_OP_y_R(x, y, OP, na.rm = na.rm) 248s + b1 <- t_tx_OP_y(x, y, OP, na.rm = na.rm) 248s + str(b1) 248s + stopifnot(all.equal(b1, b0)) 248s + } 248s + } 248s + } 248s OP = '+', na.rm = FALSE 248s num [1:4, 1:4] 2 4 NA NA NA NA 10 12 10 12 ... 248s num [1:4, 1:4] 2 3 NA NA NA NA 9 10 12 13 ... 248s OP = '+', na.rm = TRUE 248s num [1:4, 1:4] 2 4 3 4 1 2 10 12 10 12 ... 248s num [1:4, 1:4] 2 3 1 1 2 2 9 10 12 13 ... 248s OP = '-', na.rm = FALSE 248s num [1:4, 1:4] 0 0 NA NA NA NA 4 4 8 8 ... 248s num [1:4, 1:4] 0 1 NA NA NA NA 5 6 6 7 ... 248s OP = '-', na.rm = TRUE 248s num [1:4, 1:4] 0 0 NA NA NA NA 4 4 8 8 ... 248s num [1:4, 1:4] 0 1 NA NA NA NA 5 6 6 7 ... 248s OP = '*', na.rm = FALSE 248s num [1:4, 1:4] 1 4 NA NA NA NA 21 32 9 20 ... 248s num [1:4, 1:4] 1 2 NA NA NA NA 14 16 27 30 ... 248s OP = '*', na.rm = TRUE 248s num [1:4, 1:4] 1 4 3 4 1 2 21 32 9 20 ... 248s num [1:4, 1:4] 1 2 1 1 2 2 14 16 27 30 ... 248s OP = '/', na.rm = FALSE 248s num [1:4, 1:4] 1 1 NA NA NA ... 248s num [1:4, 1:4] 1 2 NA NA NA ... 248s OP = '/', na.rm = TRUE 248s num [1:4, 1:4] 1 1 NA NA NA ... 248s num [1:4, 1:4] 1 2 NA NA NA ... 248s OP = '+', na.rm = FALSE 248s num [1:4, 1:4] NA 4 NA 8 NA 8 NA 12 NA 12 ... 248s num [1:4, 1:4] NA NA NA NA 7 8 9 10 NA NA ... 248s OP = '+', na.rm = TRUE 248s num [1:4, 1:4] 1 4 3 8 5 8 7 12 9 12 ... 248s num [1:4, 1:4] 1 2 3 4 7 8 9 10 9 10 ... 248s OP = '-', na.rm = FALSE 248s num [1:4, 1:4] NA 0 NA 0 NA 4 NA 4 NA 8 ... 248s num [1:4, 1:4] NA NA NA NA 3 4 5 6 NA NA ... 248s OP = '-', na.rm = TRUE 248s num [1:4, 1:4] NA 0 NA 0 NA 4 NA 4 NA 8 ... 248s num [1:4, 1:4] NA NA NA NA 3 4 5 6 NA NA ... 248s OP = '*', na.rm = FALSE 248s num [1:4, 1:4] NA 4 NA 16 NA 12 NA 32 NA 20 ... 248s num [1:4, 1:4] NA NA NA NA 10 12 14 16 NA NA ... 248s OP = '*', na.rm = TRUE 248s num [1:4, 1:4] 1 4 3 16 5 12 7 32 9 20 ... 248s num [1:4, 1:4] 1 2 3 4 10 12 14 16 9 10 ... 248s OP = '/', na.rm = FALSE 248s num [1:4, 1:4] NA 1 NA 1 NA 3 NA 2 NA 5 ... 248s num [1:4, 1:4] NA NA NA NA 2.5 3 3.5 4 NA NA ... 248s OP = '/', na.rm = TRUE 248s num [1:4, 1:4] NA 1 NA 1 NA 3 NA 2 NA 5 ... 248s num [1:4, 1:4] NA NA NA NA 2.5 3 3.5 4 NA NA ... 248s OP = '+', na.rm = FALSE 248s num [1:4, 1:4] NA 4 NA NA NA NA NA 12 NA 12 ... 248s num [1:4, 1:4] NA NA NA NA NA NA 9 10 NA NA ... 248s OP = '+', na.rm = TRUE 248s num [1:4, 1:4] 1 4 NA 4 NA 2 7 12 9 12 ... 248s num [1:4, 1:4] 1 2 NA NA 2 2 9 10 9 10 ... 248s OP = '-', na.rm = FALSE 248s num [1:4, 1:4] NA 0 NA NA NA NA NA 4 NA 8 ... 248s num [1:4, 1:4] NA NA NA NA NA NA 5 6 NA NA ... 248s OP = '-', na.rm = TRUE 248s num [1:4, 1:4] NA 0 NA NA NA NA NA 4 NA 8 ... 248s num [1:4, 1:4] NA NA NA NA NA NA 5 6 NA NA ... 248s OP = '*', na.rm = FALSE 248s num [1:4, 1:4] NA 4 NA NA NA NA NA 32 NA 20 ... 248s num [1:4, 1:4] NA NA NA NA NA NA 14 16 NA NA ... 248s OP = '*', na.rm = TRUE 248s num [1:4, 1:4] 1 4 NA 4 NA 2 7 32 9 20 ... 248s num [1:4, 1:4] 1 2 NA NA 2 2 14 16 9 10 ... 248s OP = '/', na.rm = FALSE 248s num [1:4, 1:4] NA 1 NA NA NA NA NA 2 NA 5 ... 248s num [1:4, 1:4] NA NA NA NA NA NA 3.5 4 NA NA ... 248s OP = '/', na.rm = TRUE 248s num [1:4, 1:4] NA 1 NA NA NA NA NA 2 NA 5 ... 248s num [1:4, 1:4] NA NA NA NA NA NA 3.5 4 NA NA ... 248s > 248s > 248s > 248s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 248s > # Length differences 248s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 248s > x <- matrix(1:8, nrow = 2, ncol = 4) 248s > y <- 1:ncol(x) 248s > storage.mode(y) <- storage.mode(x) 248s > 248s > for (OP in c("+", "-", "*", "/")) { 248s + for (na.rm in c(FALSE, TRUE)) { 248s + cat(sprintf("OP = '%s', na.rm = %s\n", OP, na.rm)) 248s + 248s + a0 <- x_OP_y_R(x, y, OP, na.rm = na.rm) 248s + a1 <- x_OP_y(x, y, OP, na.rm = na.rm) 248s + str(a1) 248s + stopifnot(all.equal(a1, a0)) 248s + 248s + b0 <- t_tx_OP_y_R(x, y, OP, na.rm = na.rm) 248s + b1 <- t_tx_OP_y(x, y, OP, na.rm = na.rm) 248s + str(b1) 248s + stopifnot(all.equal(b1, b0)) 248s + } 248s + } 248s OP = '+', na.rm = FALSE 248s int [1:2, 1:4] 2 4 6 8 6 8 10 12 248s int [1:2, 1:4] 2 3 5 6 8 9 11 12 248s OP = '+', na.rm = TRUE 248s int [1:2, 1:4] 2 4 6 8 6 8 10 12 248s int [1:2, 1:4] 2 3 5 6 8 9 11 12 248s OP = '-', na.rm = FALSE 248s int [1:2, 1:4] 0 0 0 0 4 4 4 4 248s int [1:2, 1:4] 0 1 1 2 2 3 3 4 248s OP = '-', na.rm = TRUE 248s int [1:2, 1:4] 0 0 0 0 4 4 4 4 248s int [1:2, 1:4] 0 1 1 2 2 3 3 4 248s OP = '*', na.rm = FALSE 248s int [1:2, 1:4] 1 4 9 16 5 12 21 32 248s int [1:2, 1:4] 1 2 6 8 15 18 28 32 248s OP = '*', na.rm = TRUE 248s int [1:2, 1:4] 1 4 9 16 5 12 21 32 248s int [1:2, 1:4] 1 2 6 8 15 18 28 32 248s OP = '/', na.rm = FALSE 248s num [1:2, 1:4] 1 1 1 1 5 ... 248s num [1:2, 1:4] 1 2 1.5 2 1.67 ... 248s OP = '/', na.rm = TRUE 248s num [1:2, 1:4] 1 1 1 1 5 ... 248s num [1:2, 1:4] 1 2 1.5 2 1.67 ... 248s > 248s > 248s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 248s > # All missing values 248s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 248s > xs <- list( 248s + A = matrix(1:2, nrow = 2, ncol = 2), 248s + B = matrix(NA_integer_, nrow = 2, ncol = 2) 248s + ) 248s > ys <- list( 248s + A = 1L, 248s + B = NA_integer_ 248s + ) 248s > 248s > for (x in xs) { 248s + for (y in ys) { 248s + for (mode in c("logical", "integer", "double")) { 248s + storage.mode(x) <- mode 248s + storage.mode(y) <- mode 248s + str(list(x = x, y = y)) 248s + 248s + for (OP in c("+", "-", "*", "/")) { 248s + for (na.rm in c(FALSE, TRUE)) { 248s + cat(sprintf("mode = '%s', OP = '%s', na.rm = %s\n", mode, OP, na.rm)) 248s + suppressWarnings({ 248s + z0 <- x_OP_y_R(x, y, OP, na.rm = na.rm) 248s + z <- x_OP_y(x, y, OP, na.rm = na.rm) 248s + }) 248s + str(z) 248s + stopifnot(all.equal(z, z0)) 248s + } 248s + } 248s + } # for (mode ...) 248s + } # for (y ...) 248s + } # for (x ...) 248s List of 2 248s $ x: logi [1:2, 1:2] TRUE TRUE TRUE TRUE 248s $ y: logi TRUE 248s mode = 'logical', OP = '+', na.rm = FALSE 248s int [1:2, 1:2] 2 2 2 2 248s mode = 'logical', OP = '+', na.rm = TRUE 248s int [1:2, 1:2] 2 2 2 2 248s mode = 'logical', OP = '-', na.rm = FALSE 248s int [1:2, 1:2] 0 0 0 0 248s mode = 'logical', OP = '-', na.rm = TRUE 248s int [1:2, 1:2] 0 0 0 0 248s mode = 'logical', OP = '*', na.rm = FALSE 248s int [1:2, 1:2] 1 1 1 1 248s mode = 'logical', OP = '*', na.rm = TRUE 248s int [1:2, 1:2] 1 1 1 1 248s mode = 'logical', OP = '/', na.rm = FALSE 248s num [1:2, 1:2] 1 1 1 1 248s mode = 'logical', OP = '/', na.rm = TRUE 248s num [1:2, 1:2] 1 1 1 1 248s List of 2 248s $ x: int [1:2, 1:2] 1 1 1 1 248s $ y: int 1 248s mode = 'integer', OP = '+', na.rm = FALSE 248s int [1:2, 1:2] 2 2 2 2 248s mode = 'integer', OP = '+', na.rm = TRUE 248s int [1:2, 1:2] 2 2 2 2 248s mode = 'integer', OP = '-', na.rm = FALSE 248s int [1:2, 1:2] 0 0 0 0 248s mode = 'integer', OP = '-', na.rm = TRUE 248s int [1:2, 1:2] 0 0 0 0 248s mode = 'integer', OP = '*', na.rm = FALSE 248s int [1:2, 1:2] 1 1 1 1 248s mode = 'integer', OP = '*', na.rm = TRUE 248s int [1:2, 1:2] 1 1 1 1 248s mode = 'integer', OP = '/', na.rm = FALSE 248s num [1:2, 1:2] 1 1 1 1 248s mode = 'integer', OP = '/', na.rm = TRUE 248s num [1:2, 1:2] 1 1 1 1 248s List of 2 248s $ x: num [1:2, 1:2] 1 1 1 1 248s $ y: num 1 248s mode = 'double', OP = '+', na.rm = FALSE 248s num [1:2, 1:2] 2 2 2 2 248s mode = 'double', OP = '+', na.rm = TRUE 248s num [1:2, 1:2] 2 2 2 2 248s mode = 'double', OP = '-', na.rm = FALSE 248s num [1:2, 1:2] 0 0 0 0 248s mode = 'double', OP = '-', na.rm = TRUE 248s num [1:2, 1:2] 0 0 0 0 248s mode = 'double', OP = '*', na.rm = FALSE 248s num [1:2, 1:2] 1 1 1 1 248s mode = 'double', OP = '*', na.rm = TRUE 248s num [1:2, 1:2] 1 1 1 1 248s mode = 'double', OP = '/', na.rm = FALSE 248s num [1:2, 1:2] 1 1 1 1 248s mode = 'double', OP = '/', na.rm = TRUE 248s num [1:2, 1:2] 1 1 1 1 248s List of 2 248s $ x: logi [1:2, 1:2] TRUE TRUE TRUE TRUE 248s $ y: logi NA 248s mode = 'logical', OP = '+', na.rm = FALSE 248s int [1:2, 1:2] NA NA NA NA 248s mode = 'logical', OP = '+', na.rm = TRUE 248s int [1:2, 1:2] 1 1 1 1 248s mode = 'logical', OP = '-', na.rm = FALSE 248s int [1:2, 1:2] NA NA NA NA 248s mode = 'logical', OP = '-', na.rm = TRUE 248s int [1:2, 1:2] NA NA NA NA 248s mode = 'logical', OP = '*', na.rm = FALSE 248s int [1:2, 1:2] NA NA NA NA 248s mode = 'logical', OP = '*', na.rm = TRUE 248s int [1:2, 1:2] 1 1 1 1 248s mode = 'logical', OP = '/', na.rm = FALSE 248s num [1:2, 1:2] NA NA NA NA 248s mode = 'logical', OP = '/', na.rm = TRUE 248s num [1:2, 1:2] NA NA NA NA 248s List of 2 248s $ x: int [1:2, 1:2] 1 1 1 1 248s $ y: int NA 248s mode = 'integer', OP = '+', na.rm = FALSE 248s int [1:2, 1:2] NA NA NA NA 248s mode = 'integer', OP = '+', na.rm = TRUE 248s int [1:2, 1:2] 1 1 1 1 248s mode = 'integer', OP = '-', na.rm = FALSE 248s int [1:2, 1:2] NA NA NA NA 248s mode = 'integer', OP = '-', na.rm = TRUE 248s int [1:2, 1:2] NA NA NA NA 248s mode = 'integer', OP = '*', na.rm = FALSE 248s int [1:2, 1:2] NA NA NA NA 248s mode = 'integer', OP = '*', na.rm = TRUE 248s int [1:2, 1:2] 1 1 1 1 248s mode = 'integer', OP = '/', na.rm = FALSE 248s num [1:2, 1:2] NA NA NA NA 248s mode = 'integer', OP = '/', na.rm = TRUE 248s num [1:2, 1:2] NA NA NA NA 248s List of 2 248s $ x: num [1:2, 1:2] 1 1 1 1 248s $ y: num NA 248s mode = 'double', OP = '+', na.rm = FALSE 248s num [1:2, 1:2] NA NA NA NA 248s mode = 'double', OP = '+', na.rm = TRUE 248s num [1:2, 1:2] 1 1 1 1 248s mode = 'double', OP = '-', na.rm = FALSE 248s num [1:2, 1:2] NA NA NA NA 248s mode = 'double', OP = '-', na.rm = TRUE 248s num [1:2, 1:2] NA NA NA NA 248s mode = 'double', OP = '*', na.rm = FALSE 248s num [1:2, 1:2] NA NA NA NA 248s mode = 'double', OP = '*', na.rm = TRUE 248s num [1:2, 1:2] 1 1 1 1 248s mode = 'double', OP = '/', na.rm = FALSE 248s num [1:2, 1:2] NA NA NA NA 248s mode = 'double', OP = '/', na.rm = TRUE 248s num [1:2, 1:2] NA NA NA NA 248s List of 2 248s $ x: logi [1:2, 1:2] NA NA NA NA 248s $ y: logi TRUE 248s mode = 'logical', OP = '+', na.rm = FALSE 248s int [1:2, 1:2] NA NA NA NA 248s mode = 'logical', OP = '+', na.rm = TRUE 248s int [1:2, 1:2] 1 1 1 1 248s mode = 'logical', OP = '-', na.rm = FALSE 248s int [1:2, 1:2] NA NA NA NA 248s mode = 'logical', OP = '-', na.rm = TRUE 248s int [1:2, 1:2] NA NA NA NA 248s mode = 'logical', OP = '*', na.rm = FALSE 248s int [1:2, 1:2] NA NA NA NA 248s mode = 'logical', OP = '*', na.rm = TRUE 248s int [1:2, 1:2] 1 1 1 1 248s mode = 'logical', OP = '/', na.rm = FALSE 248s num [1:2, 1:2] NA NA NA NA 248s mode = 'logical', OP = '/', na.rm = TRUE 248s num [1:2, 1:2] NA NA NA NA 248s List of 2 248s $ x: int [1:2, 1:2] NA NA NA NA 248s $ y: int 1 248s mode = 'integer', OP = '+', na.rm = FALSE 248s int [1:2, 1:2] NA NA NA NA 248s mode = 'integer', OP = '+', na.rm = TRUE 248s int [1:2, 1:2] 1 1 1 1 248s mode = 'integer', OP = '-', na.rm = FALSE 248s int [1:2, 1:2] NA NA NA NA 248s mode = 'integer', OP = '-', na.rm = TRUE 248s int [1:2, 1:2] NA NA NA NA 248s mode = 'integer', OP = '*', na.rm = FALSE 248s int [1:2, 1:2] NA NA NA NA 248s mode = 'integer', OP = '*', na.rm = TRUE 248s int [1:2, 1:2] 1 1 1 1 248s mode = 'integer', OP = '/', na.rm = FALSE 248s num [1:2, 1:2] NA NA NA NA 248s mode = 'integer', OP = '/', na.rm = TRUE 248s num [1:2, 1:2] NA NA NA NA 248s List of 2 248s $ x: num [1:2, 1:2] NA NA NA NA 248s $ y: num 1 248s mode = 'double', OP = '+', na.rm = FALSE 248s num [1:2, 1:2] NA NA NA NA 248s mode = 'double', OP = '+', na.rm = TRUE 248s num [1:2, 1:2] 1 1 1 1 248s mode = 'double', OP = '-', na.rm = FALSE 248s num [1:2, 1:2] NA NA NA NA 248s mode = 'double', OP = '-', na.rm = TRUE 248s num [1:2, 1:2] NA NA NA NA 248s mode = 'double', OP = '*', na.rm = FALSE 248s num [1:2, 1:2] NA NA NA NA 248s mode = 'double', OP = '*', na.rm = TRUE 248s num [1:2, 1:2] 1 1 1 1 248s mode = 'double', OP = '/', na.rm = FALSE 248s num [1:2, 1:2] NA NA NA NA 248s mode = 'double', OP = '/', na.rm = TRUE 248s num [1:2, 1:2] NA NA NA NA 248s List of 2 248s $ x: logi [1:2, 1:2] NA NA NA NA 248s $ y: logi NA 248s mode = 'logical', OP = '+', na.rm = FALSE 248s int [1:2, 1:2] NA NA NA NA 248s mode = 'logical', OP = '+', na.rm = TRUE 248s int [1:2, 1:2] NA NA NA NA 248s mode = 'logical', OP = '-', na.rm = FALSE 248s int [1:2, 1:2] NA NA NA NA 248s mode = 'logical', OP = '-', na.rm = TRUE 248s int [1:2, 1:2] NA NA NA NA 248s mode = 'logical', OP = '*', na.rm = FALSE 248s int [1:2, 1:2] NA NA NA NA 248s mode = 'logical', OP = '*', na.rm = TRUE 248s int [1:2, 1:2] NA NA NA NA 248s mode = 'logical', OP = '/', na.rm = FALSE 248s num [1:2, 1:2] NA NA NA NA 248s mode = 'logical', OP = '/', na.rm = TRUE 248s num [1:2, 1:2] NA NA NA NA 248s List of 2 248s $ x: int [1:2, 1:2] NA NA NA NA 248s $ y: int NA 248s mode = 'integer', OP = '+', na.rm = FALSE 248s int [1:2, 1:2] NA NA NA NA 248s mode = 'integer', OP = '+', na.rm = TRUE 248s int [1:2, 1:2] NA NA NA NA 248s mode = 'integer', OP = '-', na.rm = FALSE 248s int [1:2, 1:2] NA NA NA NA 248s mode = 'integer', OP = '-', na.rm = TRUE 248s int [1:2, 1:2] NA NA NA NA 248s mode = 'integer', OP = '*', na.rm = FALSE 248s int [1:2, 1:2] NA NA NA NA 248s mode = 'integer', OP = '*', na.rm = TRUE 248s int [1:2, 1:2] NA NA NA NA 248s mode = 'integer', OP = '/', na.rm = FALSE 248s num [1:2, 1:2] NA NA NA NA 248s mode = 'integer', OP = '/', na.rm = TRUE 248s num [1:2, 1:2] NA NA NA NA 248s List of 2 248s $ x: num [1:2, 1:2] NA NA NA NA 248s $ y: num NA 248s mode = 'double', OP = '+', na.rm = FALSE 248s num [1:2, 1:2] NA NA NA NA 248s mode = 'double', OP = '+', na.rm = TRUE 248s num [1:2, 1:2] NA NA NA NA 248s mode = 'double', OP = '-', na.rm = FALSE 248s num [1:2, 1:2] NA NA NA NA 248s mode = 'double', OP = '-', na.rm = TRUE 248s num [1:2, 1:2] NA NA NA NA 248s mode = 'double', OP = '*', na.rm = FALSE 248s num [1:2, 1:2] NA NA NA NA 248s mode = 'double', OP = '*', na.rm = TRUE 248s num [1:2, 1:2] NA NA NA NA 248s mode = 'double', OP = '/', na.rm = FALSE 248s num [1:2, 1:2] NA NA NA NA 248s mode = 'double', OP = '/', na.rm = TRUE 248s num [1:2, 1:2] NA NA NA NA 248s > 248s 248s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 248s Copyright (C) 2024 The R Foundation for Statistical Computing 248s Platform: x86_64-pc-linux-gnu 248s 248s R is free software and comes with ABSOLUTELY NO WARRANTY. 248s You are welcome to redistribute it under certain conditions. 248s Type 'license()' or 'licence()' for distribution details. 248s 248s R is a collaborative project with many contributors. 248s Type 'contributors()' for more information and 248s 'citation()' on how to cite R or R packages in publications. 248s 248s Type 'demo()' for some demos, 'help()' for on-line help, or 248s 'help.start()' for an HTML browser interface to help. 248s Type 'q()' to quit R. 248s 248s > library("matrixStats") 248s > 248s > x_OP_y_R <- function(x, y, OP, na.rm = FALSE) { 248s + if (na.rm) { 248s + xnok <- is.na(x) 248s + ynok <- is.na(y) 248s + anok <- xnok & ynok 248s + unit <- switch(OP, 248s + "+" = 0, 248s + "-" = NA_real_, 248s + "*" = 1, 248s + "/" = NA_real_, 248s + stop("Unknown 'OP' operator: ", OP) 248s + ) 248s + x[xnok] <- unit 248s + y[ynok] <- unit 248s + } 248s + 248s + ans <- switch(OP, 248s + "+" = x + y, 248s + "-" = x - y, 248s + "*" = x * y, 248s + "/" = x / y, 248s + stop("Unknown 'OP' operator: ", OP) 248s + ) 248s + 248s + if (na.rm) { 248s + ans[anok] <- NA_real_ 248s + } 248s + 248s + ans 248s + } # x_OP_y_R() 248s > 248s > 248s > t_tx_OP_y_R <- function(x, y, OP, na.rm = FALSE) { 248s + t(x_OP_y_R(x = t(x), y = y, OP = OP, na.rm = na.rm)) 248s + } 248s > 248s > 248s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 248s > # Subsetted tests 248s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 248s > source("utils/validateIndicesFramework.R") 248s > for (OP in c("+", "-", "*", "/")) { 248s + for (mode in c("numeric", "integer", "logical")) { 248s + x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6L, ncol = 6L) 248s + y <- runif(6, min = 0, max = 6) 248s + storage.mode(x) <- mode 248s + storage.mode(y) <- mode 248s + if (mode == "numeric") y[1] <- Inf 248s + 248s + for (xrows in index_cases) { 248s + for (xcols in index_cases) { 248s + if (is.null(xrows)) xrows <- seq_len(nrow(x)) 248s + if (is.null(xcols)) xcols <- seq_len(ncol(x)) 248s + 248s + for (yidxs in list(xrows, xcols)) { 248s + for (na.rm in c(TRUE, FALSE)) { 248s + 248s + suppressWarnings({ 248s + actual <- tryCatch( 248s + x_OP_y(x, y, OP, xrows = xrows, xcols = xcols, yidxs = yidxs, 248s + na.rm = na.rm), 248s + error = function(c) "error" 248s + ) 248s + 248s + expect <- tryCatch( 248s + x_OP_y_R(x[xrows, xcols, drop = FALSE], y[yidxs], OP, 248s + na.rm = na.rm), 248s + error = function(c) "error" 248s + ) 248s + }) 248s + stopifnot(all.equal(as.vector(actual), as.vector(expect))) 248s + 248s + suppressWarnings({ 248s + actual <- tryCatch( 248s + t_tx_OP_y(x, y, OP, xrows = xrows, xcols = xcols, yidxs = yidxs, 248s + na.rm = na.rm), 248s + error = function(c) "error" 248s + ) 248s + 248s + expect <- tryCatch( 248s + t_tx_OP_y_R(x[xrows, xcols, drop = FALSE], y[yidxs], OP, 248s + na.rm = na.rm), 248s + error = function(c) "error" 248s + ) 248s + }) 248s + stopifnot(all.equal(as.vector(actual), as.vector(expect))) 248s + } 248s + } 248s + } 248s + } 248s + } 248s + } 251s > 251s 251s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 251s Copyright (C) 2024 The R Foundation for Statistical Computing 251s Platform: x86_64-pc-linux-gnu 251s 251s R is free software and comes with ABSOLUTELY NO WARRANTY. 251s You are welcome to redistribute it under certain conditions. 251s Type 'license()' or 'licence()' for distribution details. 251s 251s R is a collaborative project with many contributors. 251s Type 'contributors()' for more information and 251s 'citation()' on how to cite R or R packages in publications. 251s 251s Type 'demo()' for some demos, 'help()' for on-line help, or 251s 'help.start()' for an HTML browser interface to help. 251s Type 'q()' to quit R. 251s 251s > ## These tests need to be last of all tests, otherwise 251s > ## covr::package_coverage() gives an error. 251s > cat("1. Loading package\n") 251s 1. Loading package 251s > loadNamespace("matrixStats") 251s 251s > stopifnot("matrixStats" %in% loadedNamespaces()) 251s > 251s > cat("2. Unloading package\n") 251s 2. Unloading package 251s > unloadNamespace("matrixStats") 251s > stopifnot(!"matrixStats" %in% loadedNamespaces()) 251s > 251s > if (FALSE) { 251s + ## 'covr' gives "Error in library("matrixStats") : 251s + ## there is no package called 'matrixStats'" here, cf. 251s + ## https://travis-ci.org/HenrikBengtsson/matrixStats/builds/48015577 251s + 251s + cat("3. Attaching package\n") 251s + library("matrixStats") 251s + stopifnot("package:matrixStats" %in% search()) 251s + 251s + cat("4. Detaching package\n") 251s + detach("package:matrixStats") 251s + stopifnot(!"package:matrixStats" %in% search()) 251s + stopifnot("matrixStats" %in% loadedNamespaces()) 251s + 251s + cat("5. Unloading package\n") 251s + unloadNamespace("matrixStats") 251s + stopifnot(!"matrixStats" %in% loadedNamespaces()) 251s + 251s + cat("6. Attaching package (again)\n") 251s + library("matrixStats") 251s + stopifnot("package:matrixStats" %in% search()) 251s + 251s + cat("7. Detaching package (again)\n") 251s + detach("package:matrixStats") 251s + stopifnot(!"package:matrixStats" %in% search()) 251s + stopifnot("matrixStats" %in% loadedNamespaces()) 251s + } 251s > 251s > cat("7. DONE\n") 251s 7. DONE 251s > 252s autopkgtest [09:44:02]: test run-unit-test: -----------------------] 252s autopkgtest [09:44:02]: test run-unit-test: - - - - - - - - - - results - - - - - - - - - - 252s run-unit-test PASS 252s autopkgtest [09:44:02]: test pkg-r-autopkgtest: preparing testbed 345s autopkgtest [09:45:35]: testbed dpkg architecture: amd64 345s autopkgtest [09:45:35]: testbed apt version: 2.9.3 345s autopkgtest [09:45:35]: @@@@@@@@@@@@@@@@@@@@ test bed setup 345s Get:1 http://ftpmaster.internal/ubuntu oracular-proposed InRelease [73.9 kB] 346s Get:2 http://ftpmaster.internal/ubuntu oracular-proposed/restricted Sources [1964 B] 346s Get:3 http://ftpmaster.internal/ubuntu oracular-proposed/universe Sources [507 kB] 346s Get:4 http://ftpmaster.internal/ubuntu oracular-proposed/multiverse Sources [3388 B] 346s Get:5 http://ftpmaster.internal/ubuntu oracular-proposed/main Sources [57.4 kB] 346s Get:6 http://ftpmaster.internal/ubuntu oracular-proposed/main amd64 Packages [175 kB] 346s Get:7 http://ftpmaster.internal/ubuntu oracular-proposed/main i386 Packages [136 kB] 346s Get:8 http://ftpmaster.internal/ubuntu oracular-proposed/restricted amd64 Packages [7700 B] 346s Get:9 http://ftpmaster.internal/ubuntu oracular-proposed/universe i386 Packages [192 kB] 346s Get:10 http://ftpmaster.internal/ubuntu oracular-proposed/universe amd64 Packages [519 kB] 346s Get:11 http://ftpmaster.internal/ubuntu oracular-proposed/multiverse i386 Packages [1392 B] 346s Get:12 http://ftpmaster.internal/ubuntu oracular-proposed/multiverse amd64 Packages [2536 B] 346s Fetched 1677 kB in 0s (5633 kB/s) 346s Reading package lists... 348s Reading package lists... 348s Building dependency tree... 348s Reading state information... 348s Calculating upgrade... 349s The following packages will be upgraded: 349s libclang-cpp18 libclang1-18 libllvm18 349s 3 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 349s Need to get 48.8 MB of archives. 349s After this operation, 726 kB of additional disk space will be used. 349s Get:1 http://ftpmaster.internal/ubuntu oracular/main amd64 libclang-cpp18 amd64 1:18.1.6-1 [13.5 MB] 349s Get:2 http://ftpmaster.internal/ubuntu oracular/main amd64 libllvm18 amd64 1:18.1.6-1 [27.5 MB] 349s Get:3 http://ftpmaster.internal/ubuntu oracular/main amd64 libclang1-18 amd64 1:18.1.6-1 [7804 kB] 349s Fetched 48.8 MB in 0s (121 MB/s) 350s (Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 74358 files and directories currently installed.) 350s Preparing to unpack .../libclang-cpp18_1%3a18.1.6-1_amd64.deb ... 350s Unpacking libclang-cpp18 (1:18.1.6-1) over (1:18.1.3-1) ... 350s Preparing to unpack .../libllvm18_1%3a18.1.6-1_amd64.deb ... 350s Unpacking libllvm18:amd64 (1:18.1.6-1) over (1:18.1.3-1) ... 351s Preparing to unpack .../libclang1-18_1%3a18.1.6-1_amd64.deb ... 351s Unpacking libclang1-18 (1:18.1.6-1) over (1:18.1.3-1) ... 351s Setting up libllvm18:amd64 (1:18.1.6-1) ... 351s Setting up libclang1-18 (1:18.1.6-1) ... 351s Setting up libclang-cpp18 (1:18.1.6-1) ... 351s Processing triggers for libc-bin (2.39-0ubuntu8.1) ... 351s Reading package lists... 351s Building dependency tree... 351s Reading state information... 352s 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 352s Hit:1 http://ftpmaster.internal/ubuntu oracular-proposed InRelease 352s Hit:2 http://ftpmaster.internal/ubuntu oracular InRelease 352s Hit:3 http://ftpmaster.internal/ubuntu oracular-updates InRelease 352s Hit:4 http://ftpmaster.internal/ubuntu oracular-security InRelease 353s Reading package lists... 353s Reading package lists... 353s Building dependency tree... 353s Reading state information... 354s Calculating upgrade... 354s 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 354s Reading package lists... 354s Building dependency tree... 354s Reading state information... 354s 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 356s Reading package lists... 356s Building dependency tree... 356s Reading state information... 356s Starting pkgProblemResolver with broken count: 0 356s Starting 2 pkgProblemResolver with broken count: 0 356s Done 357s The following additional packages will be installed: 357s build-essential cpp cpp-13 cpp-13-x86-64-linux-gnu cpp-x86-64-linux-gnu 357s dctrl-tools fontconfig fonts-glyphicons-halflings fonts-mathjax g++ g++-13 357s g++-13-x86-64-linux-gnu g++-x86-64-linux-gnu gcc gcc-13 gcc-13-base 357s gcc-13-x86-64-linux-gnu gcc-x86-64-linux-gnu gfortran gfortran-13 357s gfortran-13-x86-64-linux-gnu gfortran-x86-64-linux-gnu icu-devtools libasan8 357s libatomic1 libblas-dev libblas3 libbz2-dev libcairo2 libcc1-0 libdatrie1 357s libdeflate-dev libgcc-13-dev libgfortran-13-dev libgfortran5 libgomp1 357s libgraphite2-3 libharfbuzz0b libhwasan0 libice6 libicu-dev libisl23 libitm1 357s libjpeg-dev libjpeg-turbo8-dev libjpeg8-dev libjs-bootstrap 357s libjs-highlight.js libjs-jquery libjs-jquery-datatables libjs-mathjax 357s liblapack-dev liblapack3 liblsan0 liblzma-dev libmpc3 libncurses-dev 357s libpango-1.0-0 libpangocairo-1.0-0 libpangoft2-1.0-0 libpaper-utils 357s libpaper1 libpcre2-16-0 libpcre2-32-0 libpcre2-dev libpcre2-posix3 357s libpixman-1-0 libpkgconf3 libpng-dev libquadmath0 libreadline-dev libsm6 357s libstdc++-13-dev libtcl8.6 libthai-data libthai0 libtirpc-dev libtk8.6 357s libtsan2 libubsan1 libxcb-render0 libxcb-shm0 libxft2 libxrender1 libxss1 357s libxt6t64 node-normalize.css pkg-r-autopkgtest pkgconf pkgconf-bin 357s r-base-core r-base-dev r-cran-base64enc r-cran-cli r-cran-colorspace 357s r-cran-commonmark r-cran-evaluate r-cran-fansi r-cran-farver r-cran-ggplot2 357s r-cran-glue r-cran-gtable r-cran-highr r-cran-isoband r-cran-knitr 357s r-cran-labeling r-cran-lattice r-cran-lifecycle r-cran-magrittr 357s r-cran-markdown r-cran-mass r-cran-matrix r-cran-matrixstats r-cran-mgcv 357s r-cran-munsell r-cran-nlme r-cran-pillar r-cran-pkgconfig r-cran-r6 357s r-cran-rcolorbrewer r-cran-rlang r-cran-scales r-cran-tibble r-cran-utf8 357s r-cran-vctrs r-cran-viridislite r-cran-withr r-cran-xfun r-cran-yaml unzip 357s x11-common xdg-utils zip zlib1g-dev 357s Suggested packages: 357s cpp-doc gcc-13-locales cpp-13-doc debtags g++-multilib g++-13-multilib 357s gcc-13-doc gcc-multilib manpages-dev autoconf automake libtool flex bison 357s gdb gcc-doc gcc-13-multilib gdb-x86-64-linux-gnu gfortran-multilib 357s gfortran-doc gfortran-13-multilib gfortran-13-doc libcoarrays-dev 357s liblapack-doc icu-doc fonts-mathjax-extras fonts-stix libjs-mathjax-doc 357s liblzma-doc ncurses-doc readline-doc libstdc++-13-doc tcl8.6 tk8.6 357s libjs-html5shiv elpa-ess r-doc-info | r-doc-pdf r-mathlib r-base-html 357s texlive-base texlive-latex-base texlive-plain-generic 357s texlive-fonts-recommended texlive-fonts-extra texlive-extra-utils 357s texlive-latex-recommended texlive-latex-extra texinfo r-cran-kernsmooth 357s r-cran-kernlab r-cran-mvtnorm r-cran-vcd r-cran-shiny r-cran-shinyjs 357s r-cran-dplyr r-cran-png r-cran-jpeg r-cran-rmarkdown r-cran-viridis 357s r-cran-covr r-cran-magick r-cran-sf r-cran-bit64 r-cran-dbi 357s r-cran-formattable r-cran-nanotime r-cran-palmerpenguins r-cran-stringi 357s r-cran-survival r-cran-units r-cran-vdiffr r-cran-testthat r-cran-bench 357s r-cran-blob r-cran-brio r-cran-callr r-cran-crayon r-cran-here r-cran-hms 357s r-cran-htmltools r-cran-pkgbuild r-cran-pkgload r-cran-purrr r-cran-tidyr 357s Recommended packages: 357s bzip2-doc javascript-common libpng-tools r-recommended r-doc-html 357s r-cran-callr r-cran-covr r-cran-crayon r-cran-digest r-cran-htmltools 357s r-cran-htmlwidgets r-cran-mockery r-cran-processx r-cran-ps r-cran-rmarkdown 357s r-cran-rprojroot r-cran-rstudioapi r-cran-testthat r-cran-whoami r-cran-curl 357s r-cran-xml2 r-cran-unitizer r-cran-dplyr r-cran-hexbin r-cran-hmisc 357s r-cran-mapproj r-cran-maps r-cran-multcomp r-cran-profvis r-cran-quantreg 357s r-cran-ragg r-cran-rpart r-cran-sf r-cran-svglite r-cran-vdiffr r-cran-dbi 357s r-cran-rsqlite r-cran-waldo r-cran-testit r-cran-bslib r-cran-codetools 357s r-cran-formatr r-cran-gridsvg r-cran-jpeg r-cran-magick r-cran-png 357s r-cran-reticulate r-cran-rgl r-cran-sass r-cran-tikzdevice r-cran-tinytex 357s r-cran-webshot node-highlight.js r-cran-lintr r-cran-tidyverse r-cran-rcurl 357s r-cran-r.devices r-cran-r.rsp r-cran-lubridate r-cran-fs r-cran-usethis 357s r-cran-bit64 r-cran-dichromat r-cran-hms r-cran-stringi r-cran-data.table 357s r-cran-mockr r-cran-formattable r-cran-generics r-cran-pkgdown 357s r-cran-zeallot r-cran-mime r-cran-remotes r-cran-renv r-cran-jsonlite 357s r-cran-runit libfile-mimeinfo-perl libnet-dbus-perl libx11-protocol-perl 357s x11-utils x11-xserver-utils 357s The following NEW packages will be installed: 357s autopkgtest-satdep build-essential cpp cpp-13 cpp-13-x86-64-linux-gnu 357s cpp-x86-64-linux-gnu dctrl-tools fontconfig fonts-glyphicons-halflings 357s fonts-mathjax g++ g++-13 g++-13-x86-64-linux-gnu g++-x86-64-linux-gnu gcc 357s gcc-13 gcc-13-base gcc-13-x86-64-linux-gnu gcc-x86-64-linux-gnu gfortran 357s gfortran-13 gfortran-13-x86-64-linux-gnu gfortran-x86-64-linux-gnu 357s icu-devtools libasan8 libatomic1 libblas-dev libblas3 libbz2-dev libcairo2 357s libcc1-0 libdatrie1 libdeflate-dev libgcc-13-dev libgfortran-13-dev 357s libgfortran5 libgomp1 libgraphite2-3 libharfbuzz0b libhwasan0 libice6 357s libicu-dev libisl23 libitm1 libjpeg-dev libjpeg-turbo8-dev libjpeg8-dev 357s libjs-bootstrap libjs-highlight.js libjs-jquery libjs-jquery-datatables 357s libjs-mathjax liblapack-dev liblapack3 liblsan0 liblzma-dev libmpc3 357s libncurses-dev libpango-1.0-0 libpangocairo-1.0-0 libpangoft2-1.0-0 357s libpaper-utils libpaper1 libpcre2-16-0 libpcre2-32-0 libpcre2-dev 357s libpcre2-posix3 libpixman-1-0 libpkgconf3 libpng-dev libquadmath0 357s libreadline-dev libsm6 libstdc++-13-dev libtcl8.6 libthai-data libthai0 357s libtirpc-dev libtk8.6 libtsan2 libubsan1 libxcb-render0 libxcb-shm0 libxft2 357s libxrender1 libxss1 libxt6t64 node-normalize.css pkg-r-autopkgtest pkgconf 357s pkgconf-bin r-base-core r-base-dev r-cran-base64enc r-cran-cli 357s r-cran-colorspace r-cran-commonmark r-cran-evaluate r-cran-fansi 357s r-cran-farver r-cran-ggplot2 r-cran-glue r-cran-gtable r-cran-highr 357s r-cran-isoband r-cran-knitr r-cran-labeling r-cran-lattice r-cran-lifecycle 357s r-cran-magrittr r-cran-markdown r-cran-mass r-cran-matrix r-cran-matrixstats 357s r-cran-mgcv r-cran-munsell r-cran-nlme r-cran-pillar r-cran-pkgconfig 357s r-cran-r6 r-cran-rcolorbrewer r-cran-rlang r-cran-scales r-cran-tibble 357s r-cran-utf8 r-cran-vctrs r-cran-viridislite r-cran-withr r-cran-xfun 357s r-cran-yaml unzip x11-common xdg-utils zip zlib1g-dev 357s 0 upgraded, 135 newly installed, 0 to remove and 0 not upgraded. 357s Need to get 174 MB/174 MB of archives. 357s After this operation, 530 MB of additional disk space will be used. 357s Get:1 /tmp/autopkgtest.eTRLIq/2-autopkgtest-satdep.deb autopkgtest-satdep amd64 0 [756 B] 357s Get:2 http://ftpmaster.internal/ubuntu oracular/main amd64 gcc-13-base amd64 13.2.0-23ubuntu4 [49.0 kB] 357s Get:3 http://ftpmaster.internal/ubuntu oracular/main amd64 libisl23 amd64 0.26-3build1 [680 kB] 357s Get:4 http://ftpmaster.internal/ubuntu oracular/main amd64 libmpc3 amd64 1.3.1-1build1 [54.5 kB] 357s Get:5 http://ftpmaster.internal/ubuntu oracular/main amd64 cpp-13-x86-64-linux-gnu amd64 13.2.0-23ubuntu4 [11.2 MB] 357s Get:6 http://ftpmaster.internal/ubuntu oracular/main amd64 cpp-13 amd64 13.2.0-23ubuntu4 [1032 B] 357s Get:7 http://ftpmaster.internal/ubuntu oracular/main amd64 cpp-x86-64-linux-gnu amd64 4:13.2.0-7ubuntu1 [5326 B] 357s Get:8 http://ftpmaster.internal/ubuntu oracular/main amd64 cpp amd64 4:13.2.0-7ubuntu1 [22.4 kB] 357s Get:9 http://ftpmaster.internal/ubuntu oracular/main amd64 libcc1-0 amd64 14.1.0-1ubuntu1 [48.0 kB] 357s Get:10 http://ftpmaster.internal/ubuntu oracular/main amd64 libgomp1 amd64 14.1.0-1ubuntu1 [148 kB] 357s Get:11 http://ftpmaster.internal/ubuntu oracular/main amd64 libitm1 amd64 14.1.0-1ubuntu1 [29.1 kB] 357s Get:12 http://ftpmaster.internal/ubuntu oracular/main amd64 libatomic1 amd64 14.1.0-1ubuntu1 [10.4 kB] 357s Get:13 http://ftpmaster.internal/ubuntu oracular/main amd64 libasan8 amd64 14.1.0-1ubuntu1 [3025 kB] 357s Get:14 http://ftpmaster.internal/ubuntu oracular/main amd64 liblsan0 amd64 14.1.0-1ubuntu1 [1313 kB] 357s Get:15 http://ftpmaster.internal/ubuntu oracular/main amd64 libtsan2 amd64 14.1.0-1ubuntu1 [2736 kB] 357s Get:16 http://ftpmaster.internal/ubuntu oracular/main amd64 libubsan1 amd64 14.1.0-1ubuntu1 [1174 kB] 357s Get:17 http://ftpmaster.internal/ubuntu oracular/main amd64 libhwasan0 amd64 14.1.0-1ubuntu1 [1632 kB] 357s Get:18 http://ftpmaster.internal/ubuntu oracular/main amd64 libquadmath0 amd64 14.1.0-1ubuntu1 [153 kB] 357s Get:19 http://ftpmaster.internal/ubuntu oracular/main amd64 libgcc-13-dev amd64 13.2.0-23ubuntu4 [2688 kB] 357s Get:20 http://ftpmaster.internal/ubuntu oracular/main amd64 gcc-13-x86-64-linux-gnu amd64 13.2.0-23ubuntu4 [21.9 MB] 357s Get:21 http://ftpmaster.internal/ubuntu oracular/main amd64 gcc-13 amd64 13.2.0-23ubuntu4 [482 kB] 357s Get:22 http://ftpmaster.internal/ubuntu oracular/main amd64 gcc-x86-64-linux-gnu amd64 4:13.2.0-7ubuntu1 [1212 B] 357s Get:23 http://ftpmaster.internal/ubuntu oracular/main amd64 gcc amd64 4:13.2.0-7ubuntu1 [5018 B] 357s Get:24 http://ftpmaster.internal/ubuntu oracular/main amd64 libstdc++-13-dev amd64 13.2.0-23ubuntu4 [2399 kB] 357s Get:25 http://ftpmaster.internal/ubuntu oracular/main amd64 g++-13-x86-64-linux-gnu amd64 13.2.0-23ubuntu4 [12.5 MB] 357s Get:26 http://ftpmaster.internal/ubuntu oracular/main amd64 g++-13 amd64 13.2.0-23ubuntu4 [14.5 kB] 357s Get:27 http://ftpmaster.internal/ubuntu oracular/main amd64 g++-x86-64-linux-gnu amd64 4:13.2.0-7ubuntu1 [964 B] 357s Get:28 http://ftpmaster.internal/ubuntu oracular/main amd64 g++ amd64 4:13.2.0-7ubuntu1 [1100 B] 357s Get:29 http://ftpmaster.internal/ubuntu oracular/main amd64 build-essential amd64 12.10ubuntu1 [4928 B] 357s Get:30 http://ftpmaster.internal/ubuntu oracular/main amd64 dctrl-tools amd64 2.24-3build3 [106 kB] 357s Get:31 http://ftpmaster.internal/ubuntu oracular/main amd64 fontconfig amd64 2.15.0-1.1ubuntu2 [180 kB] 357s Get:32 http://ftpmaster.internal/ubuntu oracular/universe amd64 fonts-glyphicons-halflings all 1.009~3.4.1+dfsg-3 [118 kB] 357s Get:33 http://ftpmaster.internal/ubuntu oracular/main amd64 fonts-mathjax all 2.7.9+dfsg-1 [2208 kB] 357s Get:34 http://ftpmaster.internal/ubuntu oracular/main amd64 libgfortran5 amd64 14.1.0-1ubuntu1 [928 kB] 357s Get:35 http://ftpmaster.internal/ubuntu oracular/main amd64 libgfortran-13-dev amd64 13.2.0-23ubuntu4 [942 kB] 357s Get:36 http://ftpmaster.internal/ubuntu oracular/main amd64 gfortran-13-x86-64-linux-gnu amd64 13.2.0-23ubuntu4 [11.6 MB] 357s Get:37 http://ftpmaster.internal/ubuntu oracular/main amd64 gfortran-13 amd64 13.2.0-23ubuntu4 [11.7 kB] 357s Get:38 http://ftpmaster.internal/ubuntu oracular/main amd64 gfortran-x86-64-linux-gnu amd64 4:13.2.0-7ubuntu1 [1024 B] 357s Get:39 http://ftpmaster.internal/ubuntu oracular/main amd64 gfortran amd64 4:13.2.0-7ubuntu1 [1176 B] 357s Get:40 http://ftpmaster.internal/ubuntu oracular/main amd64 icu-devtools amd64 74.2-1ubuntu3 [212 kB] 357s Get:41 http://ftpmaster.internal/ubuntu oracular/main amd64 libblas3 amd64 3.12.0-3build1 [238 kB] 357s Get:42 http://ftpmaster.internal/ubuntu oracular/main amd64 libblas-dev amd64 3.12.0-3build1 [170 kB] 357s Get:43 http://ftpmaster.internal/ubuntu oracular/main amd64 libbz2-dev amd64 1.0.8-5.1 [33.6 kB] 357s Get:44 http://ftpmaster.internal/ubuntu oracular/main amd64 libpixman-1-0 amd64 0.42.2-1build1 [279 kB] 357s Get:45 http://ftpmaster.internal/ubuntu oracular/main amd64 libxcb-render0 amd64 1.17.0-2 [16.2 kB] 357s Get:46 http://ftpmaster.internal/ubuntu oracular/main amd64 libxcb-shm0 amd64 1.17.0-2 [5758 B] 357s Get:47 http://ftpmaster.internal/ubuntu oracular/main amd64 libxrender1 amd64 1:0.9.10-1.1build1 [19.0 kB] 357s Get:48 http://ftpmaster.internal/ubuntu oracular/main amd64 libcairo2 amd64 1.18.0-3build1 [566 kB] 357s Get:49 http://ftpmaster.internal/ubuntu oracular/main amd64 libdatrie1 amd64 0.2.13-3build1 [19.0 kB] 357s Get:50 http://ftpmaster.internal/ubuntu oracular/main amd64 libdeflate-dev amd64 1.20-1 [55.8 kB] 357s Get:51 http://ftpmaster.internal/ubuntu oracular/main amd64 libgraphite2-3 amd64 1.3.14-2build1 [73.0 kB] 357s Get:52 http://ftpmaster.internal/ubuntu oracular/main amd64 libharfbuzz0b amd64 8.3.0-2build2 [469 kB] 357s Get:53 http://ftpmaster.internal/ubuntu oracular/main amd64 x11-common all 1:7.7+23ubuntu3 [21.7 kB] 357s Get:54 http://ftpmaster.internal/ubuntu oracular/main amd64 libice6 amd64 2:1.0.10-1build3 [41.4 kB] 357s Get:55 http://ftpmaster.internal/ubuntu oracular/main amd64 libicu-dev amd64 74.2-1ubuntu3 [11.9 MB] 358s Get:56 http://ftpmaster.internal/ubuntu oracular/main amd64 libjpeg-turbo8-dev amd64 2.1.5-2ubuntu2 [295 kB] 358s Get:57 http://ftpmaster.internal/ubuntu oracular/main amd64 libjpeg8-dev amd64 8c-2ubuntu11 [1484 B] 358s Get:58 http://ftpmaster.internal/ubuntu oracular/main amd64 libjpeg-dev amd64 8c-2ubuntu11 [1482 B] 358s Get:59 http://ftpmaster.internal/ubuntu oracular/universe amd64 libjs-bootstrap all 3.4.1+dfsg-3 [129 kB] 358s Get:60 http://ftpmaster.internal/ubuntu oracular/universe amd64 libjs-highlight.js all 9.18.5+dfsg1-2 [385 kB] 358s Get:61 http://ftpmaster.internal/ubuntu oracular/main amd64 libjs-jquery all 3.6.1+dfsg+~3.5.14-1 [328 kB] 358s Get:62 http://ftpmaster.internal/ubuntu oracular/universe amd64 libjs-jquery-datatables all 1.11.5+dfsg-2 [146 kB] 358s Get:63 http://ftpmaster.internal/ubuntu oracular/main amd64 liblapack3 amd64 3.12.0-3build1 [2650 kB] 358s Get:64 http://ftpmaster.internal/ubuntu oracular/main amd64 liblapack-dev amd64 3.12.0-3build1 [5196 kB] 358s Get:65 http://ftpmaster.internal/ubuntu oracular/main amd64 libncurses-dev amd64 6.4+20240113-1ubuntu2 [384 kB] 358s Get:66 http://ftpmaster.internal/ubuntu oracular/main amd64 libthai-data all 0.1.29-2build1 [158 kB] 358s Get:67 http://ftpmaster.internal/ubuntu oracular/main amd64 libthai0 amd64 0.1.29-2build1 [18.9 kB] 358s Get:68 http://ftpmaster.internal/ubuntu oracular/main amd64 libpango-1.0-0 amd64 1.52.2+ds-1 [233 kB] 358s Get:69 http://ftpmaster.internal/ubuntu oracular/main amd64 libpangoft2-1.0-0 amd64 1.52.2+ds-1 [42.6 kB] 358s Get:70 http://ftpmaster.internal/ubuntu oracular/main amd64 libpangocairo-1.0-0 amd64 1.52.2+ds-1 [28.7 kB] 358s Get:71 http://ftpmaster.internal/ubuntu oracular/main amd64 libpaper1 amd64 1.1.29build1 [13.4 kB] 358s Get:72 http://ftpmaster.internal/ubuntu oracular/main amd64 libpaper-utils amd64 1.1.29build1 [8650 B] 358s Get:73 http://ftpmaster.internal/ubuntu oracular/main amd64 libpcre2-16-0 amd64 10.42-4ubuntu2 [210 kB] 358s Get:74 http://ftpmaster.internal/ubuntu oracular/main amd64 libpcre2-32-0 amd64 10.42-4ubuntu2 [197 kB] 358s Get:75 http://ftpmaster.internal/ubuntu oracular/main amd64 libpcre2-posix3 amd64 10.42-4ubuntu2 [6686 B] 358s Get:76 http://ftpmaster.internal/ubuntu oracular/main amd64 libpcre2-dev amd64 10.42-4ubuntu2 [737 kB] 358s Get:77 http://ftpmaster.internal/ubuntu oracular/main amd64 libpkgconf3 amd64 1.8.1-2build1 [30.7 kB] 358s Get:78 http://ftpmaster.internal/ubuntu oracular/main amd64 zlib1g-dev amd64 1:1.3.dfsg-3.1ubuntu2 [894 kB] 358s Get:79 http://ftpmaster.internal/ubuntu oracular/main amd64 libpng-dev amd64 1.6.43-5build1 [264 kB] 358s Get:80 http://ftpmaster.internal/ubuntu oracular/main amd64 libreadline-dev amd64 8.2-4build1 [167 kB] 358s Get:81 http://ftpmaster.internal/ubuntu oracular/main amd64 libsm6 amd64 2:1.2.3-1build3 [15.7 kB] 358s Get:82 http://ftpmaster.internal/ubuntu oracular/main amd64 libtcl8.6 amd64 8.6.14+dfsg-1build1 [988 kB] 358s Get:83 http://ftpmaster.internal/ubuntu oracular/main amd64 libxft2 amd64 2.3.6-1build1 [45.3 kB] 358s Get:84 http://ftpmaster.internal/ubuntu oracular/main amd64 libxss1 amd64 1:1.2.3-1build3 [7204 B] 358s Get:85 http://ftpmaster.internal/ubuntu oracular/main amd64 libtk8.6 amd64 8.6.14-1build1 [779 kB] 358s Get:86 http://ftpmaster.internal/ubuntu oracular/main amd64 libxt6t64 amd64 1:1.2.1-1.2build1 [171 kB] 358s Get:87 http://ftpmaster.internal/ubuntu oracular/universe amd64 node-normalize.css all 8.0.1-5 [10.8 kB] 358s Get:88 http://ftpmaster.internal/ubuntu oracular/main amd64 zip amd64 3.0-13build1 [175 kB] 358s Get:89 http://ftpmaster.internal/ubuntu oracular/main amd64 unzip amd64 6.0-28ubuntu4 [175 kB] 358s Get:90 http://ftpmaster.internal/ubuntu oracular/main amd64 xdg-utils all 1.1.3-4.1ubuntu3 [62.0 kB] 358s Get:91 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-base-core amd64 4.4.0-2 [28.5 MB] 358s Get:92 http://ftpmaster.internal/ubuntu oracular/main amd64 liblzma-dev amd64 5.6.1+really5.4.5-1 [176 kB] 358s Get:93 http://ftpmaster.internal/ubuntu oracular/main amd64 pkgconf-bin amd64 1.8.1-2build1 [20.7 kB] 358s Get:94 http://ftpmaster.internal/ubuntu oracular/main amd64 pkgconf amd64 1.8.1-2build1 [16.8 kB] 358s Get:95 http://ftpmaster.internal/ubuntu oracular/main amd64 libtirpc-dev amd64 1.3.4+ds-1.3 [193 kB] 358s Get:96 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-base-dev all 4.4.0-2 [4340 B] 358s Get:97 http://ftpmaster.internal/ubuntu oracular/universe amd64 pkg-r-autopkgtest all 20231212ubuntu1 [6448 B] 358s Get:98 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-base64enc amd64 0.1-3-3 [27.6 kB] 358s Get:99 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-cli amd64 3.6.2-1 [1380 kB] 358s Get:100 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-colorspace amd64 2.1-0+dfsg-1 [1541 kB] 358s Get:101 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-commonmark amd64 1.9.1-1 [131 kB] 358s Get:102 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-evaluate all 0.23-1 [90.2 kB] 358s Get:103 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-fansi amd64 1.0.5-1 [619 kB] 358s Get:104 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-farver amd64 2.1.1-2 [1349 kB] 358s Get:105 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-glue amd64 1.7.0-1 [154 kB] 358s Get:106 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-rlang amd64 1.1.3-1 [1663 kB] 358s Get:107 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-lifecycle all 1.0.4+dfsg-1 [110 kB] 358s Get:108 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-gtable all 0.3.4+dfsg-1 [191 kB] 358s Get:109 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-isoband amd64 0.2.7-1 [1481 kB] 358s Get:110 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-mass amd64 7.3-60.2-1 [1109 kB] 358s Get:111 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-lattice amd64 0.22-6-1 [1340 kB] 358s Get:112 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-nlme amd64 3.1.164-1build1 [2261 kB] 358s Get:113 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-matrix amd64 1.6-5-1 [3830 kB] 358s Get:114 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-mgcv amd64 1.9-1-1 [3252 kB] 358s Get:115 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-labeling all 0.4.3-1 [62.1 kB] 358s Get:116 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-munsell all 0.5.0-2build1 [208 kB] 358s Get:117 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-r6 all 2.5.1-1 [99.0 kB] 358s Get:118 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-rcolorbrewer all 1.1-3-1build1 [55.4 kB] 358s Get:119 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-viridislite all 0.4.2-2 [1088 kB] 358s Get:120 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-scales all 1.3.0-1 [603 kB] 358s Get:121 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-magrittr amd64 2.0.3-1 [154 kB] 358s Get:122 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-utf8 amd64 1.2.4-1 [140 kB] 358s Get:123 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-vctrs amd64 0.6.5-1 [1335 kB] 358s Get:124 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-pillar all 1.9.0+dfsg-1 [464 kB] 358s Get:125 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-pkgconfig all 2.0.3-2build1 [19.7 kB] 358s Get:126 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-tibble amd64 3.2.1+dfsg-2 [415 kB] 358s Get:127 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-withr all 2.5.0-1 [225 kB] 358s Get:128 http://ftpmaster.internal/ubuntu oracular-proposed/universe amd64 r-cran-ggplot2 all 3.5.1+dfsg-1 [3940 kB] 358s Get:129 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-xfun amd64 0.44+dfsg-1 [518 kB] 358s Get:130 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-highr all 0.10+dfsg-2 [38.5 kB] 358s Get:131 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-yaml amd64 2.3.8-2 [108 kB] 358s Get:132 http://ftpmaster.internal/ubuntu oracular/main amd64 libjs-mathjax all 2.7.9+dfsg-1 [5665 kB] 358s Get:133 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-knitr all 1.46+dfsg-1 [911 kB] 358s Get:134 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-markdown all 1.12+dfsg-2 [179 kB] 358s Get:135 http://ftpmaster.internal/ubuntu oracular/universe amd64 r-cran-matrixstats amd64 1.2.0-1 [488 kB] 359s Preconfiguring packages ... 359s Fetched 174 MB in 1s (126 MB/s) 359s Selecting previously unselected package gcc-13-base:amd64. 359s (Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 74359 files and directories currently installed.) 359s Preparing to unpack .../000-gcc-13-base_13.2.0-23ubuntu4_amd64.deb ... 359s Unpacking gcc-13-base:amd64 (13.2.0-23ubuntu4) ... 359s Selecting previously unselected package libisl23:amd64. 359s Preparing to unpack .../001-libisl23_0.26-3build1_amd64.deb ... 359s Unpacking libisl23:amd64 (0.26-3build1) ... 359s Selecting previously unselected package libmpc3:amd64. 359s Preparing to unpack .../002-libmpc3_1.3.1-1build1_amd64.deb ... 359s Unpacking libmpc3:amd64 (1.3.1-1build1) ... 359s Selecting previously unselected package cpp-13-x86-64-linux-gnu. 359s Preparing to unpack .../003-cpp-13-x86-64-linux-gnu_13.2.0-23ubuntu4_amd64.deb ... 359s Unpacking cpp-13-x86-64-linux-gnu (13.2.0-23ubuntu4) ... 359s Selecting previously unselected package cpp-13. 359s Preparing to unpack .../004-cpp-13_13.2.0-23ubuntu4_amd64.deb ... 359s Unpacking cpp-13 (13.2.0-23ubuntu4) ... 359s Selecting previously unselected package cpp-x86-64-linux-gnu. 359s Preparing to unpack .../005-cpp-x86-64-linux-gnu_4%3a13.2.0-7ubuntu1_amd64.deb ... 359s Unpacking cpp-x86-64-linux-gnu (4:13.2.0-7ubuntu1) ... 359s Selecting previously unselected package cpp. 359s Preparing to unpack .../006-cpp_4%3a13.2.0-7ubuntu1_amd64.deb ... 359s Unpacking cpp (4:13.2.0-7ubuntu1) ... 359s Selecting previously unselected package libcc1-0:amd64. 359s Preparing to unpack .../007-libcc1-0_14.1.0-1ubuntu1_amd64.deb ... 359s Unpacking libcc1-0:amd64 (14.1.0-1ubuntu1) ... 359s Selecting previously unselected package libgomp1:amd64. 359s Preparing to unpack .../008-libgomp1_14.1.0-1ubuntu1_amd64.deb ... 359s Unpacking libgomp1:amd64 (14.1.0-1ubuntu1) ... 359s Selecting previously unselected package libitm1:amd64. 359s Preparing to unpack .../009-libitm1_14.1.0-1ubuntu1_amd64.deb ... 359s Unpacking libitm1:amd64 (14.1.0-1ubuntu1) ... 359s Selecting previously unselected package libatomic1:amd64. 359s Preparing to unpack .../010-libatomic1_14.1.0-1ubuntu1_amd64.deb ... 359s Unpacking libatomic1:amd64 (14.1.0-1ubuntu1) ... 359s Selecting previously unselected package libasan8:amd64. 359s Preparing to unpack .../011-libasan8_14.1.0-1ubuntu1_amd64.deb ... 359s Unpacking libasan8:amd64 (14.1.0-1ubuntu1) ... 359s Selecting previously unselected package liblsan0:amd64. 359s Preparing to unpack .../012-liblsan0_14.1.0-1ubuntu1_amd64.deb ... 359s Unpacking liblsan0:amd64 (14.1.0-1ubuntu1) ... 359s Selecting previously unselected package libtsan2:amd64. 359s Preparing to unpack .../013-libtsan2_14.1.0-1ubuntu1_amd64.deb ... 359s Unpacking libtsan2:amd64 (14.1.0-1ubuntu1) ... 359s Selecting previously unselected package libubsan1:amd64. 359s Preparing to unpack .../014-libubsan1_14.1.0-1ubuntu1_amd64.deb ... 359s Unpacking libubsan1:amd64 (14.1.0-1ubuntu1) ... 359s Selecting previously unselected package libhwasan0:amd64. 359s Preparing to unpack .../015-libhwasan0_14.1.0-1ubuntu1_amd64.deb ... 359s Unpacking libhwasan0:amd64 (14.1.0-1ubuntu1) ... 359s Selecting previously unselected package libquadmath0:amd64. 359s Preparing to unpack .../016-libquadmath0_14.1.0-1ubuntu1_amd64.deb ... 359s Unpacking libquadmath0:amd64 (14.1.0-1ubuntu1) ... 359s Selecting previously unselected package libgcc-13-dev:amd64. 359s Preparing to unpack .../017-libgcc-13-dev_13.2.0-23ubuntu4_amd64.deb ... 359s Unpacking libgcc-13-dev:amd64 (13.2.0-23ubuntu4) ... 360s Selecting previously unselected package gcc-13-x86-64-linux-gnu. 360s Preparing to unpack .../018-gcc-13-x86-64-linux-gnu_13.2.0-23ubuntu4_amd64.deb ... 360s Unpacking gcc-13-x86-64-linux-gnu (13.2.0-23ubuntu4) ... 360s Selecting previously unselected package gcc-13. 360s Preparing to unpack .../019-gcc-13_13.2.0-23ubuntu4_amd64.deb ... 360s Unpacking gcc-13 (13.2.0-23ubuntu4) ... 360s Selecting previously unselected package gcc-x86-64-linux-gnu. 360s Preparing to unpack .../020-gcc-x86-64-linux-gnu_4%3a13.2.0-7ubuntu1_amd64.deb ... 360s Unpacking gcc-x86-64-linux-gnu (4:13.2.0-7ubuntu1) ... 360s Selecting previously unselected package gcc. 360s Preparing to unpack .../021-gcc_4%3a13.2.0-7ubuntu1_amd64.deb ... 360s Unpacking gcc (4:13.2.0-7ubuntu1) ... 360s Selecting previously unselected package libstdc++-13-dev:amd64. 360s Preparing to unpack .../022-libstdc++-13-dev_13.2.0-23ubuntu4_amd64.deb ... 360s Unpacking libstdc++-13-dev:amd64 (13.2.0-23ubuntu4) ... 360s Selecting previously unselected package g++-13-x86-64-linux-gnu. 360s Preparing to unpack .../023-g++-13-x86-64-linux-gnu_13.2.0-23ubuntu4_amd64.deb ... 360s Unpacking g++-13-x86-64-linux-gnu (13.2.0-23ubuntu4) ... 360s Selecting previously unselected package g++-13. 360s Preparing to unpack .../024-g++-13_13.2.0-23ubuntu4_amd64.deb ... 360s Unpacking g++-13 (13.2.0-23ubuntu4) ... 360s Selecting previously unselected package g++-x86-64-linux-gnu. 361s Preparing to unpack .../025-g++-x86-64-linux-gnu_4%3a13.2.0-7ubuntu1_amd64.deb ... 361s Unpacking g++-x86-64-linux-gnu (4:13.2.0-7ubuntu1) ... 361s Selecting previously unselected package g++. 361s Preparing to unpack .../026-g++_4%3a13.2.0-7ubuntu1_amd64.deb ... 361s Unpacking g++ (4:13.2.0-7ubuntu1) ... 361s Selecting previously unselected package build-essential. 361s Preparing to unpack .../027-build-essential_12.10ubuntu1_amd64.deb ... 361s Unpacking build-essential (12.10ubuntu1) ... 361s Selecting previously unselected package dctrl-tools. 361s Preparing to unpack .../028-dctrl-tools_2.24-3build3_amd64.deb ... 361s Unpacking dctrl-tools (2.24-3build3) ... 361s Selecting previously unselected package fontconfig. 361s Preparing to unpack .../029-fontconfig_2.15.0-1.1ubuntu2_amd64.deb ... 361s Unpacking fontconfig (2.15.0-1.1ubuntu2) ... 361s Selecting previously unselected package fonts-glyphicons-halflings. 361s Preparing to unpack .../030-fonts-glyphicons-halflings_1.009~3.4.1+dfsg-3_all.deb ... 361s Unpacking fonts-glyphicons-halflings (1.009~3.4.1+dfsg-3) ... 361s Selecting previously unselected package fonts-mathjax. 361s Preparing to unpack .../031-fonts-mathjax_2.7.9+dfsg-1_all.deb ... 361s Unpacking fonts-mathjax (2.7.9+dfsg-1) ... 361s Selecting previously unselected package libgfortran5:amd64. 361s Preparing to unpack .../032-libgfortran5_14.1.0-1ubuntu1_amd64.deb ... 361s Unpacking libgfortran5:amd64 (14.1.0-1ubuntu1) ... 361s Selecting previously unselected package libgfortran-13-dev:amd64. 361s Preparing to unpack .../033-libgfortran-13-dev_13.2.0-23ubuntu4_amd64.deb ... 361s Unpacking libgfortran-13-dev:amd64 (13.2.0-23ubuntu4) ... 361s Selecting previously unselected package gfortran-13-x86-64-linux-gnu. 361s Preparing to unpack .../034-gfortran-13-x86-64-linux-gnu_13.2.0-23ubuntu4_amd64.deb ... 361s Unpacking gfortran-13-x86-64-linux-gnu (13.2.0-23ubuntu4) ... 361s Selecting previously unselected package gfortran-13. 361s Preparing to unpack .../035-gfortran-13_13.2.0-23ubuntu4_amd64.deb ... 361s Unpacking gfortran-13 (13.2.0-23ubuntu4) ... 361s Selecting previously unselected package gfortran-x86-64-linux-gnu. 361s Preparing to unpack .../036-gfortran-x86-64-linux-gnu_4%3a13.2.0-7ubuntu1_amd64.deb ... 361s Unpacking gfortran-x86-64-linux-gnu (4:13.2.0-7ubuntu1) ... 361s Selecting previously unselected package gfortran. 361s Preparing to unpack .../037-gfortran_4%3a13.2.0-7ubuntu1_amd64.deb ... 361s Unpacking gfortran (4:13.2.0-7ubuntu1) ... 361s Selecting previously unselected package icu-devtools. 361s Preparing to unpack .../038-icu-devtools_74.2-1ubuntu3_amd64.deb ... 361s Unpacking icu-devtools (74.2-1ubuntu3) ... 361s Selecting previously unselected package libblas3:amd64. 361s Preparing to unpack .../039-libblas3_3.12.0-3build1_amd64.deb ... 361s Unpacking libblas3:amd64 (3.12.0-3build1) ... 361s Selecting previously unselected package libblas-dev:amd64. 361s Preparing to unpack .../040-libblas-dev_3.12.0-3build1_amd64.deb ... 361s Unpacking libblas-dev:amd64 (3.12.0-3build1) ... 361s Selecting previously unselected package libbz2-dev:amd64. 361s Preparing to unpack .../041-libbz2-dev_1.0.8-5.1_amd64.deb ... 361s Unpacking libbz2-dev:amd64 (1.0.8-5.1) ... 361s Selecting previously unselected package libpixman-1-0:amd64. 361s Preparing to unpack .../042-libpixman-1-0_0.42.2-1build1_amd64.deb ... 361s Unpacking libpixman-1-0:amd64 (0.42.2-1build1) ... 361s Selecting previously unselected package libxcb-render0:amd64. 361s Preparing to unpack .../043-libxcb-render0_1.17.0-2_amd64.deb ... 361s Unpacking libxcb-render0:amd64 (1.17.0-2) ... 361s Selecting previously unselected package libxcb-shm0:amd64. 361s Preparing to unpack .../044-libxcb-shm0_1.17.0-2_amd64.deb ... 361s Unpacking libxcb-shm0:amd64 (1.17.0-2) ... 361s Selecting previously unselected package libxrender1:amd64. 361s Preparing to unpack .../045-libxrender1_1%3a0.9.10-1.1build1_amd64.deb ... 361s Unpacking libxrender1:amd64 (1:0.9.10-1.1build1) ... 362s Selecting previously unselected package libcairo2:amd64. 362s Preparing to unpack .../046-libcairo2_1.18.0-3build1_amd64.deb ... 362s Unpacking libcairo2:amd64 (1.18.0-3build1) ... 362s Selecting previously unselected package libdatrie1:amd64. 362s Preparing to unpack .../047-libdatrie1_0.2.13-3build1_amd64.deb ... 362s Unpacking libdatrie1:amd64 (0.2.13-3build1) ... 362s Selecting previously unselected package libdeflate-dev:amd64. 362s Preparing to unpack .../048-libdeflate-dev_1.20-1_amd64.deb ... 362s Unpacking libdeflate-dev:amd64 (1.20-1) ... 362s Selecting previously unselected package libgraphite2-3:amd64. 362s Preparing to unpack .../049-libgraphite2-3_1.3.14-2build1_amd64.deb ... 362s Unpacking libgraphite2-3:amd64 (1.3.14-2build1) ... 362s Selecting previously unselected package libharfbuzz0b:amd64. 362s Preparing to unpack .../050-libharfbuzz0b_8.3.0-2build2_amd64.deb ... 362s Unpacking libharfbuzz0b:amd64 (8.3.0-2build2) ... 362s Selecting previously unselected package x11-common. 362s Preparing to unpack .../051-x11-common_1%3a7.7+23ubuntu3_all.deb ... 362s Unpacking x11-common (1:7.7+23ubuntu3) ... 362s Selecting previously unselected package libice6:amd64. 362s Preparing to unpack .../052-libice6_2%3a1.0.10-1build3_amd64.deb ... 362s Unpacking libice6:amd64 (2:1.0.10-1build3) ... 362s Selecting previously unselected package libicu-dev:amd64. 362s Preparing to unpack .../053-libicu-dev_74.2-1ubuntu3_amd64.deb ... 362s Unpacking libicu-dev:amd64 (74.2-1ubuntu3) ... 362s Selecting previously unselected package libjpeg-turbo8-dev:amd64. 362s Preparing to unpack .../054-libjpeg-turbo8-dev_2.1.5-2ubuntu2_amd64.deb ... 362s Unpacking libjpeg-turbo8-dev:amd64 (2.1.5-2ubuntu2) ... 362s Selecting previously unselected package libjpeg8-dev:amd64. 362s Preparing to unpack .../055-libjpeg8-dev_8c-2ubuntu11_amd64.deb ... 362s Unpacking libjpeg8-dev:amd64 (8c-2ubuntu11) ... 362s Selecting previously unselected package libjpeg-dev:amd64. 362s Preparing to unpack .../056-libjpeg-dev_8c-2ubuntu11_amd64.deb ... 362s Unpacking libjpeg-dev:amd64 (8c-2ubuntu11) ... 362s Selecting previously unselected package libjs-bootstrap. 362s Preparing to unpack .../057-libjs-bootstrap_3.4.1+dfsg-3_all.deb ... 362s Unpacking libjs-bootstrap (3.4.1+dfsg-3) ... 362s Selecting previously unselected package libjs-highlight.js. 362s Preparing to unpack .../058-libjs-highlight.js_9.18.5+dfsg1-2_all.deb ... 362s Unpacking libjs-highlight.js (9.18.5+dfsg1-2) ... 362s Selecting previously unselected package libjs-jquery. 362s Preparing to unpack .../059-libjs-jquery_3.6.1+dfsg+~3.5.14-1_all.deb ... 362s Unpacking libjs-jquery (3.6.1+dfsg+~3.5.14-1) ... 362s Selecting previously unselected package libjs-jquery-datatables. 362s Preparing to unpack .../060-libjs-jquery-datatables_1.11.5+dfsg-2_all.deb ... 362s Unpacking libjs-jquery-datatables (1.11.5+dfsg-2) ... 362s Selecting previously unselected package liblapack3:amd64. 362s Preparing to unpack .../061-liblapack3_3.12.0-3build1_amd64.deb ... 362s Unpacking liblapack3:amd64 (3.12.0-3build1) ... 362s Selecting previously unselected package liblapack-dev:amd64. 362s Preparing to unpack .../062-liblapack-dev_3.12.0-3build1_amd64.deb ... 362s Unpacking liblapack-dev:amd64 (3.12.0-3build1) ... 362s Selecting previously unselected package libncurses-dev:amd64. 362s Preparing to unpack .../063-libncurses-dev_6.4+20240113-1ubuntu2_amd64.deb ... 362s Unpacking libncurses-dev:amd64 (6.4+20240113-1ubuntu2) ... 363s Selecting previously unselected package libthai-data. 363s Preparing to unpack .../064-libthai-data_0.1.29-2build1_all.deb ... 363s Unpacking libthai-data (0.1.29-2build1) ... 363s Selecting previously unselected package libthai0:amd64. 363s Preparing to unpack .../065-libthai0_0.1.29-2build1_amd64.deb ... 363s Unpacking libthai0:amd64 (0.1.29-2build1) ... 363s Selecting previously unselected package libpango-1.0-0:amd64. 363s Preparing to unpack .../066-libpango-1.0-0_1.52.2+ds-1_amd64.deb ... 363s Unpacking libpango-1.0-0:amd64 (1.52.2+ds-1) ... 363s Selecting previously unselected package libpangoft2-1.0-0:amd64. 363s Preparing to unpack .../067-libpangoft2-1.0-0_1.52.2+ds-1_amd64.deb ... 363s Unpacking libpangoft2-1.0-0:amd64 (1.52.2+ds-1) ... 363s Selecting previously unselected package libpangocairo-1.0-0:amd64. 363s Preparing to unpack .../068-libpangocairo-1.0-0_1.52.2+ds-1_amd64.deb ... 363s Unpacking libpangocairo-1.0-0:amd64 (1.52.2+ds-1) ... 363s Selecting previously unselected package libpaper1:amd64. 363s Preparing to unpack .../069-libpaper1_1.1.29build1_amd64.deb ... 363s Unpacking libpaper1:amd64 (1.1.29build1) ... 363s Selecting previously unselected package libpaper-utils. 363s Preparing to unpack .../070-libpaper-utils_1.1.29build1_amd64.deb ... 363s Unpacking libpaper-utils (1.1.29build1) ... 363s Selecting previously unselected package libpcre2-16-0:amd64. 363s Preparing to unpack .../071-libpcre2-16-0_10.42-4ubuntu2_amd64.deb ... 363s Unpacking libpcre2-16-0:amd64 (10.42-4ubuntu2) ... 363s Selecting previously unselected package libpcre2-32-0:amd64. 363s Preparing to unpack .../072-libpcre2-32-0_10.42-4ubuntu2_amd64.deb ... 363s Unpacking libpcre2-32-0:amd64 (10.42-4ubuntu2) ... 363s Selecting previously unselected package libpcre2-posix3:amd64. 363s Preparing to unpack .../073-libpcre2-posix3_10.42-4ubuntu2_amd64.deb ... 363s Unpacking libpcre2-posix3:amd64 (10.42-4ubuntu2) ... 363s Selecting previously unselected package libpcre2-dev:amd64. 363s Preparing to unpack .../074-libpcre2-dev_10.42-4ubuntu2_amd64.deb ... 363s Unpacking libpcre2-dev:amd64 (10.42-4ubuntu2) ... 363s Selecting previously unselected package libpkgconf3:amd64. 363s Preparing to unpack .../075-libpkgconf3_1.8.1-2build1_amd64.deb ... 363s Unpacking libpkgconf3:amd64 (1.8.1-2build1) ... 363s Selecting previously unselected package zlib1g-dev:amd64. 363s Preparing to unpack .../076-zlib1g-dev_1%3a1.3.dfsg-3.1ubuntu2_amd64.deb ... 363s Unpacking zlib1g-dev:amd64 (1:1.3.dfsg-3.1ubuntu2) ... 363s Selecting previously unselected package libpng-dev:amd64. 363s Preparing to unpack .../077-libpng-dev_1.6.43-5build1_amd64.deb ... 363s Unpacking libpng-dev:amd64 (1.6.43-5build1) ... 363s Selecting previously unselected package libreadline-dev:amd64. 363s Preparing to unpack .../078-libreadline-dev_8.2-4build1_amd64.deb ... 363s Unpacking libreadline-dev:amd64 (8.2-4build1) ... 363s Selecting previously unselected package libsm6:amd64. 363s Preparing to unpack .../079-libsm6_2%3a1.2.3-1build3_amd64.deb ... 363s Unpacking libsm6:amd64 (2:1.2.3-1build3) ... 363s Selecting previously unselected package libtcl8.6:amd64. 363s Preparing to unpack .../080-libtcl8.6_8.6.14+dfsg-1build1_amd64.deb ... 363s Unpacking libtcl8.6:amd64 (8.6.14+dfsg-1build1) ... 363s Selecting previously unselected package libxft2:amd64. 363s Preparing to unpack .../081-libxft2_2.3.6-1build1_amd64.deb ... 363s Unpacking libxft2:amd64 (2.3.6-1build1) ... 363s Selecting previously unselected package libxss1:amd64. 363s Preparing to unpack .../082-libxss1_1%3a1.2.3-1build3_amd64.deb ... 363s Unpacking libxss1:amd64 (1:1.2.3-1build3) ... 363s Selecting previously unselected package libtk8.6:amd64. 363s Preparing to unpack .../083-libtk8.6_8.6.14-1build1_amd64.deb ... 363s Unpacking libtk8.6:amd64 (8.6.14-1build1) ... 363s Selecting previously unselected package libxt6t64:amd64. 363s Preparing to unpack .../084-libxt6t64_1%3a1.2.1-1.2build1_amd64.deb ... 363s Unpacking libxt6t64:amd64 (1:1.2.1-1.2build1) ... 363s Selecting previously unselected package node-normalize.css. 363s Preparing to unpack .../085-node-normalize.css_8.0.1-5_all.deb ... 363s Unpacking node-normalize.css (8.0.1-5) ... 363s Selecting previously unselected package zip. 363s Preparing to unpack .../086-zip_3.0-13build1_amd64.deb ... 363s Unpacking zip (3.0-13build1) ... 363s Selecting previously unselected package unzip. 363s Preparing to unpack .../087-unzip_6.0-28ubuntu4_amd64.deb ... 363s Unpacking unzip (6.0-28ubuntu4) ... 363s Selecting previously unselected package xdg-utils. 363s Preparing to unpack .../088-xdg-utils_1.1.3-4.1ubuntu3_all.deb ... 363s Unpacking xdg-utils (1.1.3-4.1ubuntu3) ... 363s Selecting previously unselected package r-base-core. 363s Preparing to unpack .../089-r-base-core_4.4.0-2_amd64.deb ... 363s Unpacking r-base-core (4.4.0-2) ... 364s Selecting previously unselected package liblzma-dev:amd64. 364s Preparing to unpack .../090-liblzma-dev_5.6.1+really5.4.5-1_amd64.deb ... 364s Unpacking liblzma-dev:amd64 (5.6.1+really5.4.5-1) ... 364s Selecting previously unselected package pkgconf-bin. 364s Preparing to unpack .../091-pkgconf-bin_1.8.1-2build1_amd64.deb ... 364s Unpacking pkgconf-bin (1.8.1-2build1) ... 364s Selecting previously unselected package pkgconf:amd64. 364s Preparing to unpack .../092-pkgconf_1.8.1-2build1_amd64.deb ... 364s Unpacking pkgconf:amd64 (1.8.1-2build1) ... 364s Selecting previously unselected package libtirpc-dev:amd64. 364s Preparing to unpack .../093-libtirpc-dev_1.3.4+ds-1.3_amd64.deb ... 364s Unpacking libtirpc-dev:amd64 (1.3.4+ds-1.3) ... 364s Selecting previously unselected package r-base-dev. 364s Preparing to unpack .../094-r-base-dev_4.4.0-2_all.deb ... 364s Unpacking r-base-dev (4.4.0-2) ... 364s Selecting previously unselected package pkg-r-autopkgtest. 364s Preparing to unpack .../095-pkg-r-autopkgtest_20231212ubuntu1_all.deb ... 364s Unpacking pkg-r-autopkgtest (20231212ubuntu1) ... 364s Selecting previously unselected package r-cran-base64enc. 364s Preparing to unpack .../096-r-cran-base64enc_0.1-3-3_amd64.deb ... 364s Unpacking r-cran-base64enc (0.1-3-3) ... 364s Selecting previously unselected package r-cran-cli. 364s Preparing to unpack .../097-r-cran-cli_3.6.2-1_amd64.deb ... 364s Unpacking r-cran-cli (3.6.2-1) ... 364s Selecting previously unselected package r-cran-colorspace. 364s Preparing to unpack .../098-r-cran-colorspace_2.1-0+dfsg-1_amd64.deb ... 364s Unpacking r-cran-colorspace (2.1-0+dfsg-1) ... 364s Selecting previously unselected package r-cran-commonmark. 364s Preparing to unpack .../099-r-cran-commonmark_1.9.1-1_amd64.deb ... 364s Unpacking r-cran-commonmark (1.9.1-1) ... 364s Selecting previously unselected package r-cran-evaluate. 364s Preparing to unpack .../100-r-cran-evaluate_0.23-1_all.deb ... 364s Unpacking r-cran-evaluate (0.23-1) ... 364s Selecting previously unselected package r-cran-fansi. 364s Preparing to unpack .../101-r-cran-fansi_1.0.5-1_amd64.deb ... 364s Unpacking r-cran-fansi (1.0.5-1) ... 364s Selecting previously unselected package r-cran-farver. 364s Preparing to unpack .../102-r-cran-farver_2.1.1-2_amd64.deb ... 364s Unpacking r-cran-farver (2.1.1-2) ... 364s Selecting previously unselected package r-cran-glue. 364s Preparing to unpack .../103-r-cran-glue_1.7.0-1_amd64.deb ... 364s Unpacking r-cran-glue (1.7.0-1) ... 364s Selecting previously unselected package r-cran-rlang. 364s Preparing to unpack .../104-r-cran-rlang_1.1.3-1_amd64.deb ... 364s Unpacking r-cran-rlang (1.1.3-1) ... 364s Selecting previously unselected package r-cran-lifecycle. 364s Preparing to unpack .../105-r-cran-lifecycle_1.0.4+dfsg-1_all.deb ... 364s Unpacking r-cran-lifecycle (1.0.4+dfsg-1) ... 364s Selecting previously unselected package r-cran-gtable. 364s Preparing to unpack .../106-r-cran-gtable_0.3.4+dfsg-1_all.deb ... 364s Unpacking r-cran-gtable (0.3.4+dfsg-1) ... 364s Selecting previously unselected package r-cran-isoband. 364s Preparing to unpack .../107-r-cran-isoband_0.2.7-1_amd64.deb ... 364s Unpacking r-cran-isoband (0.2.7-1) ... 364s Selecting previously unselected package r-cran-mass. 364s Preparing to unpack .../108-r-cran-mass_7.3-60.2-1_amd64.deb ... 364s Unpacking r-cran-mass (7.3-60.2-1) ... 364s Selecting previously unselected package r-cran-lattice. 364s Preparing to unpack .../109-r-cran-lattice_0.22-6-1_amd64.deb ... 364s Unpacking r-cran-lattice (0.22-6-1) ... 364s Selecting previously unselected package r-cran-nlme. 364s Preparing to unpack .../110-r-cran-nlme_3.1.164-1build1_amd64.deb ... 364s Unpacking r-cran-nlme (3.1.164-1build1) ... 364s Selecting previously unselected package r-cran-matrix. 364s Preparing to unpack .../111-r-cran-matrix_1.6-5-1_amd64.deb ... 364s Unpacking r-cran-matrix (1.6-5-1) ... 365s Selecting previously unselected package r-cran-mgcv. 365s Preparing to unpack .../112-r-cran-mgcv_1.9-1-1_amd64.deb ... 365s Unpacking r-cran-mgcv (1.9-1-1) ... 365s Selecting previously unselected package r-cran-labeling. 365s Preparing to unpack .../113-r-cran-labeling_0.4.3-1_all.deb ... 365s Unpacking r-cran-labeling (0.4.3-1) ... 365s Selecting previously unselected package r-cran-munsell. 365s Preparing to unpack .../114-r-cran-munsell_0.5.0-2build1_all.deb ... 365s Unpacking r-cran-munsell (0.5.0-2build1) ... 365s Selecting previously unselected package r-cran-r6. 365s Preparing to unpack .../115-r-cran-r6_2.5.1-1_all.deb ... 365s Unpacking r-cran-r6 (2.5.1-1) ... 365s Selecting previously unselected package r-cran-rcolorbrewer. 365s Preparing to unpack .../116-r-cran-rcolorbrewer_1.1-3-1build1_all.deb ... 365s Unpacking r-cran-rcolorbrewer (1.1-3-1build1) ... 365s Selecting previously unselected package r-cran-viridislite. 365s Preparing to unpack .../117-r-cran-viridislite_0.4.2-2_all.deb ... 365s Unpacking r-cran-viridislite (0.4.2-2) ... 365s Selecting previously unselected package r-cran-scales. 365s Preparing to unpack .../118-r-cran-scales_1.3.0-1_all.deb ... 365s Unpacking r-cran-scales (1.3.0-1) ... 365s Selecting previously unselected package r-cran-magrittr. 365s Preparing to unpack .../119-r-cran-magrittr_2.0.3-1_amd64.deb ... 365s Unpacking r-cran-magrittr (2.0.3-1) ... 365s Selecting previously unselected package r-cran-utf8. 365s Preparing to unpack .../120-r-cran-utf8_1.2.4-1_amd64.deb ... 365s Unpacking r-cran-utf8 (1.2.4-1) ... 365s Selecting previously unselected package r-cran-vctrs. 365s Preparing to unpack .../121-r-cran-vctrs_0.6.5-1_amd64.deb ... 365s Unpacking r-cran-vctrs (0.6.5-1) ... 365s Selecting previously unselected package r-cran-pillar. 365s Preparing to unpack .../122-r-cran-pillar_1.9.0+dfsg-1_all.deb ... 365s Unpacking r-cran-pillar (1.9.0+dfsg-1) ... 365s Selecting previously unselected package r-cran-pkgconfig. 365s Preparing to unpack .../123-r-cran-pkgconfig_2.0.3-2build1_all.deb ... 365s Unpacking r-cran-pkgconfig (2.0.3-2build1) ... 365s Selecting previously unselected package r-cran-tibble. 365s Preparing to unpack .../124-r-cran-tibble_3.2.1+dfsg-2_amd64.deb ... 365s Unpacking r-cran-tibble (3.2.1+dfsg-2) ... 365s Selecting previously unselected package r-cran-withr. 365s Preparing to unpack .../125-r-cran-withr_2.5.0-1_all.deb ... 365s Unpacking r-cran-withr (2.5.0-1) ... 365s Selecting previously unselected package r-cran-ggplot2. 365s Preparing to unpack .../126-r-cran-ggplot2_3.5.1+dfsg-1_all.deb ... 365s Unpacking r-cran-ggplot2 (3.5.1+dfsg-1) ... 365s Selecting previously unselected package r-cran-xfun. 365s Preparing to unpack .../127-r-cran-xfun_0.44+dfsg-1_amd64.deb ... 365s Unpacking r-cran-xfun (0.44+dfsg-1) ... 365s Selecting previously unselected package r-cran-highr. 365s Preparing to unpack .../128-r-cran-highr_0.10+dfsg-2_all.deb ... 365s Unpacking r-cran-highr (0.10+dfsg-2) ... 365s Selecting previously unselected package r-cran-yaml. 365s Preparing to unpack .../129-r-cran-yaml_2.3.8-2_amd64.deb ... 365s Unpacking r-cran-yaml (2.3.8-2) ... 365s Selecting previously unselected package libjs-mathjax. 365s Preparing to unpack .../130-libjs-mathjax_2.7.9+dfsg-1_all.deb ... 365s Unpacking libjs-mathjax (2.7.9+dfsg-1) ... 366s Selecting previously unselected package r-cran-knitr. 366s Preparing to unpack .../131-r-cran-knitr_1.46+dfsg-1_all.deb ... 366s Unpacking r-cran-knitr (1.46+dfsg-1) ... 366s Selecting previously unselected package r-cran-markdown. 366s Preparing to unpack .../132-r-cran-markdown_1.12+dfsg-2_all.deb ... 366s Unpacking r-cran-markdown (1.12+dfsg-2) ... 366s Selecting previously unselected package r-cran-matrixstats. 366s Preparing to unpack .../133-r-cran-matrixstats_1.2.0-1_amd64.deb ... 366s Unpacking r-cran-matrixstats (1.2.0-1) ... 366s Selecting previously unselected package autopkgtest-satdep. 366s Preparing to unpack .../134-2-autopkgtest-satdep.deb ... 366s Unpacking autopkgtest-satdep (0) ... 366s Setting up libgraphite2-3:amd64 (1.3.14-2build1) ... 366s Setting up libpixman-1-0:amd64 (0.42.2-1build1) ... 366s Setting up libpaper1:amd64 (1.1.29build1) ... 366s 366s Creating config file /etc/papersize with new version 366s Setting up fontconfig (2.15.0-1.1ubuntu2) ... 368s Regenerating fonts cache... done. 368s Setting up libjpeg-turbo8-dev:amd64 (2.1.5-2ubuntu2) ... 368s Setting up libncurses-dev:amd64 (6.4+20240113-1ubuntu2) ... 368s Setting up fonts-mathjax (2.7.9+dfsg-1) ... 368s Setting up libjs-mathjax (2.7.9+dfsg-1) ... 368s Setting up libxrender1:amd64 (1:0.9.10-1.1build1) ... 368s Setting up libdatrie1:amd64 (0.2.13-3build1) ... 368s Setting up libxcb-render0:amd64 (1.17.0-2) ... 368s Setting up fonts-glyphicons-halflings (1.009~3.4.1+dfsg-3) ... 368s Setting up unzip (6.0-28ubuntu4) ... 368s Setting up x11-common (1:7.7+23ubuntu3) ... 369s Setting up libxcb-shm0:amd64 (1.17.0-2) ... 369s Setting up libpaper-utils (1.1.29build1) ... 369s Setting up libreadline-dev:amd64 (8.2-4build1) ... 369s Setting up libgomp1:amd64 (14.1.0-1ubuntu1) ... 369s Setting up libcairo2:amd64 (1.18.0-3build1) ... 369s Setting up libpcre2-16-0:amd64 (10.42-4ubuntu2) ... 369s Setting up zip (3.0-13build1) ... 369s Setting up libpcre2-32-0:amd64 (10.42-4ubuntu2) ... 369s Setting up libblas3:amd64 (3.12.0-3build1) ... 369s update-alternatives: using /usr/lib/x86_64-linux-gnu/blas/libblas.so.3 to provide /usr/lib/x86_64-linux-gnu/libblas.so.3 (libblas.so.3-x86_64-linux-gnu) in auto mode 369s Setting up libtirpc-dev:amd64 (1.3.4+ds-1.3) ... 369s Setting up libpkgconf3:amd64 (1.8.1-2build1) ... 369s Setting up gcc-13-base:amd64 (13.2.0-23ubuntu4) ... 369s Setting up libquadmath0:amd64 (14.1.0-1ubuntu1) ... 369s Setting up libmpc3:amd64 (1.3.1-1build1) ... 369s Setting up libatomic1:amd64 (14.1.0-1ubuntu1) ... 369s Setting up libtcl8.6:amd64 (8.6.14+dfsg-1build1) ... 369s Setting up icu-devtools (74.2-1ubuntu3) ... 369s Setting up pkgconf-bin (1.8.1-2build1) ... 369s Setting up libgfortran5:amd64 (14.1.0-1ubuntu1) ... 369s Setting up liblzma-dev:amd64 (5.6.1+really5.4.5-1) ... 369s Setting up libubsan1:amd64 (14.1.0-1ubuntu1) ... 369s Setting up zlib1g-dev:amd64 (1:1.3.dfsg-3.1ubuntu2) ... 369s Setting up libpcre2-posix3:amd64 (10.42-4ubuntu2) ... 369s Setting up libjs-highlight.js (9.18.5+dfsg1-2) ... 369s Setting up libhwasan0:amd64 (14.1.0-1ubuntu1) ... 369s Setting up libasan8:amd64 (14.1.0-1ubuntu1) ... 369s Setting up libharfbuzz0b:amd64 (8.3.0-2build2) ... 369s Setting up libthai-data (0.1.29-2build1) ... 369s Setting up libxss1:amd64 (1:1.2.3-1build3) ... 369s Setting up libtsan2:amd64 (14.1.0-1ubuntu1) ... 369s Setting up libjs-jquery (3.6.1+dfsg+~3.5.14-1) ... 369s Setting up libjpeg8-dev:amd64 (8c-2ubuntu11) ... 369s Setting up libisl23:amd64 (0.26-3build1) ... 369s Setting up libdeflate-dev:amd64 (1.20-1) ... 369s Setting up node-normalize.css (8.0.1-5) ... 369s Setting up libicu-dev:amd64 (74.2-1ubuntu3) ... 369s Setting up xdg-utils (1.1.3-4.1ubuntu3) ... 369s update-alternatives: using /usr/bin/xdg-open to provide /usr/bin/open (open) in auto mode 369s Setting up libcc1-0:amd64 (14.1.0-1ubuntu1) ... 369s Setting up liblsan0:amd64 (14.1.0-1ubuntu1) ... 369s Setting up libblas-dev:amd64 (3.12.0-3build1) ... 369s update-alternatives: using /usr/lib/x86_64-linux-gnu/blas/libblas.so to provide /usr/lib/x86_64-linux-gnu/libblas.so (libblas.so-x86_64-linux-gnu) in auto mode 369s Setting up dctrl-tools (2.24-3build3) ... 369s Setting up libjs-bootstrap (3.4.1+dfsg-3) ... 369s Setting up libitm1:amd64 (14.1.0-1ubuntu1) ... 369s Setting up libbz2-dev:amd64 (1.0.8-5.1) ... 369s Setting up libice6:amd64 (2:1.0.10-1build3) ... 369s Setting up liblapack3:amd64 (3.12.0-3build1) ... 369s update-alternatives: using /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3 to provide /usr/lib/x86_64-linux-gnu/liblapack.so.3 (liblapack.so.3-x86_64-linux-gnu) in auto mode 369s Setting up libxft2:amd64 (2.3.6-1build1) ... 369s Setting up libpcre2-dev:amd64 (10.42-4ubuntu2) ... 369s Setting up cpp-13-x86-64-linux-gnu (13.2.0-23ubuntu4) ... 369s Setting up libtk8.6:amd64 (8.6.14-1build1) ... 369s Setting up libpng-dev:amd64 (1.6.43-5build1) ... 369s Setting up libjpeg-dev:amd64 (8c-2ubuntu11) ... 369s Setting up libjs-jquery-datatables (1.11.5+dfsg-2) ... 369s Setting up pkgconf:amd64 (1.8.1-2build1) ... 369s Setting up libthai0:amd64 (0.1.29-2build1) ... 369s Setting up liblapack-dev:amd64 (3.12.0-3build1) ... 369s update-alternatives: using /usr/lib/x86_64-linux-gnu/lapack/liblapack.so to provide /usr/lib/x86_64-linux-gnu/liblapack.so (liblapack.so-x86_64-linux-gnu) in auto mode 369s Setting up libgcc-13-dev:amd64 (13.2.0-23ubuntu4) ... 369s Setting up libgfortran-13-dev:amd64 (13.2.0-23ubuntu4) ... 369s Setting up libsm6:amd64 (2:1.2.3-1build3) ... 369s Setting up libstdc++-13-dev:amd64 (13.2.0-23ubuntu4) ... 369s Setting up cpp-x86-64-linux-gnu (4:13.2.0-7ubuntu1) ... 369s Setting up cpp-13 (13.2.0-23ubuntu4) ... 369s Setting up gcc-13-x86-64-linux-gnu (13.2.0-23ubuntu4) ... 369s Setting up libpango-1.0-0:amd64 (1.52.2+ds-1) ... 369s Setting up gfortran-13-x86-64-linux-gnu (13.2.0-23ubuntu4) ... 369s Setting up libxt6t64:amd64 (1:1.2.1-1.2build1) ... 369s Setting up gcc-13 (13.2.0-23ubuntu4) ... 369s Setting up cpp (4:13.2.0-7ubuntu1) ... 369s Setting up libpangoft2-1.0-0:amd64 (1.52.2+ds-1) ... 369s Setting up libpangocairo-1.0-0:amd64 (1.52.2+ds-1) ... 369s Setting up g++-13-x86-64-linux-gnu (13.2.0-23ubuntu4) ... 369s Setting up gcc-x86-64-linux-gnu (4:13.2.0-7ubuntu1) ... 369s Setting up gfortran-x86-64-linux-gnu (4:13.2.0-7ubuntu1) ... 369s Setting up gcc (4:13.2.0-7ubuntu1) ... 369s Setting up gfortran-13 (13.2.0-23ubuntu4) ... 369s Setting up r-base-core (4.4.0-2) ... 369s 369s Creating config file /etc/R/Renviron with new version 369s Setting up r-cran-labeling (0.4.3-1) ... 369s Setting up r-cran-lattice (0.22-6-1) ... 369s Setting up r-cran-nlme (3.1.164-1build1) ... 369s Setting up r-cran-farver (2.1.1-2) ... 369s Setting up r-cran-viridislite (0.4.2-2) ... 369s Setting up g++-x86-64-linux-gnu (4:13.2.0-7ubuntu1) ... 369s Setting up r-cran-commonmark (1.9.1-1) ... 369s Setting up r-cran-r6 (2.5.1-1) ... 369s Setting up r-cran-magrittr (2.0.3-1) ... 369s Setting up g++-13 (13.2.0-23ubuntu4) ... 369s Setting up r-cran-rlang (1.1.3-1) ... 369s Setting up r-cran-matrixstats (1.2.0-1) ... 369s Setting up r-cran-xfun (0.44+dfsg-1) ... 369s Setting up r-cran-withr (2.5.0-1) ... 369s Setting up r-cran-base64enc (0.1-3-3) ... 369s Setting up r-cran-yaml (2.3.8-2) ... 369s Setting up r-cran-evaluate (0.23-1) ... 369s Setting up r-cran-highr (0.10+dfsg-2) ... 369s Setting up r-cran-fansi (1.0.5-1) ... 369s Setting up r-cran-mass (7.3-60.2-1) ... 369s Setting up r-cran-glue (1.7.0-1) ... 369s Setting up r-cran-cli (3.6.2-1) ... 369s Setting up gfortran (4:13.2.0-7ubuntu1) ... 369s update-alternatives: using /usr/bin/gfortran to provide /usr/bin/f95 (f95) in auto mode 369s update-alternatives: warning: skip creation of /usr/share/man/man1/f95.1.gz because associated file /usr/share/man/man1/gfortran.1.gz (of link group f95) doesn't exist 369s update-alternatives: using /usr/bin/gfortran to provide /usr/bin/f77 (f77) in auto mode 369s update-alternatives: warning: skip creation of /usr/share/man/man1/f77.1.gz because associated file /usr/share/man/man1/gfortran.1.gz (of link group f77) doesn't exist 369s Setting up r-cran-lifecycle (1.0.4+dfsg-1) ... 369s Setting up r-cran-pkgconfig (2.0.3-2build1) ... 369s Setting up r-cran-utf8 (1.2.4-1) ... 369s Setting up r-cran-colorspace (2.1-0+dfsg-1) ... 369s Setting up r-cran-markdown (1.12+dfsg-2) ... 369s Setting up r-cran-rcolorbrewer (1.1-3-1build1) ... 369s Setting up r-cran-isoband (0.2.7-1) ... 369s Setting up r-cran-gtable (0.3.4+dfsg-1) ... 369s Setting up r-cran-matrix (1.6-5-1) ... 369s Setting up r-cran-knitr (1.46+dfsg-1) ... 369s Setting up r-cran-mgcv (1.9-1-1) ... 369s Setting up g++ (4:13.2.0-7ubuntu1) ... 369s update-alternatives: using /usr/bin/g++ to provide /usr/bin/c++ (c++) in auto mode 369s Setting up build-essential (12.10ubuntu1) ... 369s Setting up r-cran-vctrs (0.6.5-1) ... 369s Setting up r-cran-pillar (1.9.0+dfsg-1) ... 369s Setting up r-base-dev (4.4.0-2) ... 369s Setting up r-cran-munsell (0.5.0-2build1) ... 369s Setting up r-cran-tibble (3.2.1+dfsg-2) ... 369s Setting up r-cran-scales (1.3.0-1) ... 369s Setting up pkg-r-autopkgtest (20231212ubuntu1) ... 369s Setting up r-cran-ggplot2 (3.5.1+dfsg-1) ... 369s Setting up autopkgtest-satdep (0) ... 369s Processing triggers for man-db (2.12.1-1) ... 371s Processing triggers for install-info (7.1-3build2) ... 371s Processing triggers for libc-bin (2.39-0ubuntu8.1) ... 375s (Reading database ... 86897 files and directories currently installed.) 375s Removing autopkgtest-satdep (0) ... 378s autopkgtest [09:46:08]: test pkg-r-autopkgtest: /usr/share/dh-r/pkg-r-autopkgtest 378s autopkgtest [09:46:08]: test pkg-r-autopkgtest: [----------------------- 378s Test: Try to load the R library matrixStats 378s 378s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 378s Copyright (C) 2024 The R Foundation for Statistical Computing 378s Platform: x86_64-pc-linux-gnu 378s 378s R is free software and comes with ABSOLUTELY NO WARRANTY. 378s You are welcome to redistribute it under certain conditions. 378s Type 'license()' or 'licence()' for distribution details. 378s 378s R is a collaborative project with many contributors. 378s Type 'contributors()' for more information and 378s 'citation()' on how to cite R or R packages in publications. 378s 378s Type 'demo()' for some demos, 'help()' for on-line help, or 378s 'help.start()' for an HTML browser interface to help. 378s Type 'q()' to quit R. 378s 378s > library('matrixStats') 378s > 378s > 378s Other tests are currently unsupported! 378s They will be progressively added. 378s autopkgtest [09:46:08]: test pkg-r-autopkgtest: -----------------------] 379s pkg-r-autopkgtest PASS 379s autopkgtest [09:46:09]: test pkg-r-autopkgtest: - - - - - - - - - - results - - - - - - - - - - 379s autopkgtest [09:46:09]: @@@@@@@@@@@@@@@@@@@@ summary 379s run-unit-test PASS 379s pkg-r-autopkgtest PASS 407s flock: timeout while waiting to get lock 407s Creating nova instance adt-oracular-amd64-r-cran-matrixstats-20240524-093950-juju-7f2275-prod-proposed-migration-environment-2-12bdd5f9-b656-478a-837e-faf2674679ec from image adt/ubuntu-oracular-amd64-server-20240524.img (UUID bfc0849f-cb68-4883-a64a-ae724e062cdb)... 407s Creating nova instance adt-oracular-amd64-r-cran-matrixstats-20240524-093950-juju-7f2275-prod-proposed-migration-environment-2-12bdd5f9-b656-478a-837e-faf2674679ec from image adt/ubuntu-oracular-amd64-server-20240524.img (UUID bfc0849f-cb68-4883-a64a-ae724e062cdb)...