0s autopkgtest [16:19:31]: starting date and time: 2025-03-15 16:19:31+0000 0s autopkgtest [16:19:31]: git checkout: 325255d2 Merge branch 'pin-any-arch' into 'ubuntu/production' 0s autopkgtest [16:19:31]: host juju-7f2275-prod-proposed-migration-environment-9; command line: /home/ubuntu/autopkgtest/runner/autopkgtest --output-dir /tmp/autopkgtest-work.3wvvyxs7/out --timeout-copy=6000 --setup-commands 'ln -s /dev/null /etc/systemd/system/bluetooth.service; printf "http_proxy=http://squid.internal:3128\nhttps_proxy=http://squid.internal:3128\nno_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,radosgw.ps5.canonical.com\n" >> /etc/environment' --apt-pocket=proposed=src:glibc --apt-upgrade r-cran-matrixstats --timeout-short=300 --timeout-copy=20000 --timeout-build=20000 --env=ADT_TEST_TRIGGERS=glibc/2.41-1ubuntu2 -- lxd -r lxd-armhf-10.145.243.141 lxd-armhf-10.145.243.141:autopkgtest/ubuntu/plucky/armhf 22s autopkgtest [16:19:53]: testbed dpkg architecture: armhf 23s autopkgtest [16:19:54]: testbed apt version: 2.9.33 27s autopkgtest [16:19:58]: @@@@@@@@@@@@@@@@@@@@ test bed setup 29s autopkgtest [16:20:00]: testbed release detected to be: None 38s autopkgtest [16:20:09]: updating testbed package index (apt update) 40s Get:1 http://ftpmaster.internal/ubuntu plucky-proposed InRelease [126 kB] 41s Get:2 http://ftpmaster.internal/ubuntu plucky InRelease [257 kB] 41s Get:3 http://ftpmaster.internal/ubuntu plucky-updates InRelease [126 kB] 41s Get:4 http://ftpmaster.internal/ubuntu plucky-security InRelease [126 kB] 41s Get:5 http://ftpmaster.internal/ubuntu plucky-proposed/multiverse Sources [15.8 kB] 41s Get:6 http://ftpmaster.internal/ubuntu plucky-proposed/main Sources [99.7 kB] 42s Get:7 http://ftpmaster.internal/ubuntu plucky-proposed/universe Sources [379 kB] 42s Get:8 http://ftpmaster.internal/ubuntu plucky-proposed/main armhf Packages [114 kB] 42s Get:9 http://ftpmaster.internal/ubuntu plucky-proposed/main armhf c-n-f Metadata [1832 B] 42s Get:10 http://ftpmaster.internal/ubuntu plucky-proposed/restricted armhf c-n-f Metadata [116 B] 42s Get:11 http://ftpmaster.internal/ubuntu plucky-proposed/universe armhf Packages [312 kB] 42s Get:12 http://ftpmaster.internal/ubuntu plucky-proposed/universe armhf c-n-f Metadata [11.1 kB] 42s Get:13 http://ftpmaster.internal/ubuntu plucky-proposed/multiverse armhf Packages [3472 B] 42s Get:14 http://ftpmaster.internal/ubuntu plucky-proposed/multiverse armhf c-n-f Metadata [240 B] 42s Get:15 http://ftpmaster.internal/ubuntu plucky/main Sources [1394 kB] 44s Get:16 http://ftpmaster.internal/ubuntu plucky/multiverse Sources [299 kB] 44s Get:17 http://ftpmaster.internal/ubuntu plucky/universe Sources [21.0 MB] 64s Get:18 http://ftpmaster.internal/ubuntu plucky/main armhf Packages [1378 kB] 66s Get:19 http://ftpmaster.internal/ubuntu plucky/main armhf c-n-f Metadata [29.4 kB] 66s Get:20 http://ftpmaster.internal/ubuntu plucky/restricted armhf c-n-f Metadata [108 B] 66s Get:21 http://ftpmaster.internal/ubuntu plucky/universe armhf Packages [15.1 MB] 83s Get:22 http://ftpmaster.internal/ubuntu plucky/multiverse armhf Packages [172 kB] 85s Fetched 41.0 MB in 45s (914 kB/s) 86s Reading package lists... 92s autopkgtest [16:21:03]: upgrading testbed (apt dist-upgrade and autopurge) 94s Reading package lists... 94s Building dependency tree... 94s Reading state information... 95s Calculating upgrade...Starting pkgProblemResolver with broken count: 0 95s Starting 2 pkgProblemResolver with broken count: 0 95s Done 96s Entering ResolveByKeep 96s 96s Calculating upgrade... 97s The following packages will be upgraded: 97s libc-bin libc6 locales pinentry-curses python3-jinja2 sos strace 97s 7 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 97s Need to get 8683 kB of archives. 97s After this operation, 23.6 kB of additional disk space will be used. 97s Get:1 http://ftpmaster.internal/ubuntu plucky-proposed/main armhf libc6 armhf 2.41-1ubuntu2 [2932 kB] 101s Get:2 http://ftpmaster.internal/ubuntu plucky-proposed/main armhf libc-bin armhf 2.41-1ubuntu2 [545 kB] 101s Get:3 http://ftpmaster.internal/ubuntu plucky-proposed/main armhf locales all 2.41-1ubuntu2 [4246 kB] 107s Get:4 http://ftpmaster.internal/ubuntu plucky/main armhf strace armhf 6.13+ds-1ubuntu1 [445 kB] 107s Get:5 http://ftpmaster.internal/ubuntu plucky/main armhf pinentry-curses armhf 1.3.1-2ubuntu3 [40.6 kB] 107s Get:6 http://ftpmaster.internal/ubuntu plucky/main armhf python3-jinja2 all 3.1.5-2ubuntu1 [109 kB] 107s Get:7 http://ftpmaster.internal/ubuntu plucky/main armhf sos all 4.9.0-5 [365 kB] 108s Preconfiguring packages ... 108s Fetched 8683 kB in 11s (803 kB/s) 108s (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 ... 64655 files and directories currently installed.) 108s Preparing to unpack .../libc6_2.41-1ubuntu2_armhf.deb ... 109s Unpacking libc6:armhf (2.41-1ubuntu2) over (2.41-1ubuntu1) ... 109s Setting up libc6:armhf (2.41-1ubuntu2) ... 109s (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 ... 64655 files and directories currently installed.) 109s Preparing to unpack .../libc-bin_2.41-1ubuntu2_armhf.deb ... 109s Unpacking libc-bin (2.41-1ubuntu2) over (2.41-1ubuntu1) ... 109s Setting up libc-bin (2.41-1ubuntu2) ... 110s (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 ... 64655 files and directories currently installed.) 110s Preparing to unpack .../locales_2.41-1ubuntu2_all.deb ... 110s Unpacking locales (2.41-1ubuntu2) over (2.41-1ubuntu1) ... 110s Preparing to unpack .../strace_6.13+ds-1ubuntu1_armhf.deb ... 110s Unpacking strace (6.13+ds-1ubuntu1) over (6.11-0ubuntu1) ... 110s Preparing to unpack .../pinentry-curses_1.3.1-2ubuntu3_armhf.deb ... 110s Unpacking pinentry-curses (1.3.1-2ubuntu3) over (1.3.1-2ubuntu2) ... 110s Preparing to unpack .../python3-jinja2_3.1.5-2ubuntu1_all.deb ... 110s Unpacking python3-jinja2 (3.1.5-2ubuntu1) over (3.1.5-2) ... 110s Preparing to unpack .../archives/sos_4.9.0-5_all.deb ... 110s Unpacking sos (4.9.0-5) over (4.9.0-4) ... 110s Setting up sos (4.9.0-5) ... 111s Setting up pinentry-curses (1.3.1-2ubuntu3) ... 111s Setting up locales (2.41-1ubuntu2) ... 112s Generating locales (this might take a while)... 114s en_US.UTF-8... done 114s Generation complete. 115s Setting up python3-jinja2 (3.1.5-2ubuntu1) ... 115s Setting up strace (6.13+ds-1ubuntu1) ... 115s Processing triggers for man-db (2.13.0-1) ... 117s Processing triggers for systemd (257.3-1ubuntu3) ... 119s Reading package lists... 119s Building dependency tree... 119s Reading state information... 120s Starting pkgProblemResolver with broken count: 0 120s Starting 2 pkgProblemResolver with broken count: 0 120s Done 120s Solving dependencies... 121s 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 123s autopkgtest [16:21:34]: rebooting testbed after setup commands that affected boot 164s autopkgtest [16:22:15]: testbed running kernel: Linux 6.8.0-52-generic #53~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Jan 15 18:10:51 UTC 2 188s autopkgtest [16:22:39]: @@@@@@@@@@@@@@@@@@@@ apt-source r-cran-matrixstats 198s Get:1 http://ftpmaster.internal/ubuntu plucky/universe r-cran-matrixstats 1.5.0-1 (dsc) [2228 B] 198s Get:2 http://ftpmaster.internal/ubuntu plucky/universe r-cran-matrixstats 1.5.0-1 (tar) [212 kB] 198s Get:3 http://ftpmaster.internal/ubuntu plucky/universe r-cran-matrixstats 1.5.0-1 (diff) [4864 B] 198s gpgv: Signature made Sat Jan 18 11:46:01 2025 UTC 198s gpgv: using RSA key 724D609337113C710550D7473C26763F6C67E6E2 198s gpgv: Can't check signature: No public key 198s dpkg-source: warning: cannot verify inline signature for ./r-cran-matrixstats_1.5.0-1.dsc: no acceptable signature found 199s autopkgtest [16:22:50]: testing package r-cran-matrixstats version 1.5.0-1 201s autopkgtest [16:22:52]: build not needed 204s autopkgtest [16:22:55]: test run-unit-test: preparing testbed 206s Reading package lists... 206s Building dependency tree... 206s Reading state information... 207s Starting pkgProblemResolver with broken count: 0 207s Starting 2 pkgProblemResolver with broken count: 0 207s Done 208s The following NEW packages will be installed: 208s fontconfig fontconfig-config fonts-dejavu-core fonts-dejavu-mono 208s fonts-glyphicons-halflings fonts-mathjax libblas3 libcairo2 libdatrie1 208s libdeflate0 libfontconfig1 libfreetype6 libgfortran5 libgomp1 libgraphite2-3 208s libharfbuzz0b libice6 libjbig0 libjpeg-turbo8 libjpeg8 libjs-bootstrap 208s libjs-highlight.js libjs-jquery libjs-jquery-datatables libjs-mathjax 208s liblapack3 liblerc4 libpango-1.0-0 libpangocairo-1.0-0 libpangoft2-1.0-0 208s libpaper-utils libpaper2 libpixman-1-0 libsharpyuv0 libsm6 libtcl8.6 208s libthai-data libthai0 libtiff6 libtk8.6 libwebp7 libxcb-render0 libxcb-shm0 208s libxft2 libxrender1 libxss1 libxt6t64 node-normalize.css r-base-core 208s r-cran-base64enc r-cran-cli r-cran-colorspace r-cran-commonmark 208s r-cran-digest r-cran-evaluate r-cran-fansi r-cran-farver r-cran-ggplot2 208s r-cran-glue r-cran-gtable r-cran-highr r-cran-isoband r-cran-knitr 208s r-cran-labeling r-cran-lattice r-cran-lifecycle r-cran-magrittr 208s r-cran-markdown r-cran-mass r-cran-matrix r-cran-matrixstats r-cran-mgcv 208s r-cran-microbenchmark r-cran-munsell r-cran-nlme r-cran-pillar 208s r-cran-pkgconfig r-cran-r.cache r-cran-r.devices r-cran-r.methodss3 208s r-cran-r.oo r-cran-r.rsp r-cran-r.utils r-cran-r6 r-cran-rcolorbrewer 208s r-cran-rlang r-cran-scales r-cran-tibble r-cran-utf8 r-cran-vctrs 208s r-cran-viridislite r-cran-withr r-cran-xfun r-cran-yaml tcl tcl8.6 unzip 208s x11-common xdg-utils zip 208s 0 upgraded, 100 newly installed, 0 to remove and 0 not upgraded. 208s Need to get 83.1 MB of archives. 208s After this operation, 179 MB of additional disk space will be used. 208s Get:1 http://ftpmaster.internal/ubuntu plucky/main armhf libfreetype6 armhf 2.13.3+dfsg-1 [330 kB] 209s Get:2 http://ftpmaster.internal/ubuntu plucky/main armhf fonts-dejavu-mono all 2.37-8 [502 kB] 209s Get:3 http://ftpmaster.internal/ubuntu plucky/main armhf fonts-dejavu-core all 2.37-8 [835 kB] 210s Get:4 http://ftpmaster.internal/ubuntu plucky/main armhf fontconfig-config armhf 2.15.0-2ubuntu1 [37.5 kB] 210s Get:5 http://ftpmaster.internal/ubuntu plucky/main armhf libfontconfig1 armhf 2.15.0-2ubuntu1 [114 kB] 210s Get:6 http://ftpmaster.internal/ubuntu plucky/main armhf fontconfig armhf 2.15.0-2ubuntu1 [190 kB] 210s Get:7 http://ftpmaster.internal/ubuntu plucky/universe armhf fonts-glyphicons-halflings all 1.009~3.4.1+dfsg-3 [118 kB] 211s Get:8 http://ftpmaster.internal/ubuntu plucky/main armhf fonts-mathjax all 2.7.9+dfsg-1 [2208 kB] 213s Get:9 http://ftpmaster.internal/ubuntu plucky/main armhf libblas3 armhf 3.12.1-2 [132 kB] 214s Get:10 http://ftpmaster.internal/ubuntu plucky/main armhf libpixman-1-0 armhf 0.44.0-3 [183 kB] 214s Get:11 http://ftpmaster.internal/ubuntu plucky/main armhf libxcb-render0 armhf 1.17.0-2 [15.3 kB] 214s Get:12 http://ftpmaster.internal/ubuntu plucky/main armhf libxcb-shm0 armhf 1.17.0-2 [5774 B] 214s Get:13 http://ftpmaster.internal/ubuntu plucky/main armhf libxrender1 armhf 1:0.9.10-1.1build1 [16.0 kB] 214s Get:14 http://ftpmaster.internal/ubuntu plucky/main armhf libcairo2 armhf 1.18.2-2 [484 kB] 214s Get:15 http://ftpmaster.internal/ubuntu plucky/main armhf libdatrie1 armhf 0.2.13-3build1 [15.7 kB] 214s Get:16 http://ftpmaster.internal/ubuntu plucky/main armhf libdeflate0 armhf 1.23-1 [38.5 kB] 214s Get:17 http://ftpmaster.internal/ubuntu plucky/main armhf libgfortran5 armhf 15-20250222-0ubuntu1 [330 kB] 215s Get:18 http://ftpmaster.internal/ubuntu plucky/main armhf libgomp1 armhf 15-20250222-0ubuntu1 [128 kB] 215s Get:19 http://ftpmaster.internal/ubuntu plucky/main armhf libgraphite2-3 armhf 1.3.14-2ubuntu1 [64.8 kB] 215s Get:20 http://ftpmaster.internal/ubuntu plucky/main armhf libharfbuzz0b armhf 10.2.0-1 [464 kB] 215s Get:21 http://ftpmaster.internal/ubuntu plucky/main armhf x11-common all 1:7.7+23ubuntu3 [21.7 kB] 215s Get:22 http://ftpmaster.internal/ubuntu plucky/main armhf libice6 armhf 2:1.1.1-1 [36.5 kB] 215s Get:23 http://ftpmaster.internal/ubuntu plucky/main armhf libjpeg-turbo8 armhf 2.1.5-3ubuntu2 [127 kB] 216s Get:24 http://ftpmaster.internal/ubuntu plucky/main armhf libjpeg8 armhf 8c-2ubuntu11 [2148 B] 216s Get:25 http://ftpmaster.internal/ubuntu plucky/universe armhf libjs-bootstrap all 3.4.1+dfsg-3 [129 kB] 216s Get:26 http://ftpmaster.internal/ubuntu plucky/universe armhf libjs-highlight.js all 9.18.5+dfsg1-2 [385 kB] 216s Get:27 http://ftpmaster.internal/ubuntu plucky/main armhf libjs-jquery all 3.6.1+dfsg+~3.5.14-1 [328 kB] 216s Get:28 http://ftpmaster.internal/ubuntu plucky/universe armhf libjs-jquery-datatables all 1.11.5+dfsg-2 [146 kB] 217s Get:29 http://ftpmaster.internal/ubuntu plucky/main armhf liblapack3 armhf 3.12.1-2 [2091 kB] 219s Get:30 http://ftpmaster.internal/ubuntu plucky/main armhf liblerc4 armhf 4.0.0+ds-5ubuntu1 [160 kB] 219s Get:31 http://ftpmaster.internal/ubuntu plucky/main armhf libthai-data all 0.1.29-2build1 [158 kB] 219s Get:32 http://ftpmaster.internal/ubuntu plucky/main armhf libthai0 armhf 0.1.29-2build1 [15.2 kB] 219s Get:33 http://ftpmaster.internal/ubuntu plucky/main armhf libpango-1.0-0 armhf 1.56.2-1 [216 kB] 219s Get:34 http://ftpmaster.internal/ubuntu plucky/main armhf libpangoft2-1.0-0 armhf 1.56.2-1 [43.6 kB] 220s Get:35 http://ftpmaster.internal/ubuntu plucky/main armhf libpangocairo-1.0-0 armhf 1.56.2-1 [25.1 kB] 220s Get:36 http://ftpmaster.internal/ubuntu plucky/main armhf libpaper2 armhf 2.2.5-0.3 [16.3 kB] 220s Get:37 http://ftpmaster.internal/ubuntu plucky/main armhf libpaper-utils armhf 2.2.5-0.3 [14.2 kB] 220s Get:38 http://ftpmaster.internal/ubuntu plucky/main armhf libsharpyuv0 armhf 1.5.0-0.1 [16.4 kB] 220s Get:39 http://ftpmaster.internal/ubuntu plucky/main armhf libsm6 armhf 2:1.2.4-1 [15.1 kB] 220s Get:40 http://ftpmaster.internal/ubuntu plucky/main armhf libtcl8.6 armhf 8.6.16+dfsg-1 [909 kB] 221s Get:41 http://ftpmaster.internal/ubuntu plucky/main armhf libjbig0 armhf 2.1-6.1ubuntu2 [24.9 kB] 221s Get:42 http://ftpmaster.internal/ubuntu plucky/main armhf libwebp7 armhf 1.5.0-0.1 [188 kB] 221s Get:43 http://ftpmaster.internal/ubuntu plucky/main armhf libtiff6 armhf 4.5.1+git230720-4ubuntu4 [179 kB] 221s Get:44 http://ftpmaster.internal/ubuntu plucky/main armhf libxft2 armhf 2.3.6-1build1 [37.4 kB] 221s Get:45 http://ftpmaster.internal/ubuntu plucky/main armhf libxss1 armhf 1:1.2.3-1build3 [6500 B] 221s Get:46 http://ftpmaster.internal/ubuntu plucky/main armhf libtk8.6 armhf 8.6.16-1 [686 kB] 222s Get:47 http://ftpmaster.internal/ubuntu plucky/main armhf libxt6t64 armhf 1:1.2.1-1.2build1 [145 kB] 222s Get:48 http://ftpmaster.internal/ubuntu plucky/universe armhf node-normalize.css all 8.0.1-5 [10.8 kB] 222s Get:49 http://ftpmaster.internal/ubuntu plucky/main armhf zip armhf 3.0-14ubuntu2 [164 kB] 222s Get:50 http://ftpmaster.internal/ubuntu plucky/main armhf unzip armhf 6.0-28ubuntu6 [167 kB] 223s Get:51 http://ftpmaster.internal/ubuntu plucky/main armhf xdg-utils all 1.2.1-2ubuntu1 [66.0 kB] 223s Get:52 http://ftpmaster.internal/ubuntu plucky/universe armhf r-base-core armhf 4.4.3-1 [28.2 MB] 255s Get:53 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-base64enc armhf 0.1-3-3 [27.3 kB] 255s Get:54 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-cli armhf 3.6.4-1 [1377 kB] 256s Get:55 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-colorspace armhf 2.1-1+dfsg-1 [1561 kB] 258s Get:56 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-commonmark armhf 1.9.2-2 [112 kB] 258s Get:57 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-digest armhf 0.6.37-1 [207 kB] 259s Get:58 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-evaluate all 1.0.3-1 [114 kB] 259s Get:59 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-fansi armhf 1.0.5-1 [611 kB] 259s Get:60 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-farver armhf 2.1.2-1 [1355 kB] 261s Get:61 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-glue armhf 1.8.0-1 [162 kB] 261s Get:62 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-rlang armhf 1.1.5-1 [1701 kB] 263s Get:63 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-lifecycle all 1.0.4+dfsg-1 [110 kB] 263s Get:64 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-gtable all 0.3.6+dfsg-1 [199 kB] 264s Get:65 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-isoband armhf 0.2.7-1 [1477 kB] 265s Get:66 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-mass armhf 7.3-64-1 [1105 kB] 267s Get:67 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-lattice armhf 0.22-6-1 [1363 kB] 268s Get:68 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-nlme armhf 3.1.167-1 [2306 kB] 271s Get:69 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-matrix armhf 1.7-3-1 [4039 kB] 276s Get:70 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-mgcv armhf 1.9-1-1 [3205 kB] 279s Get:71 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-labeling all 0.4.3-1 [62.1 kB] 279s Get:72 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-munsell all 0.5.1-1 [213 kB] 280s Get:73 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-r6 all 2.6.1-1 [101 kB] 280s Get:74 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-rcolorbrewer all 1.1-3-1build1 [55.4 kB] 280s Get:75 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-viridislite all 0.4.2-2 [1088 kB] 282s Get:76 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-scales all 1.3.0-1 [603 kB] 282s Get:77 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-magrittr armhf 2.0.3-1 [154 kB] 282s Get:78 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-utf8 armhf 1.2.4-1 [136 kB] 283s Get:79 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-vctrs armhf 0.6.5-1 [1310 kB] 284s Get:80 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-pillar all 1.10.1+dfsg-1 [453 kB] 285s Get:81 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-pkgconfig all 2.0.3-2build1 [19.7 kB] 285s Get:82 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-tibble armhf 3.2.1+dfsg-3 [420 kB] 285s Get:83 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-withr all 3.0.2+dfsg-1 [214 kB] 286s Get:84 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-ggplot2 all 3.5.1+dfsg-1 [3940 kB] 290s Get:85 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-xfun armhf 0.51+dfsg-1 [573 kB] 291s Get:86 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-highr all 0.11+dfsg-1 [38.5 kB] 291s Get:87 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-yaml armhf 2.3.10-1 [101 kB] 291s Get:88 http://ftpmaster.internal/ubuntu plucky/main armhf libjs-mathjax all 2.7.9+dfsg-1 [5665 kB] 298s Get:89 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-knitr all 1.49+dfsg-1 [859 kB] 299s Get:90 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-markdown all 1.13-1 [162 kB] 299s Get:91 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-matrixstats armhf 1.5.0-1 [495 kB] 300s Get:92 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-microbenchmark armhf 1.5.0-1 [67.8 kB] 300s Get:93 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-r.methodss3 all 1.8.2-1 [84.0 kB] 300s Get:94 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-r.oo all 1.27.0-1 [979 kB] 301s Get:95 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-r.utils all 2.13.0-1 [1423 kB] 303s Get:96 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-r.cache all 0.16.0-1 [113 kB] 303s Get:97 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-r.devices all 2.17.2+ds-1 [398 kB] 304s Get:98 http://ftpmaster.internal/ubuntu plucky/main armhf tcl8.6 armhf 8.6.16+dfsg-1 [14.6 kB] 304s Get:99 http://ftpmaster.internal/ubuntu plucky/main armhf tcl armhf 8.6.14build1 [4124 B] 304s Get:100 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-r.rsp all 0.46.0+ds-1 [1412 kB] 306s Preconfiguring packages ... 307s Fetched 83.1 MB in 1min 38s (851 kB/s) 307s Selecting previously unselected package libfreetype6:armhf. 307s (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 ... 64655 files and directories currently installed.) 307s Preparing to unpack .../00-libfreetype6_2.13.3+dfsg-1_armhf.deb ... 307s Unpacking libfreetype6:armhf (2.13.3+dfsg-1) ... 307s Selecting previously unselected package fonts-dejavu-mono. 307s Preparing to unpack .../01-fonts-dejavu-mono_2.37-8_all.deb ... 307s Unpacking fonts-dejavu-mono (2.37-8) ... 307s Selecting previously unselected package fonts-dejavu-core. 307s Preparing to unpack .../02-fonts-dejavu-core_2.37-8_all.deb ... 307s Unpacking fonts-dejavu-core (2.37-8) ... 307s Selecting previously unselected package fontconfig-config. 307s Preparing to unpack .../03-fontconfig-config_2.15.0-2ubuntu1_armhf.deb ... 307s Unpacking fontconfig-config (2.15.0-2ubuntu1) ... 307s Selecting previously unselected package libfontconfig1:armhf. 307s Preparing to unpack .../04-libfontconfig1_2.15.0-2ubuntu1_armhf.deb ... 307s Unpacking libfontconfig1:armhf (2.15.0-2ubuntu1) ... 307s Selecting previously unselected package fontconfig. 307s Preparing to unpack .../05-fontconfig_2.15.0-2ubuntu1_armhf.deb ... 307s Unpacking fontconfig (2.15.0-2ubuntu1) ... 307s Selecting previously unselected package fonts-glyphicons-halflings. 307s Preparing to unpack .../06-fonts-glyphicons-halflings_1.009~3.4.1+dfsg-3_all.deb ... 307s Unpacking fonts-glyphicons-halflings (1.009~3.4.1+dfsg-3) ... 307s Selecting previously unselected package fonts-mathjax. 307s Preparing to unpack .../07-fonts-mathjax_2.7.9+dfsg-1_all.deb ... 307s Unpacking fonts-mathjax (2.7.9+dfsg-1) ... 307s Selecting previously unselected package libblas3:armhf. 308s Preparing to unpack .../08-libblas3_3.12.1-2_armhf.deb ... 308s Unpacking libblas3:armhf (3.12.1-2) ... 308s Selecting previously unselected package libpixman-1-0:armhf. 308s Preparing to unpack .../09-libpixman-1-0_0.44.0-3_armhf.deb ... 308s Unpacking libpixman-1-0:armhf (0.44.0-3) ... 308s Selecting previously unselected package libxcb-render0:armhf. 308s Preparing to unpack .../10-libxcb-render0_1.17.0-2_armhf.deb ... 308s Unpacking libxcb-render0:armhf (1.17.0-2) ... 308s Selecting previously unselected package libxcb-shm0:armhf. 308s Preparing to unpack .../11-libxcb-shm0_1.17.0-2_armhf.deb ... 308s Unpacking libxcb-shm0:armhf (1.17.0-2) ... 308s Selecting previously unselected package libxrender1:armhf. 308s Preparing to unpack .../12-libxrender1_1%3a0.9.10-1.1build1_armhf.deb ... 308s Unpacking libxrender1:armhf (1:0.9.10-1.1build1) ... 308s Selecting previously unselected package libcairo2:armhf. 308s Preparing to unpack .../13-libcairo2_1.18.2-2_armhf.deb ... 308s Unpacking libcairo2:armhf (1.18.2-2) ... 308s Selecting previously unselected package libdatrie1:armhf. 308s Preparing to unpack .../14-libdatrie1_0.2.13-3build1_armhf.deb ... 308s Unpacking libdatrie1:armhf (0.2.13-3build1) ... 308s Selecting previously unselected package libdeflate0:armhf. 308s Preparing to unpack .../15-libdeflate0_1.23-1_armhf.deb ... 308s Unpacking libdeflate0:armhf (1.23-1) ... 308s Selecting previously unselected package libgfortran5:armhf. 308s Preparing to unpack .../16-libgfortran5_15-20250222-0ubuntu1_armhf.deb ... 308s Unpacking libgfortran5:armhf (15-20250222-0ubuntu1) ... 308s Selecting previously unselected package libgomp1:armhf. 308s Preparing to unpack .../17-libgomp1_15-20250222-0ubuntu1_armhf.deb ... 308s Unpacking libgomp1:armhf (15-20250222-0ubuntu1) ... 308s Selecting previously unselected package libgraphite2-3:armhf. 308s Preparing to unpack .../18-libgraphite2-3_1.3.14-2ubuntu1_armhf.deb ... 308s Unpacking libgraphite2-3:armhf (1.3.14-2ubuntu1) ... 308s Selecting previously unselected package libharfbuzz0b:armhf. 308s Preparing to unpack .../19-libharfbuzz0b_10.2.0-1_armhf.deb ... 308s Unpacking libharfbuzz0b:armhf (10.2.0-1) ... 308s Selecting previously unselected package x11-common. 308s Preparing to unpack .../20-x11-common_1%3a7.7+23ubuntu3_all.deb ... 308s Unpacking x11-common (1:7.7+23ubuntu3) ... 308s Selecting previously unselected package libice6:armhf. 308s Preparing to unpack .../21-libice6_2%3a1.1.1-1_armhf.deb ... 308s Unpacking libice6:armhf (2:1.1.1-1) ... 308s Selecting previously unselected package libjpeg-turbo8:armhf. 308s Preparing to unpack .../22-libjpeg-turbo8_2.1.5-3ubuntu2_armhf.deb ... 308s Unpacking libjpeg-turbo8:armhf (2.1.5-3ubuntu2) ... 309s Selecting previously unselected package libjpeg8:armhf. 309s Preparing to unpack .../23-libjpeg8_8c-2ubuntu11_armhf.deb ... 309s Unpacking libjpeg8:armhf (8c-2ubuntu11) ... 309s Selecting previously unselected package libjs-bootstrap. 309s Preparing to unpack .../24-libjs-bootstrap_3.4.1+dfsg-3_all.deb ... 309s Unpacking libjs-bootstrap (3.4.1+dfsg-3) ... 309s Selecting previously unselected package libjs-highlight.js. 309s Preparing to unpack .../25-libjs-highlight.js_9.18.5+dfsg1-2_all.deb ... 309s Unpacking libjs-highlight.js (9.18.5+dfsg1-2) ... 309s Selecting previously unselected package libjs-jquery. 309s Preparing to unpack .../26-libjs-jquery_3.6.1+dfsg+~3.5.14-1_all.deb ... 309s Unpacking libjs-jquery (3.6.1+dfsg+~3.5.14-1) ... 309s Selecting previously unselected package libjs-jquery-datatables. 309s Preparing to unpack .../27-libjs-jquery-datatables_1.11.5+dfsg-2_all.deb ... 309s Unpacking libjs-jquery-datatables (1.11.5+dfsg-2) ... 309s Selecting previously unselected package liblapack3:armhf. 309s Preparing to unpack .../28-liblapack3_3.12.1-2_armhf.deb ... 309s Unpacking liblapack3:armhf (3.12.1-2) ... 309s Selecting previously unselected package liblerc4:armhf. 309s Preparing to unpack .../29-liblerc4_4.0.0+ds-5ubuntu1_armhf.deb ... 309s Unpacking liblerc4:armhf (4.0.0+ds-5ubuntu1) ... 309s Selecting previously unselected package libthai-data. 309s Preparing to unpack .../30-libthai-data_0.1.29-2build1_all.deb ... 309s Unpacking libthai-data (0.1.29-2build1) ... 309s Selecting previously unselected package libthai0:armhf. 309s Preparing to unpack .../31-libthai0_0.1.29-2build1_armhf.deb ... 309s Unpacking libthai0:armhf (0.1.29-2build1) ... 309s Selecting previously unselected package libpango-1.0-0:armhf. 309s Preparing to unpack .../32-libpango-1.0-0_1.56.2-1_armhf.deb ... 309s Unpacking libpango-1.0-0:armhf (1.56.2-1) ... 309s Selecting previously unselected package libpangoft2-1.0-0:armhf. 309s Preparing to unpack .../33-libpangoft2-1.0-0_1.56.2-1_armhf.deb ... 309s Unpacking libpangoft2-1.0-0:armhf (1.56.2-1) ... 309s Selecting previously unselected package libpangocairo-1.0-0:armhf. 309s Preparing to unpack .../34-libpangocairo-1.0-0_1.56.2-1_armhf.deb ... 309s Unpacking libpangocairo-1.0-0:armhf (1.56.2-1) ... 309s Selecting previously unselected package libpaper2:armhf. 309s Preparing to unpack .../35-libpaper2_2.2.5-0.3_armhf.deb ... 309s Unpacking libpaper2:armhf (2.2.5-0.3) ... 309s Selecting previously unselected package libpaper-utils. 309s Preparing to unpack .../36-libpaper-utils_2.2.5-0.3_armhf.deb ... 309s Unpacking libpaper-utils (2.2.5-0.3) ... 309s Selecting previously unselected package libsharpyuv0:armhf. 309s Preparing to unpack .../37-libsharpyuv0_1.5.0-0.1_armhf.deb ... 309s Unpacking libsharpyuv0:armhf (1.5.0-0.1) ... 309s Selecting previously unselected package libsm6:armhf. 309s Preparing to unpack .../38-libsm6_2%3a1.2.4-1_armhf.deb ... 309s Unpacking libsm6:armhf (2:1.2.4-1) ... 309s Selecting previously unselected package libtcl8.6:armhf. 309s Preparing to unpack .../39-libtcl8.6_8.6.16+dfsg-1_armhf.deb ... 309s Unpacking libtcl8.6:armhf (8.6.16+dfsg-1) ... 310s Selecting previously unselected package libjbig0:armhf. 310s Preparing to unpack .../40-libjbig0_2.1-6.1ubuntu2_armhf.deb ... 310s Unpacking libjbig0:armhf (2.1-6.1ubuntu2) ... 310s Selecting previously unselected package libwebp7:armhf. 310s Preparing to unpack .../41-libwebp7_1.5.0-0.1_armhf.deb ... 310s Unpacking libwebp7:armhf (1.5.0-0.1) ... 310s Selecting previously unselected package libtiff6:armhf. 310s Preparing to unpack .../42-libtiff6_4.5.1+git230720-4ubuntu4_armhf.deb ... 310s Unpacking libtiff6:armhf (4.5.1+git230720-4ubuntu4) ... 310s Selecting previously unselected package libxft2:armhf. 310s Preparing to unpack .../43-libxft2_2.3.6-1build1_armhf.deb ... 310s Unpacking libxft2:armhf (2.3.6-1build1) ... 310s Selecting previously unselected package libxss1:armhf. 310s Preparing to unpack .../44-libxss1_1%3a1.2.3-1build3_armhf.deb ... 310s Unpacking libxss1:armhf (1:1.2.3-1build3) ... 310s Selecting previously unselected package libtk8.6:armhf. 310s Preparing to unpack .../45-libtk8.6_8.6.16-1_armhf.deb ... 310s Unpacking libtk8.6:armhf (8.6.16-1) ... 310s Selecting previously unselected package libxt6t64:armhf. 310s Preparing to unpack .../46-libxt6t64_1%3a1.2.1-1.2build1_armhf.deb ... 310s Unpacking libxt6t64:armhf (1:1.2.1-1.2build1) ... 310s Selecting previously unselected package node-normalize.css. 310s Preparing to unpack .../47-node-normalize.css_8.0.1-5_all.deb ... 310s Unpacking node-normalize.css (8.0.1-5) ... 310s Selecting previously unselected package zip. 310s Preparing to unpack .../48-zip_3.0-14ubuntu2_armhf.deb ... 310s Unpacking zip (3.0-14ubuntu2) ... 310s Selecting previously unselected package unzip. 310s Preparing to unpack .../49-unzip_6.0-28ubuntu6_armhf.deb ... 310s Unpacking unzip (6.0-28ubuntu6) ... 310s Selecting previously unselected package xdg-utils. 310s Preparing to unpack .../50-xdg-utils_1.2.1-2ubuntu1_all.deb ... 310s Unpacking xdg-utils (1.2.1-2ubuntu1) ... 310s Selecting previously unselected package r-base-core. 310s Preparing to unpack .../51-r-base-core_4.4.3-1_armhf.deb ... 310s Unpacking r-base-core (4.4.3-1) ... 311s Selecting previously unselected package r-cran-base64enc. 311s Preparing to unpack .../52-r-cran-base64enc_0.1-3-3_armhf.deb ... 311s Unpacking r-cran-base64enc (0.1-3-3) ... 311s Selecting previously unselected package r-cran-cli. 311s Preparing to unpack .../53-r-cran-cli_3.6.4-1_armhf.deb ... 311s Unpacking r-cran-cli (3.6.4-1) ... 311s Selecting previously unselected package r-cran-colorspace. 311s Preparing to unpack .../54-r-cran-colorspace_2.1-1+dfsg-1_armhf.deb ... 311s Unpacking r-cran-colorspace (2.1-1+dfsg-1) ... 311s Selecting previously unselected package r-cran-commonmark. 311s Preparing to unpack .../55-r-cran-commonmark_1.9.2-2_armhf.deb ... 311s Unpacking r-cran-commonmark (1.9.2-2) ... 311s Selecting previously unselected package r-cran-digest. 311s Preparing to unpack .../56-r-cran-digest_0.6.37-1_armhf.deb ... 311s Unpacking r-cran-digest (0.6.37-1) ... 311s Selecting previously unselected package r-cran-evaluate. 311s Preparing to unpack .../57-r-cran-evaluate_1.0.3-1_all.deb ... 311s Unpacking r-cran-evaluate (1.0.3-1) ... 312s Selecting previously unselected package r-cran-fansi. 312s Preparing to unpack .../58-r-cran-fansi_1.0.5-1_armhf.deb ... 312s Unpacking r-cran-fansi (1.0.5-1) ... 312s Selecting previously unselected package r-cran-farver. 312s Preparing to unpack .../59-r-cran-farver_2.1.2-1_armhf.deb ... 312s Unpacking r-cran-farver (2.1.2-1) ... 312s Selecting previously unselected package r-cran-glue. 312s Preparing to unpack .../60-r-cran-glue_1.8.0-1_armhf.deb ... 312s Unpacking r-cran-glue (1.8.0-1) ... 312s Selecting previously unselected package r-cran-rlang. 312s Preparing to unpack .../61-r-cran-rlang_1.1.5-1_armhf.deb ... 312s Unpacking r-cran-rlang (1.1.5-1) ... 312s Selecting previously unselected package r-cran-lifecycle. 312s Preparing to unpack .../62-r-cran-lifecycle_1.0.4+dfsg-1_all.deb ... 312s Unpacking r-cran-lifecycle (1.0.4+dfsg-1) ... 312s Selecting previously unselected package r-cran-gtable. 312s Preparing to unpack .../63-r-cran-gtable_0.3.6+dfsg-1_all.deb ... 312s Unpacking r-cran-gtable (0.3.6+dfsg-1) ... 312s Selecting previously unselected package r-cran-isoband. 312s Preparing to unpack .../64-r-cran-isoband_0.2.7-1_armhf.deb ... 312s Unpacking r-cran-isoband (0.2.7-1) ... 312s Selecting previously unselected package r-cran-mass. 312s Preparing to unpack .../65-r-cran-mass_7.3-64-1_armhf.deb ... 312s Unpacking r-cran-mass (7.3-64-1) ... 312s Selecting previously unselected package r-cran-lattice. 312s Preparing to unpack .../66-r-cran-lattice_0.22-6-1_armhf.deb ... 312s Unpacking r-cran-lattice (0.22-6-1) ... 312s Selecting previously unselected package r-cran-nlme. 312s Preparing to unpack .../67-r-cran-nlme_3.1.167-1_armhf.deb ... 312s Unpacking r-cran-nlme (3.1.167-1) ... 312s Selecting previously unselected package r-cran-matrix. 312s Preparing to unpack .../68-r-cran-matrix_1.7-3-1_armhf.deb ... 312s Unpacking r-cran-matrix (1.7-3-1) ... 313s Selecting previously unselected package r-cran-mgcv. 313s Preparing to unpack .../69-r-cran-mgcv_1.9-1-1_armhf.deb ... 313s Unpacking r-cran-mgcv (1.9-1-1) ... 313s Selecting previously unselected package r-cran-labeling. 313s Preparing to unpack .../70-r-cran-labeling_0.4.3-1_all.deb ... 313s Unpacking r-cran-labeling (0.4.3-1) ... 313s Selecting previously unselected package r-cran-munsell. 313s Preparing to unpack .../71-r-cran-munsell_0.5.1-1_all.deb ... 313s Unpacking r-cran-munsell (0.5.1-1) ... 313s Selecting previously unselected package r-cran-r6. 313s Preparing to unpack .../72-r-cran-r6_2.6.1-1_all.deb ... 313s Unpacking r-cran-r6 (2.6.1-1) ... 313s Selecting previously unselected package r-cran-rcolorbrewer. 313s Preparing to unpack .../73-r-cran-rcolorbrewer_1.1-3-1build1_all.deb ... 313s Unpacking r-cran-rcolorbrewer (1.1-3-1build1) ... 313s Selecting previously unselected package r-cran-viridislite. 313s Preparing to unpack .../74-r-cran-viridislite_0.4.2-2_all.deb ... 313s Unpacking r-cran-viridislite (0.4.2-2) ... 313s Selecting previously unselected package r-cran-scales. 313s Preparing to unpack .../75-r-cran-scales_1.3.0-1_all.deb ... 313s Unpacking r-cran-scales (1.3.0-1) ... 313s Selecting previously unselected package r-cran-magrittr. 313s Preparing to unpack .../76-r-cran-magrittr_2.0.3-1_armhf.deb ... 313s Unpacking r-cran-magrittr (2.0.3-1) ... 313s Selecting previously unselected package r-cran-utf8. 313s Preparing to unpack .../77-r-cran-utf8_1.2.4-1_armhf.deb ... 313s Unpacking r-cran-utf8 (1.2.4-1) ... 313s Selecting previously unselected package r-cran-vctrs. 313s Preparing to unpack .../78-r-cran-vctrs_0.6.5-1_armhf.deb ... 313s Unpacking r-cran-vctrs (0.6.5-1) ... 313s Selecting previously unselected package r-cran-pillar. 313s Preparing to unpack .../79-r-cran-pillar_1.10.1+dfsg-1_all.deb ... 313s Unpacking r-cran-pillar (1.10.1+dfsg-1) ... 313s Selecting previously unselected package r-cran-pkgconfig. 313s Preparing to unpack .../80-r-cran-pkgconfig_2.0.3-2build1_all.deb ... 313s Unpacking r-cran-pkgconfig (2.0.3-2build1) ... 313s Selecting previously unselected package r-cran-tibble. 313s Preparing to unpack .../81-r-cran-tibble_3.2.1+dfsg-3_armhf.deb ... 313s Unpacking r-cran-tibble (3.2.1+dfsg-3) ... 313s Selecting previously unselected package r-cran-withr. 313s Preparing to unpack .../82-r-cran-withr_3.0.2+dfsg-1_all.deb ... 313s Unpacking r-cran-withr (3.0.2+dfsg-1) ... 314s Selecting previously unselected package r-cran-ggplot2. 314s Preparing to unpack .../83-r-cran-ggplot2_3.5.1+dfsg-1_all.deb ... 314s Unpacking r-cran-ggplot2 (3.5.1+dfsg-1) ... 314s Selecting previously unselected package r-cran-xfun. 314s Preparing to unpack .../84-r-cran-xfun_0.51+dfsg-1_armhf.deb ... 314s Unpacking r-cran-xfun (0.51+dfsg-1) ... 314s Selecting previously unselected package r-cran-highr. 314s Preparing to unpack .../85-r-cran-highr_0.11+dfsg-1_all.deb ... 314s Unpacking r-cran-highr (0.11+dfsg-1) ... 314s Selecting previously unselected package r-cran-yaml. 314s Preparing to unpack .../86-r-cran-yaml_2.3.10-1_armhf.deb ... 314s Unpacking r-cran-yaml (2.3.10-1) ... 314s Selecting previously unselected package libjs-mathjax. 314s Preparing to unpack .../87-libjs-mathjax_2.7.9+dfsg-1_all.deb ... 314s Unpacking libjs-mathjax (2.7.9+dfsg-1) ... 315s Selecting previously unselected package r-cran-knitr. 315s Preparing to unpack .../88-r-cran-knitr_1.49+dfsg-1_all.deb ... 315s Unpacking r-cran-knitr (1.49+dfsg-1) ... 315s Selecting previously unselected package r-cran-markdown. 315s Preparing to unpack .../89-r-cran-markdown_1.13-1_all.deb ... 315s Unpacking r-cran-markdown (1.13-1) ... 315s Selecting previously unselected package r-cran-matrixstats. 315s Preparing to unpack .../90-r-cran-matrixstats_1.5.0-1_armhf.deb ... 315s Unpacking r-cran-matrixstats (1.5.0-1) ... 315s Selecting previously unselected package r-cran-microbenchmark. 316s Preparing to unpack .../91-r-cran-microbenchmark_1.5.0-1_armhf.deb ... 316s Unpacking r-cran-microbenchmark (1.5.0-1) ... 316s Selecting previously unselected package r-cran-r.methodss3. 316s Preparing to unpack .../92-r-cran-r.methodss3_1.8.2-1_all.deb ... 316s Unpacking r-cran-r.methodss3 (1.8.2-1) ... 316s Selecting previously unselected package r-cran-r.oo. 316s Preparing to unpack .../93-r-cran-r.oo_1.27.0-1_all.deb ... 316s Unpacking r-cran-r.oo (1.27.0-1) ... 316s Selecting previously unselected package r-cran-r.utils. 316s Preparing to unpack .../94-r-cran-r.utils_2.13.0-1_all.deb ... 316s Unpacking r-cran-r.utils (2.13.0-1) ... 316s Selecting previously unselected package r-cran-r.cache. 316s Preparing to unpack .../95-r-cran-r.cache_0.16.0-1_all.deb ... 316s Unpacking r-cran-r.cache (0.16.0-1) ... 316s Selecting previously unselected package r-cran-r.devices. 316s Preparing to unpack .../96-r-cran-r.devices_2.17.2+ds-1_all.deb ... 316s Unpacking r-cran-r.devices (2.17.2+ds-1) ... 316s Selecting previously unselected package tcl8.6. 316s Preparing to unpack .../97-tcl8.6_8.6.16+dfsg-1_armhf.deb ... 316s Unpacking tcl8.6 (8.6.16+dfsg-1) ... 316s Selecting previously unselected package tcl. 316s Preparing to unpack .../98-tcl_8.6.14build1_armhf.deb ... 316s Unpacking tcl (8.6.14build1) ... 316s Selecting previously unselected package r-cran-r.rsp. 316s Preparing to unpack .../99-r-cran-r.rsp_0.46.0+ds-1_all.deb ... 316s Unpacking r-cran-r.rsp (0.46.0+ds-1) ... 316s Setting up libgraphite2-3:armhf (1.3.14-2ubuntu1) ... 316s Setting up libpixman-1-0:armhf (0.44.0-3) ... 316s Setting up libsharpyuv0:armhf (1.5.0-0.1) ... 316s Setting up fonts-mathjax (2.7.9+dfsg-1) ... 316s Setting up liblerc4:armhf (4.0.0+ds-5ubuntu1) ... 316s Setting up libjs-mathjax (2.7.9+dfsg-1) ... 316s Setting up libxrender1:armhf (1:0.9.10-1.1build1) ... 316s Setting up libdatrie1:armhf (0.2.13-3build1) ... 316s Setting up libxcb-render0:armhf (1.17.0-2) ... 316s Setting up fonts-glyphicons-halflings (1.009~3.4.1+dfsg-3) ... 316s Setting up unzip (6.0-28ubuntu6) ... 316s Setting up x11-common (1:7.7+23ubuntu3) ... 317s Setting up libdeflate0:armhf (1.23-1) ... 317s Setting up libxcb-shm0:armhf (1.17.0-2) ... 317s Setting up libgomp1:armhf (15-20250222-0ubuntu1) ... 317s Setting up libjbig0:armhf (2.1-6.1ubuntu2) ... 317s Setting up zip (3.0-14ubuntu2) ... 317s Setting up libblas3:armhf (3.12.1-2) ... 317s update-alternatives: using /usr/lib/arm-linux-gnueabihf/blas/libblas.so.3 to provide /usr/lib/arm-linux-gnueabihf/libblas.so.3 (libblas.so.3-arm-linux-gnueabihf) in auto mode 317s Setting up libfreetype6:armhf (2.13.3+dfsg-1) ... 317s Setting up fonts-dejavu-mono (2.37-8) ... 317s Setting up libtcl8.6:armhf (8.6.16+dfsg-1) ... 317s Setting up fonts-dejavu-core (2.37-8) ... 317s Setting up libjpeg-turbo8:armhf (2.1.5-3ubuntu2) ... 317s Setting up libgfortran5:armhf (15-20250222-0ubuntu1) ... 317s Setting up libwebp7:armhf (1.5.0-0.1) ... 317s Setting up libjs-highlight.js (9.18.5+dfsg1-2) ... 317s Setting up libharfbuzz0b:armhf (10.2.0-1) ... 317s Setting up libthai-data (0.1.29-2build1) ... 317s Setting up libxss1:armhf (1:1.2.3-1build3) ... 317s Setting up libpaper2:armhf (2.2.5-0.3) ... 317s Setting up libjs-jquery (3.6.1+dfsg+~3.5.14-1) ... 317s Setting up node-normalize.css (8.0.1-5) ... 317s Setting up xdg-utils (1.2.1-2ubuntu1) ... 317s update-alternatives: using /usr/bin/xdg-open to provide /usr/bin/open (open) in auto mode 317s Setting up libjs-bootstrap (3.4.1+dfsg-3) ... 317s Setting up libjpeg8:armhf (8c-2ubuntu11) ... 317s Setting up libice6:armhf (2:1.1.1-1) ... 317s Setting up tcl8.6 (8.6.16+dfsg-1) ... 317s Setting up liblapack3:armhf (3.12.1-2) ... 317s update-alternatives: using /usr/lib/arm-linux-gnueabihf/lapack/liblapack.so.3 to provide /usr/lib/arm-linux-gnueabihf/liblapack.so.3 (liblapack.so.3-arm-linux-gnueabihf) in auto mode 317s Setting up fontconfig-config (2.15.0-2ubuntu1) ... 318s Setting up libpaper-utils (2.2.5-0.3) ... 318s Setting up libjs-jquery-datatables (1.11.5+dfsg-2) ... 318s Setting up libthai0:armhf (0.1.29-2build1) ... 318s Setting up libtiff6:armhf (4.5.1+git230720-4ubuntu4) ... 318s Setting up tcl (8.6.14build1) ... 318s Setting up libfontconfig1:armhf (2.15.0-2ubuntu1) ... 318s Setting up libsm6:armhf (2:1.2.4-1) ... 318s Setting up fontconfig (2.15.0-2ubuntu1) ... 320s Regenerating fonts cache... done. 320s Setting up libxft2:armhf (2.3.6-1build1) ... 320s Setting up libtk8.6:armhf (8.6.16-1) ... 320s Setting up libpango-1.0-0:armhf (1.56.2-1) ... 320s Setting up libcairo2:armhf (1.18.2-2) ... 320s Setting up libxt6t64:armhf (1:1.2.1-1.2build1) ... 320s Setting up libpangoft2-1.0-0:armhf (1.56.2-1) ... 320s Setting up libpangocairo-1.0-0:armhf (1.56.2-1) ... 320s Setting up r-base-core (4.4.3-1) ... 320s Creating config file /etc/R/Renviron with new version 320s Setting up r-cran-labeling (0.4.3-1) ... 320s Setting up r-cran-lattice (0.22-6-1) ... 320s Setting up r-cran-nlme (3.1.167-1) ... 320s Setting up r-cran-farver (2.1.2-1) ... 320s Setting up r-cran-viridislite (0.4.2-2) ... 320s Setting up r-cran-commonmark (1.9.2-2) ... 320s Setting up r-cran-r6 (2.6.1-1) ... 320s Setting up r-cran-magrittr (2.0.3-1) ... 320s Setting up r-cran-microbenchmark (1.5.0-1) ... 320s Setting up r-cran-rlang (1.1.5-1) ... 320s Setting up r-cran-matrixstats (1.5.0-1) ... 320s Setting up r-cran-xfun (0.51+dfsg-1) ... 320s Setting up r-cran-withr (3.0.2+dfsg-1) ... 320s Setting up r-cran-base64enc (0.1-3-3) ... 320s Setting up r-cran-digest (0.6.37-1) ... 320s Setting up r-cran-yaml (2.3.10-1) ... 320s Setting up r-cran-evaluate (1.0.3-1) ... 320s Setting up r-cran-highr (0.11+dfsg-1) ... 320s Setting up r-cran-fansi (1.0.5-1) ... 320s Setting up r-cran-mass (7.3-64-1) ... 320s Setting up r-cran-glue (1.8.0-1) ... 320s Setting up r-cran-cli (3.6.4-1) ... 320s Setting up r-cran-lifecycle (1.0.4+dfsg-1) ... 320s Setting up r-cran-r.methodss3 (1.8.2-1) ... 320s Setting up r-cran-pkgconfig (2.0.3-2build1) ... 320s Setting up r-cran-utf8 (1.2.4-1) ... 320s Setting up r-cran-colorspace (2.1-1+dfsg-1) ... 320s Setting up r-cran-markdown (1.13-1) ... 320s Setting up r-cran-rcolorbrewer (1.1-3-1build1) ... 320s Setting up r-cran-isoband (0.2.7-1) ... 320s Setting up r-cran-gtable (0.3.6+dfsg-1) ... 320s Setting up r-cran-matrix (1.7-3-1) ... 320s Setting up r-cran-knitr (1.49+dfsg-1) ... 320s Setting up r-cran-mgcv (1.9-1-1) ... 320s Setting up r-cran-vctrs (0.6.5-1) ... 320s Setting up r-cran-pillar (1.10.1+dfsg-1) ... 320s Setting up r-cran-munsell (0.5.1-1) ... 320s Setting up r-cran-tibble (3.2.1+dfsg-3) ... 320s Setting up r-cran-r.oo (1.27.0-1) ... 320s Setting up r-cran-scales (1.3.0-1) ... 320s Setting up r-cran-r.utils (2.13.0-1) ... 320s Setting up r-cran-ggplot2 (3.5.1+dfsg-1) ... 320s Setting up r-cran-r.devices (2.17.2+ds-1) ... 320s Setting up r-cran-r.cache (0.16.0-1) ... 320s Setting up r-cran-r.rsp (0.46.0+ds-1) ... 320s Processing triggers for libc-bin (2.41-1ubuntu2) ... 320s Processing triggers for man-db (2.13.0-1) ... 321s Processing triggers for install-info (7.1.1-1) ... 329s autopkgtest [16:25:00]: test run-unit-test: [----------------------- 331s 331s R version 4.4.3 (2025-02-28) -- "Trophy Case" 331s Copyright (C) 2025 The R Foundation for Statistical Computing 331s Platform: arm-unknown-linux-gnueabihf (32-bit) 331s 331s R is free software and comes with ABSOLUTELY NO WARRANTY. 331s You are welcome to redistribute it under certain conditions. 331s Type 'license()' or 'licence()' for distribution details. 331s 331s R is a collaborative project with many contributors. 331s Type 'contributors()' for more information and 331s 'citation()' on how to cite R or R packages in publications. 331s 331s Type 'demo()' for some demos, 'help()' for on-line help, or 331s 'help.start()' for an HTML browser interface to help. 331s Type 'q()' to quit R. 331s 331s > library("matrixStats") 331s > 331s > allocArray_R <- function(nrow, ncol, value = NA) { 331s + array(data = value, dim = dim) 331s + } 331s > 331s > values <- list( 331s + -1L, 0L, +1L, NA_integer_, .Machine$integer.max, 331s + -1, 0, +1, NA_real_, NaN, -Inf, +Inf, 331s + .Machine$double.xmin, .Machine$double.xmax, 331s + .Machine$double.eps, .Machine$double.neg.eps, 331s + FALSE, TRUE, NA 331s + ) 331s > 331s > dim <- c(2L, 4L, 3L) 331s > for (value in values) { 331s + x0 <- allocArray_R(dim, value = value) 331s + x <- allocArray(dim, value = value) 331s + if (!identical(x, x0)) { 331s + str(list(dim = dim, value = value, x = x, x0 = x0)) 331s + stopifnot(identical(x, x0)) 331s + } 331s + } 331s > 332s 332s R version 4.4.3 (2025-02-28) -- "Trophy Case" 332s Copyright (C) 2025 The R Foundation for Statistical Computing 332s Platform: arm-unknown-linux-gnueabihf (32-bit) 332s 332s R is free software and comes with ABSOLUTELY NO WARRANTY. 332s You are welcome to redistribute it under certain conditions. 332s Type 'license()' or 'licence()' for distribution details. 332s 332s R is a collaborative project with many contributors. 332s Type 'contributors()' for more information and 332s 'citation()' on how to cite R or R packages in publications. 332s 332s Type 'demo()' for some demos, 'help()' for on-line help, or 332s 'help.start()' for an HTML browser interface to help. 332s Type 'q()' to quit R. 332s 332s > library("matrixStats") 332s > 332s > allocMatrix_R <- function(nrow, ncol, value = NA) { 332s + matrix(data = value, nrow = nrow, ncol = ncol) 332s + } 332s > 332s > values <- list( 332s + -1L, 0L, +1L, NA_integer_, .Machine$integer.max, 332s + -1, 0, +1, NA_real_, NaN, -Inf, +Inf, 332s + .Machine$double.xmin, .Machine$double.xmax, 332s + .Machine$double.eps, .Machine$double.neg.eps, 332s + FALSE, TRUE, NA 332s + ) 332s > 332s > nrow <- 2L 332s > ncol <- 3L 332s > for (value in values) { 332s + x0 <- allocMatrix_R(nrow, ncol, value = value) 332s + x <- allocMatrix(nrow, ncol, value = value) 332s + if (!identical(x, x0)) { 332s + str(list(nrow = nrow, ncol = ncol, value = value, x = x, x0 = x0)) 332s + stopifnot(identical(x, x0)) 332s + } 332s + } 332s > 332s 332s R version 4.4.3 (2025-02-28) -- "Trophy Case" 332s Copyright (C) 2025 The R Foundation for Statistical Computing 332s Platform: arm-unknown-linux-gnueabihf (32-bit) 332s 332s R is free software and comes with ABSOLUTELY NO WARRANTY. 332s You are welcome to redistribute it under certain conditions. 332s Type 'license()' or 'licence()' for distribution details. 332s 332s R is a collaborative project with many contributors. 332s Type 'contributors()' for more information and 332s 'citation()' on how to cite R or R packages in publications. 332s 332s Type 'demo()' for some demos, 'help()' for on-line help, or 332s 'help.start()' for an HTML browser interface to help. 332s Type 'q()' to quit R. 332s 332s > library("matrixStats") 332s > 332s > allocVector_R <- function(length, value = NA) { 332s + x <- vector(mode = typeof(value), length = length) 332s + if (!is.finite(value) || value != 0) x[] <- value 332s + x 332s + } 332s > 332s > values <- list( 332s + -1L, 0L, +1L, NA_integer_, .Machine$integer.max, 332s + -1, 0, +1, NA_real_, NaN, -Inf, +Inf, 332s + .Machine$double.xmin, .Machine$double.xmax, 332s + .Machine$double.eps, .Machine$double.neg.eps, 332s + FALSE, TRUE, NA 332s + ) 332s > 332s > n <- 10L 332s > for (value in values) { 332s + x0 <- allocVector_R(n, value = value) 332s + x <- allocVector(n, value = value) 332s + if (!identical(x, x0)) { 332s + str(list(n = n, value = value, x = x, x0 = x0)) 332s + stopifnot(identical(x, x0)) 332s + } 332s + } 332s > 332s 332s R version 4.4.3 (2025-02-28) -- "Trophy Case" 332s Copyright (C) 2025 The R Foundation for Statistical Computing 332s Platform: arm-unknown-linux-gnueabihf (32-bit) 332s 332s R is free software and comes with ABSOLUTELY NO WARRANTY. 332s You are welcome to redistribute it under certain conditions. 332s Type 'license()' or 'licence()' for distribution details. 332s 332s R is a collaborative project with many contributors. 332s Type 'contributors()' for more information and 332s 'citation()' on how to cite R or R packages in publications. 332s 332s Type 'demo()' for some demos, 'help()' for on-line help, or 332s 'help.start()' for an HTML browser interface to help. 332s Type 'q()' to quit R. 332s 332s > library("matrixStats") 332s > 332s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 332s > # Setup 332s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 332s > data <- data.frame( 332s + logical = c(TRUE, FALSE, TRUE), 332s + integer = 1:3, 332s + double = seq(from = 1.0, to = 3.0, by = 1.0), 332s + complex = seq(from = 1.0, to = 3.0, by = 1.0) + 1.0i, 332s + character = letters[1:3], 332s + stringsAsFactors = FALSE 332s + ) 332s > 332s > modes <- names(data) 332s > 332s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 332s > # Special cases 332s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 332s > cat("NULL...\n") 332s NULL... 332s > stopifnot(identical(anyMissing(NULL), FALSE)) 332s > cat("NULL...done\n") 332s NULL...done 332s > 332s > cat("raw...\n") 332s raw... 332s > stopifnot(identical(anyMissing(as.raw(0:2)), FALSE)) 332s > cat("raw...done\n") 332s raw...done 332s > 332s > cat("list(NULL)...\n") 332s list(NULL)... 332s > stopifnot(identical(anyMissing(list(NULL)), FALSE)) 332s > cat("list(NULL)...done\n") 332s list(NULL)...done 332s > 332s > 332s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 332s > # Scalars, vectors, and matrices of various modes 332s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 332s > for (mode in modes) { 332s + cat(sprintf("Mode: %s...\n", mode)) 332s + values <- data[[mode]] 332s + 332s + # Scalars 332s + cat(" scalar\n") 332s + x <- values[1L] 332s + print(x) 332s + stopifnot(identical(anyMissing(x), FALSE)) 332s + is.na(x) <- TRUE 332s + print(x) 332s + stopifnot(identical(anyMissing(x), TRUE)) 332s + 332s + # Vectors 332s + cat(" vector\n") 332s + x <- values 332s + print(x) 332s + stopifnot(identical(anyMissing(x), FALSE)) 332s + is.na(x)[2L] <- TRUE 332s + print(x) 332s + stopifnot(identical(anyMissing(x), TRUE)) 332s + 332s + # Matrices 332s + cat(" matrix\n") 332s + x <- matrix(c(values, values), ncol = 2L) 332s + print(x) 332s + stopifnot(identical(anyMissing(x), FALSE)) 332s + is.na(x)[2L] <- TRUE 332s + print(x) 332s + stopifnot(identical(anyMissing(x), TRUE)) 332s + 332s + cat(sprintf("Mode: %s...done\n", mode)) 332s + } # for (mode ...) 332s Mode: logical... 332s scalar 332s [1] TRUE 332s [1] NA 332s vector 332s [1] TRUE FALSE TRUE 332s [1] TRUE NA TRUE 332s matrix 332s [,1] [,2] 332s [1,] TRUE TRUE 332s [2,] FALSE FALSE 332s [3,] TRUE TRUE 332s [,1] [,2] 332s [1,] TRUE TRUE 332s [2,] NA FALSE 332s [3,] TRUE TRUE 332s Mode: logical...done 332s Mode: integer... 332s scalar 332s [1] 1 332s [1] NA 332s vector 332s [1] 1 2 3 332s [1] 1 NA 3 332s matrix 332s [,1] [,2] 332s [1,] 1 1 332s [2,] 2 2 332s [3,] 3 3 332s [,1] [,2] 332s [1,] 1 1 332s [2,] NA 2 332s [3,] 3 3 332s Mode: integer...done 332s Mode: double... 332s scalar 332s [1] 1 332s [1] NA 332s vector 332s [1] 1 2 3 332s [1] 1 NA 3 332s matrix 332s [,1] [,2] 332s [1,] 1 1 332s [2,] 2 2 332s [3,] 3 3 332s [,1] [,2] 332s [1,] 1 1 332s [2,] NA 2 332s [3,] 3 3 332s Mode: double...done 332s Mode: complex... 332s scalar 332s [1] 1+1i 332s [1] NA 332s vector 332s [1] 1+1i 2+1i 3+1i 332s [1] 1+1i NA 3+1i 332s matrix 332s [,1] [,2] 332s [1,] 1+1i 1+1i 332s [2,] 2+1i 2+1i 332s [3,] 3+1i 3+1i 332s [,1] [,2] 332s [1,] 1+1i 1+1i 332s [2,] NA 2+1i 332s [3,] 3+1i 3+1i 332s Mode: complex...done 332s Mode: character... 332s scalar 332s [1] "a" 332s [1] NA 332s vector 332s [1] "a" "b" "c" 332s [1] "a" NA "c" 332s matrix 332s [,1] [,2] 332s [1,] "a" "a" 332s [2,] "b" "b" 332s [3,] "c" "c" 332s [,1] [,2] 332s [1,] "a" "a" 332s [2,] NA "b" 332s [3,] "c" "c" 332s Mode: character...done 332s > 332s > 332s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 332s > # Data frames 332s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 332s > cat("data.frame...\n") 332s data.frame... 332s > x <- data 332s > stopifnot(identical(anyMissing(x), FALSE)) 332s > for (mode in modes) { 332s + x <- data 332s + is.na(x[[mode]])[2L] <- TRUE 332s + print(x) 332s + stopifnot(identical(anyMissing(x), TRUE)) 332s + } # for (mode ...) 332s logical integer double complex character 332s 1 TRUE 1 1 1+1i a 332s 2 NA 2 2 2+1i b 332s 3 TRUE 3 3 3+1i c 332s logical integer double complex character 332s 1 TRUE 1 1 1+1i a 332s 2 FALSE NA 2 2+1i b 332s 3 TRUE 3 3 3+1i c 332s logical integer double complex character 332s 1 TRUE 1 1 1+1i a 332s 2 FALSE 2 NA 2+1i b 332s 3 TRUE 3 3 3+1i c 332s logical integer double complex character 332s 1 TRUE 1 1 1+1i a 332s 2 FALSE 2 2 NA b 332s 3 TRUE 3 3 3+1i c 332s logical integer double complex character 332s 1 TRUE 1 1 1+1i a 332s 2 FALSE 2 2 2+1i 332s 3 TRUE 3 3 3+1i c 332s > cat("data.frame...done\n") 332s data.frame...done 332s > 332s > 332s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 332s > # Lists 332s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 332s > cat("list...\n") 332s list... 332s > x <- as.list(data) 332s > stopifnot(identical(anyMissing(x), FALSE)) 332s > for (mode in modes) { 332s + x <- as.list(data) 332s + is.na(x[[mode]])[2L] <- TRUE 332s + print(x) 332s + stopifnot(identical(anyMissing(x), TRUE)) 332s + } # for (mode ...) 332s $logical 332s [1] TRUE NA TRUE 332s 332s $integer 332s [1] 1 2 3 332s 332s $double 332s [1] 1 2 3 332s 332s $complex 332s [1] 1+1i 2+1i 3+1i 332s 332s $character 332s [1] "a" "b" "c" 332s 332s $logical 332s [1] TRUE FALSE TRUE 332s 332s $integer 332s [1] 1 NA 3 332s 332s $double 332s [1] 1 2 3 332s 332s $complex 332s [1] 1+1i 2+1i 3+1i 332s 332s $character 332s [1] "a" "b" "c" 332s 332s $logical 332s [1] TRUE FALSE TRUE 332s 332s $integer 332s [1] 1 2 3 332s 332s $double 332s [1] 1 NA 3 332s 332s $complex 332s [1] 1+1i 2+1i 3+1i 332s 332s $character 332s [1] "a" "b" "c" 332s 332s $logical 332s [1] TRUE FALSE TRUE 332s 332s $integer 332s [1] 1 2 3 332s 332s $double 332s [1] 1 2 3 332s 332s $complex 332s [1] 1+1i NA 3+1i 332s 332s $character 332s [1] "a" "b" "c" 332s 332s $logical 332s [1] TRUE FALSE TRUE 332s 332s $integer 332s [1] 1 2 3 332s 332s $double 332s [1] 1 2 3 332s 332s $complex 332s [1] 1+1i 2+1i 3+1i 332s 332s $character 332s [1] "a" NA "c" 332s 332s > cat("list...done\n") 332s list...done 332s > 333s 333s R version 4.4.3 (2025-02-28) -- "Trophy Case" 333s Copyright (C) 2025 The R Foundation for Statistical Computing 333s Platform: arm-unknown-linux-gnueabihf (32-bit) 333s 333s R is free software and comes with ABSOLUTELY NO WARRANTY. 333s You are welcome to redistribute it under certain conditions. 333s Type 'license()' or 'licence()' for distribution details. 333s 333s R is a collaborative project with many contributors. 333s Type 'contributors()' for more information and 333s 'citation()' on how to cite R or R packages in publications. 333s 333s Type 'demo()' for some demos, 'help()' for on-line help, or 333s 'help.start()' for an HTML browser interface to help. 333s Type 'q()' to quit R. 333s 333s > library("matrixStats") 333s > 333s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 333s > # Subsetted tests 333s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 333s > source("utils/validateIndicesFramework.R") 333s > x <- runif(4, min = -3, max = 3) 333s > x[2] <- NA 333s > for (mode in c("integer", "numeric")) { 333s + storage.mode(x) <- mode 333s + for (idxs in index_cases) { 333s + validateIndicesTestVector(x, idxs, 333s + ftest = anyMissing, fsure = function(x, ...) { 333s + anyValue(x, value = NA) 333s + }) 333s + } 333s + } 333s > 333s 333s R version 4.4.3 (2025-02-28) -- "Trophy Case" 333s Copyright (C) 2025 The R Foundation for Statistical Computing 333s Platform: arm-unknown-linux-gnueabihf (32-bit) 333s 333s R is free software and comes with ABSOLUTELY NO WARRANTY. 333s You are welcome to redistribute it under certain conditions. 333s Type 'license()' or 'licence()' for distribution details. 333s 333s R is a collaborative project with many contributors. 333s Type 'contributors()' for more information and 333s 'citation()' on how to cite R or R packages in publications. 333s 333s Type 'demo()' for some demos, 'help()' for on-line help, or 333s 'help.start()' for an HTML browser interface to help. 333s Type 'q()' to quit R. 333s 333s > ## Don't test with valgrind 333s > if (Sys.getenv("_R_CHECK_USE_VALGRIND_") == "") { 333s + 333s + ## 3. Make sure all suggested packages are installed / can be loaded 333s + pkgs <- c("base64enc", "ggplot2", "knitr", "markdown", "microbenchmark", 333s + "R.devices", "R.rsp") 333s + if (all(unlist(lapply(pkgs, FUN = requireNamespace)))) { 333s + html <- matrixStats:::benchmark("binCounts") 333s + print(html) 333s + } 333s + 333s + rm(list = "pkgs") 333s + 333s + } 333s Loading required namespace: base64enc 333s Loading required namespace: ggplot2 334s Loading required namespace: knitr 334s Loading required namespace: markdown 334s Loading required namespace: microbenchmark 334s Loading required namespace: R.devices 334s Loading required namespace: R.rsp 336s integer: unsorted 339s integer: sorted 341s double: unsorted 344s double: sorted 346s RspFileProduct: 346s Pathname: /tmp/autopkgtest.eWQgeF/autopkgtest_tmp/reports/binCounts.html 346s File size: 72.20 kB (73928 bytes) 346s Content type: text/html 346s Metadata 'author': 'Henrik Bengtsson' 346s Metadata 'title': 'binCounts() benchmarks' 346s Metadata 'date': '2014-05-25' 346s Has processor: FALSE 346s > 346s Warning message: 346s In par(parT) : argument 1 does not name a graphical parameter 346s 346s R version 4.4.3 (2025-02-28) -- "Trophy Case" 346s Copyright (C) 2025 The R Foundation for Statistical Computing 346s Platform: arm-unknown-linux-gnueabihf (32-bit) 346s 346s R is free software and comes with ABSOLUTELY NO WARRANTY. 346s You are welcome to redistribute it under certain conditions. 346s Type 'license()' or 'licence()' for distribution details. 346s 346s R is a collaborative project with many contributors. 346s Type 'contributors()' for more information and 346s 'citation()' on how to cite R or R packages in publications. 346s 346s Type 'demo()' for some demos, 'help()' for on-line help, or 346s 'help.start()' for an HTML browser interface to help. 346s Type 'q()' to quit R. 346s 346s > library("matrixStats") 346s > library("stats") 346s > 346s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 346s > # Local functions 346s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 346s > binCounts_hist <- function(x, bx, right = FALSE, ...) { 346s + n0 <- graphics::hist(x, breaks = bx, right = right, 346s + include.lowest = TRUE, plot = FALSE)$counts 346s + } 346s > 346s > 346s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 346s > # Non-sorted and sorted positions 346s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 346s > nx <- 1000L # Number of data points 346s > nb <- 200L # Number of bins 346s > 346s > # Uniformely distributed bins 346s > bx <- seq(from = 0, to = 1, length.out = nb + 1L) 346s > bx <- c(-1, bx, 2) 346s > 346s > # Sample data points 346s > set.seed(0xBEEF) 346s > x <- runif(nx, min = 0, max = 1) 346s > 346s > for (kk in 1:2) { 346s + n0 <- binCounts_hist(x, bx = bx) 346s + n1 <- binCounts(x, bx = bx) 346s + # Sanity check 346s + stopifnot(identical(n1, n0)) 346s + 346s + # Check reversed 346s + n1r <- rev(binCounts(-x, bx = rev(-bx), right = TRUE)) 346s + stopifnot(identical(n1r, n1)) 346s + 346s + # Retry with a sorted vector 346s + x <- sort(x) 346s + } # for (kk in 1:2) 347s > 347s > 347s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 347s > # Missing values 347s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 347s > x <- 1:40 347s > x[20] <- NA_integer_ 347s > nx <- length(x) 347s > 347s > # Bins 347s > bx <- c(0.5, 50.5, 100.5, 150.5, 200.5) 347s > 347s > y_smooth0 <- binCounts_hist(x, bx = bx) 347s > y_smooth <- binCounts(x, bx = bx) 347s > # Sanity check 347s > stopifnot(all.equal(y_smooth, y_smooth0)) 347s > 347s > 347s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 347s > # Border cases 347s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 347s > x <- 1:10 347s > bx <- min(x) - c(10, 1) 347s > y_smooth <- binCounts(x, bx = bx) 347s > stopifnot(all.equal(y_smooth, 0L)) 347s > bx <- range(x) 347s > y_smooth <- binCounts(x, bx = bx) 347s > stopifnot(all.equal(y_smooth, length(x) - 1L)) 347s > bx <- max(x) + c(1, 10) 347s > y_smooth <- binCounts(x, bx = bx) 347s > stopifnot(all.equal(y_smooth, 0L)) 347s > 347s > # Every second empty 347s > x <- 1:10 347s > bx <- rep(x, each = 2L) 347s > y_smooth <- binCounts(x, bx = bx) 347s > stopifnot(all.equal(y_smooth, rep(c(0L, 1L), length.out = length(bx) - 1L))) 347s > ## NOTE: binCounts_hist() does not give the same last bin count 347s > 347s > 347s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 347s > # Exception handling 347s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 347s > # Zero bin boundaries (invalid bin definition) 347s > bx <- double(0L) 347s > res <- try(y_smooth <- binCounts(1:10, bx = bx), silent = TRUE) 347s > stopifnot(inherits(res, "try-error")) 347s > 347s > # One bin boundary (invalid bin definition) 347s > bx <- double(1L) 347s > res <- try(y_smooth <- binCounts(1:10, bx = bx), silent = TRUE) 347s > stopifnot(inherits(res, "try-error")) 347s > 347s 347s R version 4.4.3 (2025-02-28) -- "Trophy Case" 347s Copyright (C) 2025 The R Foundation for Statistical Computing 347s Platform: arm-unknown-linux-gnueabihf (32-bit) 347s 347s R is free software and comes with ABSOLUTELY NO WARRANTY. 347s You are welcome to redistribute it under certain conditions. 347s Type 'license()' or 'licence()' for distribution details. 347s 347s R is a collaborative project with many contributors. 347s Type 'contributors()' for more information and 347s 'citation()' on how to cite R or R packages in publications. 347s 347s Type 'demo()' for some demos, 'help()' for on-line help, or 347s 'help.start()' for an HTML browser interface to help. 347s Type 'q()' to quit R. 347s 347s > library("matrixStats") 347s > 347s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 347s > # Local functions 347s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 347s > binCounts_hist <- function(x, bx, right = FALSE, ...) { 347s + n0 <- graphics::hist(x, breaks = bx, right = right, 347s + include.lowest = TRUE, plot = FALSE)$counts 347s + } 347s > 347s > 347s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 347s > # Subsetted tests 347s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 347s > source("utils/validateIndicesFramework.R") 347s > x <- runif(6, min = -6, max = 6) 347s > storage.mode(x) <- "integer" 347s > bx <- c(-6, 0, 3, 4, 10) 347s > for (idxs in index_cases) { 347s + validateIndicesTestVector(x, idxs, 347s + ftest = binCounts, fsure = binCounts_hist, 347s + bx = bx, right = FALSE) 347s + validateIndicesTestVector(x, idxs, 347s + ftest = binCounts, fsure = binCounts_hist, 347s + bx = bx, right = TRUE) 347s + } 347s > 347s 347s R version 4.4.3 (2025-02-28) -- "Trophy Case" 347s Copyright (C) 2025 The R Foundation for Statistical Computing 347s Platform: arm-unknown-linux-gnueabihf (32-bit) 347s 347s R is free software and comes with ABSOLUTELY NO WARRANTY. 347s You are welcome to redistribute it under certain conditions. 347s Type 'license()' or 'licence()' for distribution details. 347s 347s R is a collaborative project with many contributors. 347s Type 'contributors()' for more information and 347s 'citation()' on how to cite R or R packages in publications. 347s 347s Type 'demo()' for some demos, 'help()' for on-line help, or 347s 'help.start()' for an HTML browser interface to help. 347s Type 'q()' to quit R. 347s 347s > library("matrixStats") 347s > library("stats") 347s > 347s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 347s > # Naive R implementation of binMeans() 347s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 347s > binMeans0 <- function(y, x, bx, na.rm = TRUE, count = TRUE, right = FALSE) { 347s + n_smooth <- length(bx) - 1L 347s + res <- double(n_smooth) 347s + counts <- rep(NaN, times = n_smooth) 347s + 347s + if (na.rm) { 347s + keep <- !is.na(x) & !is.na(y) 347s + x <- x[keep] 347s + y <- y[keep] 347s + } 347s + 347s + # For each bin... 347s + for (kk in seq_len(n_smooth)) { 347s + if (right) { 347s + idxs <- which(bx[kk] < x & x <= bx[kk + 1L]) 347s + } else { 347s + idxs <- which(bx[kk] <= x & x < bx[kk + 1L]) 347s + } 347s + y_kk <- y[idxs] 347s + res[kk] <- mean(y_kk) 347s + counts[kk] <- length(idxs) 347s + } # for (kk ...) 347s + 347s + if (count) attr(res, "count") <- counts 347s + res 347s + } 347s > 347s > 347s > 347s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 347s > # Case #1 347s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 347s > x <- 1:100 347s > nx <- length(x) 347s > y <- double(nx) 347s > y[1:25] <- 5 347s > y[51:75] <- -5 347s > y <- y + rnorm(nx) 347s > 347s > # Bins 347s > bx <- c(0.5, 25.5, 50.5, 75.5, 100.5) 347s > 347s > y_smooth0 <- binMeans0(y, x = x, bx = bx) 347s > y_smooth <- binMeans(y, x = x, bx = bx) 347s > n_smooth <- binCounts(x, bx = bx) 347s > # Sanity check 347s > stopifnot(all.equal(y_smooth, y_smooth0)) 347s > stopifnot(all.equal(attr(y_smooth, "count"), n_smooth)) 347s > 347s > y_smooth0r <- rev(binMeans0(y, x = -x, bx = rev(-bx), 347s + count = FALSE, right = TRUE)) 347s > y_smoothr <- rev(binMeans(y, x = -x, bx = rev(-bx), 347s + count = FALSE, right = TRUE)) 347s > # Sanity check 347s > stopifnot(all.equal(y_smooth0r, y_smooth0, check.attributes = FALSE)) 347s > stopifnot(all.equal(y_smoothr, y_smooth0r)) 347s > 347s > 347s > # Integer input 347s > y <- as.integer(y) 347s > y_smooth0 <- binMeans0(y, x = x, bx = bx) 347s > y_smooth <- binMeans(y, x = x, bx = bx) 347s > n_smooth <- binCounts(x, bx = bx) 347s > # Sanity check 347s > stopifnot(is.integer(y), 347s + all.equal(y_smooth, y_smooth0), 347s + all.equal(attr(y_smooth, "count"), n_smooth)) 347s > 347s > # Logical input 347s > y <- as.logical(y) 347s > y_smooth0 <- binMeans0(y, x = x, bx = bx) 347s > y_smooth <- binMeans(y, x = x, bx = bx) 347s > n_smooth <- binCounts(x, bx = bx) 347s > # Sanity check 347s > stopifnot(is.logical(y), 347s + all.equal(y_smooth, y_smooth0), 347s + all.equal(attr(y_smooth, "count"), n_smooth)) 347s > 347s > 347s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 347s > # Case #2 347s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 347s > nx <- 1e3 347s > x <- runif(nx) 347s > y <- runif(nx) 347s > 347s > nb <- 10 347s > bx <- do.call(seq, c(as.list(range(x)), length.out = nb)) 347s > bx1 <- c(bx[-1], bx[nb] + 1) 347s > 347s > y_smooth0 <- binMeans0(y, x = x, bx = bx1) 347s > y_smooth <- binMeans(y, x = x, bx = bx1) 347s > n_smooth <- binCounts(x, bx = bx1) 347s > y_smoothr <- rev(binMeans(y, x = -x, bx = rev(-bx1), right = TRUE)) 347s > 347s > # Sanity check 347s > stopifnot(all.equal(y_smooth, y_smooth0)) 347s > stopifnot(all.equal(attr(y_smooth, "count"), n_smooth)) 347s > stopifnot(all.equal(y_smoothr, y_smooth, check.attributes = FALSE)) 347s > 347s > 347s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 347s > # Empty bins 347s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 347s > x <- c(6:8, 16:19) 347s > nx <- length(x) 347s > y <- runif(nx) 347s > bx <- c(0, 5, 10, 15, 20, 25) 347s > y_smooth0 <- binMeans0(y, x = x, bx = bx) 347s > y_smooth <- binMeans(y, x = x, bx = bx) 347s > n_smooth <- binCounts(x, bx = bx) 347s > stopifnot(all.equal(attr(y_smooth, "count"), n_smooth)) 347s > stopifnot(all.equal(y_smooth, y_smooth0)) 347s > 347s > 347s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 347s > # Missing values 347s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 347s > x <- 1:100 347s > x[50] <- NA_integer_ 347s > nx <- length(x) 347s > y <- double(nx) 347s > y[1:25] <- 5 347s > y[51:75] <- -5 347s > y[82:92] <- NA_real_ 347s > y <- y + rnorm(nx) 347s > 347s > # Bins 347s > bx <- c(0.5, 25.5, 75.5, 82.5, 100.5) 347s > 347s > y_smooth0 <- binMeans0(y, x = x, bx = bx) 347s > y_smooth <- binMeans(y, x = x, bx = bx) 347s > # Sanity check 347s > stopifnot(all.equal(y_smooth, y_smooth0)) 347s > 347s > 347s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 347s > # Exception handling 347s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 347s > # Zero bin boundaries (invalid bin definition) 347s > bx <- double(0L) 347s > res <- try(y_smooth <- binMeans(x = 1:5, y = 1:5, bx = bx), silent = TRUE) 347s > stopifnot(inherits(res, "try-error")) 347s > 347s > # One bin boundary (invalid bin definition) 347s > bx <- double(1L) 347s > res <- try(y_smooth <- binMeans(x = 1:5, y = 1:5, bx = bx), silent = TRUE) 347s > stopifnot(inherits(res, "try-error")) 347s > 347s 347s R version 4.4.3 (2025-02-28) -- "Trophy Case" 347s Copyright (C) 2025 The R Foundation for Statistical Computing 347s Platform: arm-unknown-linux-gnueabihf (32-bit) 347s 347s R is free software and comes with ABSOLUTELY NO WARRANTY. 347s You are welcome to redistribute it under certain conditions. 347s Type 'license()' or 'licence()' for distribution details. 347s 347s R is a collaborative project with many contributors. 347s Type 'contributors()' for more information and 347s 'citation()' on how to cite R or R packages in publications. 347s 347s Type 'demo()' for some demos, 'help()' for on-line help, or 347s 'help.start()' for an HTML browser interface to help. 347s Type 'q()' to quit R. 347s 347s > library("matrixStats") 347s > 347s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 347s > # Naive R implementation of binMeans() 347s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 347s > binMeans0 <- function(y, x, bx, na.rm = TRUE, count = TRUE, right = FALSE) { 347s + n_smooth <- length(bx) - 1L 347s + res <- double(n_smooth) 347s + counts <- rep(NaN, times = n_smooth) 347s + 347s + if (na.rm) { 347s + keep <- !is.na(x) & !is.na(y) 347s + x <- x[keep] 347s + y <- y[keep] 347s + } 347s + 347s + # For each bin... 347s + for (kk in seq_len(n_smooth)) { 347s + if (right) { 347s + idxs <- which(bx[kk] < x & x <= bx[kk + 1L]) 347s + } else { 347s + idxs <- which(bx[kk] <= x & x < bx[kk + 1L]) 347s + } 347s + y_kk <- y[idxs] 347s + res[kk] <- mean(y_kk) 347s + counts[kk] <- length(idxs) 347s + } # for (kk ...) 347s + 347s + if (count) attr(res, "count") <- counts 347s + res 347s + } 347s > 347s > 347s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 347s > # Subsetted tests 347s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 347s > source("utils/validateIndicesFramework.R") 347s > y <- runif(6, min = -6, max = 6) 347s > x <- runif(6, min = -6, max = 6) 347s > storage.mode(x) <- "integer" 347s > bx <- c(-6, 0, 3, 4, 10) 347s > for (idxs in index_cases) { 347s + for (na.rm in c(TRUE, FALSE)) { 347s + validateIndicesTestVector_w(y, x, idxs, 347s + ftest = binMeans, fsure = binMeans0, 347s + bx = bx, na.rm = na.rm, 347s + count = TRUE, right = FALSE) 347s + validateIndicesTestVector_w(y, x, idxs, 347s + ftest = binMeans, fsure = binMeans0, 347s + bx = bx, na.rm = na.rm, 347s + count = TRUE, right = TRUE) 347s + } 347s + } 347s > 348s 348s R version 4.4.3 (2025-02-28) -- "Trophy Case" 348s Copyright (C) 2025 The R Foundation for Statistical Computing 348s Platform: arm-unknown-linux-gnueabihf (32-bit) 348s 348s R is free software and comes with ABSOLUTELY NO WARRANTY. 348s You are welcome to redistribute it under certain conditions. 348s Type 'license()' or 'licence()' for distribution details. 348s 348s R is a collaborative project with many contributors. 348s Type 'contributors()' for more information and 348s 'citation()' on how to cite R or R packages in publications. 348s 348s Type 'demo()' for some demos, 'help()' for on-line help, or 348s 'help.start()' for an HTML browser interface to help. 348s Type 'q()' to quit R. 348s 348s > library("matrixStats") 348s > 348s > count_R <- function(x, value = TRUE, na.rm = FALSE, ...) { 348s + if (is.na(value)) { 348s + counts <- sum(is.na(x)) 348s + } else { 348s + counts <- sum(x == value, na.rm = na.rm) 348s + } 348s + as.integer(counts) 348s + } 348s > 348s > 348s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 348s > # Data type: integer and numeric 348s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 348s > for (mode in c("integer", "double")) { 348s + x <- runif(20 * 5, min = -3, max = 3) 348s + x[sample.int(length(x), size = 7)] <- 0 348s + storage.mode(x) <- mode 348s + 348s + for (na.rm in c(FALSE, TRUE)) { 348s + # Count zeros 348s + n0 <- count_R(x, value = 0, na.rm = na.rm) 348s + n1 <- count(x, value = 0, na.rm = na.rm) 348s + stopifnot(identical(n1, n0)) 348s + all <- allValue(x, value = 0, na.rm = na.rm) 348s + any <- anyValue(x, value = 0, na.rm = na.rm) 348s + 348s + # Count NAs 348s + n0 <- count_R(x, value = NA, na.rm = na.rm) 348s + n1 <- count(x, value = NA, na.rm = na.rm) 348s + stopifnot(identical(n1, n0)) 348s + all <- allValue(x, value = NA, na.rm = na.rm) 348s + any <- anyValue(x, value = NA, na.rm = na.rm) 348s + 348s + if (mode == "integer") { 348s + ux <- unique(as.vector(x)) 348s + n0 <- n1 <- integer(length(x)) 348s + for (value in ux) { 348s + n0 <- n0 + count_R(x, value = value, na.rm = na.rm) 348s + n1 <- n1 + count(x, value = value, na.rm = na.rm) 348s + stopifnot(identical(n1, n0)) 348s + } 348s + stopifnot(all(n0 == ncol(x))) 348s + } # if (mode == "integer") 348s + 348s + } # for (na.rm ...) 348s + } # for (mode ...) 348s > 348s > # All NAs 348s > na_list <- list(NA_integer_, NA_real_, NaN) 348s > for (na_value in na_list) { 348s + x <- rep(na_value, times = 10L) 348s + for (na.rm in c(FALSE, TRUE)) { 348s + n0 <- count_R(x, na.rm = na.rm) 348s + n1 <- count(x, na.rm = na.rm) 348s + stopifnot(identical(n1, n0)) 348s + 348s + # Count NAs 348s + n0 <- count_R(x, value = NA, na.rm = na.rm) 348s + n1 <- count(x, value = NA, na.rm = na.rm) 348s + stopifnot(identical(n1, n0)) 348s + any <- anyValue(x, value = NA, na.rm = na.rm) 348s + all <- allValue(x, value = NA, na.rm = na.rm) 348s + stopifnot(any) 348s + stopifnot(all) 348s + } 348s + } # for (na_value ...) 348s > 348s > 348s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 348s > # Data type: logical 348s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 348s > x <- logical(length = 10L) 348s > x[3:7] <- TRUE 348s > 348s > # Row/column counts 348s > for (na.rm in c(FALSE, TRUE)) { 348s + n0 <- count_R(x, na.rm = na.rm) 348s + n1 <- count(x, na.rm = na.rm) 348s + stopifnot(identical(n1, n0)) 348s + 348s + n_true <- count(x, value = TRUE, na.rm = na.rm) 348s + n_false <- count(x, value = FALSE, na.rm = na.rm) 348s + stopifnot(n_true + n_false == ncol(x)) 348s + 348s + # Count NAs 348s + n0 <- count_R(x, value = NA, na.rm = na.rm) 348s + n1 <- count(x, value = NA, na.rm = na.rm) 348s + stopifnot(identical(n1, n0)) 348s + } 348s > 348s 348s R version 4.4.3 (2025-02-28) -- "Trophy Case" 348s Copyright (C) 2025 The R Foundation for Statistical Computing 348s Platform: arm-unknown-linux-gnueabihf (32-bit) 348s 348s R is free software and comes with ABSOLUTELY NO WARRANTY. 348s You are welcome to redistribute it under certain conditions. 348s Type 'license()' or 'licence()' for distribution details. 348s 348s R is a collaborative project with many contributors. 348s Type 'contributors()' for more information and 348s 'citation()' on how to cite R or R packages in publications. 348s 348s Type 'demo()' for some demos, 'help()' for on-line help, or 348s 'help.start()' for an HTML browser interface to help. 348s Type 'q()' to quit R. 348s 348s > library("matrixStats") 348s > 348s > count_R <- function(x, value = TRUE, na.rm = FALSE, ...) { 348s + if (is.na(value)) { 348s + counts <- sum(is.na(x)) 348s + } else { 348s + counts <- sum(x == value, na.rm = na.rm) 348s + } 348s + as.integer(counts) 348s + } 348s > 348s > 348s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 348s > # Subsetted tests 348s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 348s > source("utils/validateIndicesFramework.R") 348s > x <- runif(6, min = -3, max = 3) 348s > storage.mode(x) <- "integer" 348s > for (idxs in index_cases) { 348s + validateIndicesTestVector(x, idxs, 348s + ftest = count, fsure = count_R, 348s + value = 0, na.rm = TRUE) 348s + validateIndicesTestVector(x, idxs, 348s + ftest = count, fsure = count_R, 348s + value = 0, na.rm = FALSE) 348s + validateIndicesTestVector(x, idxs, 348s + ftest = count, fsure = count_R, 348s + value = NA_integer_) 348s + } 348s > 348s 348s R version 4.4.3 (2025-02-28) -- "Trophy Case" 348s Copyright (C) 2025 The R Foundation for Statistical Computing 348s Platform: arm-unknown-linux-gnueabihf (32-bit) 348s 348s R is free software and comes with ABSOLUTELY NO WARRANTY. 348s You are welcome to redistribute it under certain conditions. 348s Type 'license()' or 'licence()' for distribution details. 348s 348s R is a collaborative project with many contributors. 348s Type 'contributors()' for more information and 348s 'citation()' on how to cite R or R packages in publications. 348s 348s Type 'demo()' for some demos, 'help()' for on-line help, or 348s 'help.start()' for an HTML browser interface to help. 348s Type 'q()' to quit R. 348s 348s > library("matrixStats") 348s > 348s > diff2_R <- function(..., useNames = TRUE){ 348s + res <- diff(...) 348s + if (!useNames) names(res) <- NULL 348s + res 348s + } 348s > 348s > set.seed(0x42) 348s > 348s > for (mode in c("integer", "double")) { 348s + x <- rnorm(10, sd = 5) 348s + storage.mode(x) <- mode 348s + str(x) 348s + 348s + for (has_na in c(FALSE, TRUE)) { 348s + for (setNames in c(TRUE, FALSE)) { 348s + for (useNames in c(TRUE, FALSE)) { 348s + if (has_na) { 348s + x[sample(1:10, size = 3)] <- NA 348s + } 348s + if (setNames) { 348s + names(x) <- LETTERS[1:10] 348s + } 348s + for (l in 1:3) { 348s + for (d in 1:4) { 348s + cat(sprintf("%s: NAs = %s, lag = %d, differences = %d, setNames = %d, useNames = %d\n", 348s + mode, has_na, l, d, setNames, useNames)) 348s + y0 <- diff2_R(x, lag = l, differences = d, useNames = useNames) 348s + str(y0) 348s + y1 <- diff2(x, lag = l, differences = d, useNames = useNames) 348s + str(y1) 348s + stopifnot(identical(y1, y0)) 348s + } 348s + } 348s + } 348s + } 348s + } # for (has_na ...) 348s + } 348s int [1:10] 11 1 2 0 -1 -3 -3 6 0 0 348s integer: NAs = FALSE, lag = 1, differences = 1, setNames = 1, useNames = 1 348s Named int [1:9] -10 1 -2 -1 -2 0 9 -6 0 348s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 348s Named int [1:9] -10 1 -2 -1 -2 0 9 -6 0 348s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 348s integer: NAs = FALSE, lag = 1, differences = 2, setNames = 1, useNames = 1 348s Named int [1:8] 11 -3 1 -1 2 9 -15 6 348s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 348s Named int [1:8] 11 -3 1 -1 2 9 -15 6 348s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 348s integer: NAs = FALSE, lag = 1, differences = 3, setNames = 1, useNames = 1 348s Named int [1:7] -14 4 -2 3 7 -24 21 348s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 348s Named int [1:7] -14 4 -2 3 7 -24 21 348s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 348s integer: NAs = FALSE, lag = 1, differences = 4, setNames = 1, useNames = 1 348s Named int [1:6] 18 -6 5 4 -31 45 348s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 348s Named int [1:6] 18 -6 5 4 -31 45 348s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 348s integer: NAs = FALSE, lag = 2, differences = 1, setNames = 1, useNames = 1 348s Named int [1:8] -9 -1 -3 -3 -2 9 3 -6 348s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 348s Named int [1:8] -9 -1 -3 -3 -2 9 3 -6 348s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 348s integer: NAs = FALSE, lag = 2, differences = 2, setNames = 1, useNames = 1 348s Named int [1:6] 6 -2 1 12 5 -15 348s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 348s Named int [1:6] 6 -2 1 12 5 -15 348s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 348s integer: NAs = FALSE, lag = 2, differences = 3, setNames = 1, useNames = 1 348s Named int [1:4] -5 14 4 -27 348s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 348s Named int [1:4] -5 14 4 -27 348s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 348s integer: NAs = FALSE, lag = 2, differences = 4, setNames = 1, useNames = 1 348s Named int [1:2] 9 -41 348s - attr(*, "names")= chr [1:2] "I" "J" 348s Named int [1:2] 9 -41 348s - attr(*, "names")= chr [1:2] "I" "J" 348s integer: NAs = FALSE, lag = 3, differences = 1, setNames = 1, useNames = 1 348s Named int [1:7] -11 -2 -5 -3 7 3 3 348s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 348s Named int [1:7] -11 -2 -5 -3 7 3 3 348s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 348s integer: NAs = FALSE, lag = 3, differences = 2, setNames = 1, useNames = 1 348s Named int [1:4] 8 9 8 6 348s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 348s Named int [1:4] 8 9 8 6 348s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 348s integer: NAs = FALSE, lag = 3, differences = 3, setNames = 1, useNames = 1 348s Named int -2 348s - attr(*, "names")= chr "J" 348s Named int -2 348s - attr(*, "names")= chr "J" 348s integer: NAs = FALSE, lag = 3, differences = 4, setNames = 1, useNames = 1 348s Named int(0) 348s - attr(*, "names")= chr(0) 348s Named int(0) 348s - attr(*, "names")= chr(0) 348s integer: NAs = FALSE, lag = 1, differences = 1, setNames = 1, useNames = 0 348s int [1:9] -10 1 -2 -1 -2 0 9 -6 0 348s int [1:9] -10 1 -2 -1 -2 0 9 -6 0 348s integer: NAs = FALSE, lag = 1, differences = 2, setNames = 1, useNames = 0 348s int [1:8] 11 -3 1 -1 2 9 -15 6 348s int [1:8] 11 -3 1 -1 2 9 -15 6 348s integer: NAs = FALSE, lag = 1, differences = 3, setNames = 1, useNames = 0 348s int [1:7] -14 4 -2 3 7 -24 21 348s int [1:7] -14 4 -2 3 7 -24 21 348s integer: NAs = FALSE, lag = 1, differences = 4, setNames = 1, useNames = 0 348s int [1:6] 18 -6 5 4 -31 45 348s int [1:6] 18 -6 5 4 -31 45 348s integer: NAs = FALSE, lag = 2, differences = 1, setNames = 1, useNames = 0 348s int [1:8] -9 -1 -3 -3 -2 9 3 -6 348s int [1:8] -9 -1 -3 -3 -2 9 3 -6 348s integer: NAs = FALSE, lag = 2, differences = 2, setNames = 1, useNames = 0 348s int [1:6] 6 -2 1 12 5 -15 348s int [1:6] 6 -2 1 12 5 -15 348s integer: NAs = FALSE, lag = 2, differences = 3, setNames = 1, useNames = 0 348s int [1:4] -5 14 4 -27 348s int [1:4] -5 14 4 -27 348s integer: NAs = FALSE, lag = 2, differences = 4, setNames = 1, useNames = 0 348s int [1:2] 9 -41 348s int [1:2] 9 -41 348s integer: NAs = FALSE, lag = 3, differences = 1, setNames = 1, useNames = 0 348s int [1:7] -11 -2 -5 -3 7 3 3 348s int [1:7] -11 -2 -5 -3 7 3 3 348s integer: NAs = FALSE, lag = 3, differences = 2, setNames = 1, useNames = 0 348s int [1:4] 8 9 8 6 348s int [1:4] 8 9 8 6 348s integer: NAs = FALSE, lag = 3, differences = 3, setNames = 1, useNames = 0 348s int -2 348s int -2 348s integer: NAs = FALSE, lag = 3, differences = 4, setNames = 1, useNames = 0 348s int(0) 348s int(0) 348s integer: NAs = FALSE, lag = 1, differences = 1, setNames = 0, useNames = 1 348s Named int [1:9] -10 1 -2 -1 -2 0 9 -6 0 348s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 348s Named int [1:9] -10 1 -2 -1 -2 0 9 -6 0 348s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 348s integer: NAs = FALSE, lag = 1, differences = 2, setNames = 0, useNames = 1 348s Named int [1:8] 11 -3 1 -1 2 9 -15 6 348s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 348s Named int [1:8] 11 -3 1 -1 2 9 -15 6 348s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 348s integer: NAs = FALSE, lag = 1, differences = 3, setNames = 0, useNames = 1 348s Named int [1:7] -14 4 -2 3 7 -24 21 348s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 348s Named int [1:7] -14 4 -2 3 7 -24 21 348s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 348s integer: NAs = FALSE, lag = 1, differences = 4, setNames = 0, useNames = 1 348s Named int [1:6] 18 -6 5 4 -31 45 348s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 348s Named int [1:6] 18 -6 5 4 -31 45 348s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 348s integer: NAs = FALSE, lag = 2, differences = 1, setNames = 0, useNames = 1 348s Named int [1:8] -9 -1 -3 -3 -2 9 3 -6 348s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 348s Named int [1:8] -9 -1 -3 -3 -2 9 3 -6 348s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 348s integer: NAs = FALSE, lag = 2, differences = 2, setNames = 0, useNames = 1 348s Named int [1:6] 6 -2 1 12 5 -15 348s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 348s Named int [1:6] 6 -2 1 12 5 -15 348s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 348s integer: NAs = FALSE, lag = 2, differences = 3, setNames = 0, useNames = 1 348s Named int [1:4] -5 14 4 -27 348s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 348s Named int [1:4] -5 14 4 -27 348s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 348s integer: NAs = FALSE, lag = 2, differences = 4, setNames = 0, useNames = 1 348s Named int [1:2] 9 -41 348s - attr(*, "names")= chr [1:2] "I" "J" 348s Named int [1:2] 9 -41 348s - attr(*, "names")= chr [1:2] "I" "J" 348s integer: NAs = FALSE, lag = 3, differences = 1, setNames = 0, useNames = 1 348s Named int [1:7] -11 -2 -5 -3 7 3 3 348s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 348s Named int [1:7] -11 -2 -5 -3 7 3 3 348s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 348s integer: NAs = FALSE, lag = 3, differences = 2, setNames = 0, useNames = 1 348s Named int [1:4] 8 9 8 6 348s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 348s Named int [1:4] 8 9 8 6 348s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 348s integer: NAs = FALSE, lag = 3, differences = 3, setNames = 0, useNames = 1 348s Named int -2 348s - attr(*, "names")= chr "J" 348s Named int -2 348s - attr(*, "names")= chr "J" 348s integer: NAs = FALSE, lag = 3, differences = 4, setNames = 0, useNames = 1 348s Named int(0) 348s - attr(*, "names")= chr(0) 348s Named int(0) 348s - attr(*, "names")= chr(0) 348s integer: NAs = FALSE, lag = 1, differences = 1, setNames = 0, useNames = 0 348s int [1:9] -10 1 -2 -1 -2 0 9 -6 0 348s int [1:9] -10 1 -2 -1 -2 0 9 -6 0 348s integer: NAs = FALSE, lag = 1, differences = 2, setNames = 0, useNames = 0 348s int [1:8] 11 -3 1 -1 2 9 -15 6 348s int [1:8] 11 -3 1 -1 2 9 -15 6 348s integer: NAs = FALSE, lag = 1, differences = 3, setNames = 0, useNames = 0 348s int [1:7] -14 4 -2 3 7 -24 21 348s int [1:7] -14 4 -2 3 7 -24 21 348s integer: NAs = FALSE, lag = 1, differences = 4, setNames = 0, useNames = 0 348s int [1:6] 18 -6 5 4 -31 45 348s int [1:6] 18 -6 5 4 -31 45 348s integer: NAs = FALSE, lag = 2, differences = 1, setNames = 0, useNames = 0 348s int [1:8] -9 -1 -3 -3 -2 9 3 -6 348s int [1:8] -9 -1 -3 -3 -2 9 3 -6 348s integer: NAs = FALSE, lag = 2, differences = 2, setNames = 0, useNames = 0 348s int [1:6] 6 -2 1 12 5 -15 348s int [1:6] 6 -2 1 12 5 -15 348s integer: NAs = FALSE, lag = 2, differences = 3, setNames = 0, useNames = 0 348s int [1:4] -5 14 4 -27 348s int [1:4] -5 14 4 -27 348s integer: NAs = FALSE, lag = 2, differences = 4, setNames = 0, useNames = 0 348s int [1:2] 9 -41 348s int [1:2] 9 -41 348s integer: NAs = FALSE, lag = 3, differences = 1, setNames = 0, useNames = 0 348s int [1:7] -11 -2 -5 -3 7 3 3 348s int [1:7] -11 -2 -5 -3 7 3 3 348s integer: NAs = FALSE, lag = 3, differences = 2, setNames = 0, useNames = 0 348s int [1:4] 8 9 8 6 348s int [1:4] 8 9 8 6 348s integer: NAs = FALSE, lag = 3, differences = 3, setNames = 0, useNames = 0 348s int -2 348s int -2 348s integer: NAs = FALSE, lag = 3, differences = 4, setNames = 0, useNames = 0 348s int(0) 348s int(0) 348s integer: NAs = TRUE, lag = 1, differences = 1, setNames = 1, useNames = 1 348s Named int [1:9] NA NA NA NA NA 0 9 -6 0 348s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 348s Named int [1:9] NA NA NA NA NA 0 9 -6 0 348s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 348s integer: NAs = TRUE, lag = 1, differences = 2, setNames = 1, useNames = 1 348s Named int [1:8] NA NA NA NA NA 9 -15 6 348s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 348s Named int [1:8] NA NA NA NA NA 9 -15 6 348s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 349s integer: NAs = TRUE, lag = 1, differences = 3, setNames = 1, useNames = 1 349s Named int [1:7] NA NA NA NA NA -24 21 349s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 349s Named int [1:7] NA NA NA NA NA -24 21 349s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 349s integer: NAs = TRUE, lag = 1, differences = 4, setNames = 1, useNames = 1 349s Named int [1:6] NA NA NA NA NA 45 349s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 349s Named int [1:6] NA NA NA NA NA 45 349s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 349s integer: NAs = TRUE, lag = 2, differences = 1, setNames = 1, useNames = 1 349s Named int [1:8] -9 NA NA NA NA 9 3 -6 349s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 349s Named int [1:8] -9 NA NA NA NA 9 3 -6 349s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 349s integer: NAs = TRUE, lag = 2, differences = 2, setNames = 1, useNames = 1 349s Named int [1:6] NA NA NA NA NA -15 349s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 349s Named int [1:6] NA NA NA NA NA -15 349s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 349s integer: NAs = TRUE, lag = 2, differences = 3, setNames = 1, useNames = 1 349s Named int [1:4] NA NA NA NA 349s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 349s Named int [1:4] NA NA NA NA 349s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 349s integer: NAs = TRUE, lag = 2, differences = 4, setNames = 1, useNames = 1 349s Named int [1:2] NA NA 349s - attr(*, "names")= chr [1:2] "I" "J" 349s Named int [1:2] NA NA 349s - attr(*, "names")= chr [1:2] "I" "J" 349s integer: NAs = TRUE, lag = 3, differences = 1, setNames = 1, useNames = 1 349s Named int [1:7] NA NA -5 NA NA 3 3 349s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 349s Named int [1:7] NA NA -5 NA NA 3 3 349s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 349s integer: NAs = TRUE, lag = 3, differences = 2, setNames = 1, useNames = 1 349s Named int [1:4] NA NA 8 NA 349s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 349s Named int [1:4] NA NA 8 NA 349s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 349s integer: NAs = TRUE, lag = 3, differences = 3, setNames = 1, useNames = 1 349s Named int NA 349s - attr(*, "names")= chr "J" 349s Named int NA 349s - attr(*, "names")= chr "J" 349s integer: NAs = TRUE, lag = 3, differences = 4, setNames = 1, useNames = 1 349s Named int(0) 349s - attr(*, "names")= chr(0) 349s Named int(0) 349s - attr(*, "names")= chr(0) 349s integer: NAs = TRUE, lag = 1, differences = 1, setNames = 1, useNames = 0 349s int [1:9] NA NA NA NA NA 0 9 NA NA 349s int [1:9] NA NA NA NA NA 0 9 NA NA 349s integer: NAs = TRUE, lag = 1, differences = 2, setNames = 1, useNames = 0 349s int [1:8] NA NA NA NA NA 9 NA NA 349s int [1:8] NA NA NA NA NA 9 NA NA 349s integer: NAs = TRUE, lag = 1, differences = 3, setNames = 1, useNames = 0 349s int [1:7] NA NA NA NA NA NA NA 349s int [1:7] NA NA NA NA NA NA NA 349s integer: NAs = TRUE, lag = 1, differences = 4, setNames = 1, useNames = 0 349s int [1:6] NA NA NA NA NA NA 349s int [1:6] NA NA NA NA NA NA 349s integer: NAs = TRUE, lag = 2, differences = 1, setNames = 1, useNames = 0 349s int [1:8] NA NA NA NA NA 9 NA -6 349s int [1:8] NA NA NA NA NA 9 NA -6 349s integer: NAs = TRUE, lag = 2, differences = 2, setNames = 1, useNames = 0 349s int [1:6] NA NA NA NA NA -15 349s int [1:6] NA NA NA NA NA -15 349s integer: NAs = TRUE, lag = 2, differences = 3, setNames = 1, useNames = 0 349s int [1:4] NA NA NA NA 349s int [1:4] NA NA NA NA 349s integer: NAs = TRUE, lag = 2, differences = 4, setNames = 1, useNames = 0 349s int [1:2] NA NA 349s int [1:2] NA NA 349s integer: NAs = TRUE, lag = 3, differences = 1, setNames = 1, useNames = 0 349s int [1:7] NA NA NA NA NA NA 3 349s int [1:7] NA NA NA NA NA NA 3 349s integer: NAs = TRUE, lag = 3, differences = 2, setNames = 1, useNames = 0 349s int [1:4] NA NA NA NA 349s int [1:4] NA NA NA NA 349s integer: NAs = TRUE, lag = 3, differences = 3, setNames = 1, useNames = 0 349s int NA 349s int NA 349s integer: NAs = TRUE, lag = 3, differences = 4, setNames = 1, useNames = 0 349s int(0) 349s int(0) 349s integer: NAs = TRUE, lag = 1, differences = 1, setNames = 0, useNames = 1 349s Named int [1:9] NA NA NA NA NA NA NA NA NA 349s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 349s Named int [1:9] NA NA NA NA NA NA NA NA NA 349s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 349s integer: NAs = TRUE, lag = 1, differences = 2, setNames = 0, useNames = 1 349s Named int [1:8] NA NA NA NA NA NA NA NA 349s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 349s Named int [1:8] NA NA NA NA NA NA NA NA 349s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 349s integer: NAs = TRUE, lag = 1, differences = 3, setNames = 0, useNames = 1 349s Named int [1:7] NA NA NA NA NA NA NA 349s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 349s Named int [1:7] NA NA NA NA NA NA NA 349s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 349s integer: NAs = TRUE, lag = 1, differences = 4, setNames = 0, useNames = 1 349s Named int [1:6] NA NA NA NA NA NA 349s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 349s Named int [1:6] NA NA NA NA NA NA 349s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 349s integer: NAs = TRUE, lag = 2, differences = 1, setNames = 0, useNames = 1 349s Named int [1:8] NA NA NA NA NA NA NA NA 349s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 349s Named int [1:8] NA NA NA NA NA NA NA NA 349s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 349s integer: NAs = TRUE, lag = 2, differences = 2, setNames = 0, useNames = 1 349s Named int [1:6] NA NA NA NA NA NA 349s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 349s Named int [1:6] NA NA NA NA NA NA 349s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 349s integer: NAs = TRUE, lag = 2, differences = 3, setNames = 0, useNames = 1 349s Named int [1:4] NA NA NA NA 349s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 349s Named int [1:4] NA NA NA NA 349s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 349s integer: NAs = TRUE, lag = 2, differences = 4, setNames = 0, useNames = 1 349s Named int [1:2] NA NA 349s - attr(*, "names")= chr [1:2] "I" "J" 349s Named int [1:2] NA NA 349s - attr(*, "names")= chr [1:2] "I" "J" 349s integer: NAs = TRUE, lag = 3, differences = 1, setNames = 0, useNames = 1 349s Named int [1:7] NA NA NA NA NA NA 3 349s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 349s Named int [1:7] NA NA NA NA NA NA 3 349s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 349s integer: NAs = TRUE, lag = 3, differences = 2, setNames = 0, useNames = 1 349s Named int [1:4] NA NA NA NA 349s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 349s Named int [1:4] NA NA NA NA 349s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 349s integer: NAs = TRUE, lag = 3, differences = 3, setNames = 0, useNames = 1 349s Named int NA 349s - attr(*, "names")= chr "J" 349s Named int NA 349s - attr(*, "names")= chr "J" 349s integer: NAs = TRUE, lag = 3, differences = 4, setNames = 0, useNames = 1 349s Named int(0) 349s - attr(*, "names")= chr(0) 349s Named int(0) 349s - attr(*, "names")= chr(0) 349s integer: NAs = TRUE, lag = 1, differences = 1, setNames = 0, useNames = 0 349s int [1:9] NA NA NA NA NA NA NA NA NA 349s int [1:9] NA NA NA NA NA NA NA NA NA 349s integer: NAs = TRUE, lag = 1, differences = 2, setNames = 0, useNames = 0 349s int [1:8] NA NA NA NA NA NA NA NA 349s int [1:8] NA NA NA NA NA NA NA NA 349s integer: NAs = TRUE, lag = 1, differences = 3, setNames = 0, useNames = 0 349s int [1:7] NA NA NA NA NA NA NA 349s int [1:7] NA NA NA NA NA NA NA 349s integer: NAs = TRUE, lag = 1, differences = 4, setNames = 0, useNames = 0 349s int [1:6] NA NA NA NA NA NA 349s int [1:6] NA NA NA NA NA NA 349s integer: NAs = TRUE, lag = 2, differences = 1, setNames = 0, useNames = 0 349s int [1:8] NA NA NA NA NA NA NA NA 349s int [1:8] NA NA NA NA NA NA NA NA 349s integer: NAs = TRUE, lag = 2, differences = 2, setNames = 0, useNames = 0 349s int [1:6] NA NA NA NA NA NA 349s int [1:6] NA NA NA NA NA NA 349s integer: NAs = TRUE, lag = 2, differences = 3, setNames = 0, useNames = 0 349s int [1:4] NA NA NA NA 349s int [1:4] NA NA NA NA 349s integer: NAs = TRUE, lag = 2, differences = 4, setNames = 0, useNames = 0 349s int [1:2] NA NA 349s int [1:2] NA NA 349s integer: NAs = TRUE, lag = 3, differences = 1, setNames = 0, useNames = 0 349s int [1:7] NA NA NA NA NA NA 3 349s int [1:7] NA NA NA NA NA NA 3 349s integer: NAs = TRUE, lag = 3, differences = 2, setNames = 0, useNames = 0 349s int [1:4] NA NA NA NA 349s int [1:4] NA NA NA NA 349s integer: NAs = TRUE, lag = 3, differences = 3, setNames = 0, useNames = 0 349s int NA 349s int NA 349s integer: NAs = TRUE, lag = 3, differences = 4, setNames = 0, useNames = 0 349s int(0) 349s int(0) 349s num [1:10] 2.586 -0.344 0.33 9.155 -3.254 ... 349s double: NAs = FALSE, lag = 1, differences = 1, setNames = 1, useNames = 1 349s Named num [1:9] -2.929 0.673 8.826 -12.409 -1.221 ... 349s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 349s Named num [1:9] -2.929 0.673 8.826 -12.409 -1.221 ... 349s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 349s double: NAs = FALSE, lag = 1, differences = 2, setNames = 1, useNames = 1 349s Named num [1:8] 3.6 8.15 -21.23 11.19 -2.1 ... 349s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 349s Named num [1:8] 3.6 8.15 -21.23 11.19 -2.1 ... 349s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 349s double: NAs = FALSE, lag = 1, differences = 3, setNames = 1, useNames = 1 349s Named num [1:7] 4.55 -29.39 32.42 -13.29 14.97 ... 349s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 349s Named num [1:7] 4.55 -29.39 32.42 -13.29 14.97 ... 349s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 349s double: NAs = FALSE, lag = 1, differences = 4, setNames = 1, useNames = 1 349s Named num [1:6] -33.9 61.8 -45.7 28.3 -37 ... 349s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 349s Named num [1:6] -33.9 61.8 -45.7 28.3 -37 ... 349s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 349s double: NAs = FALSE, lag = 2, differences = 1, setNames = 1, useNames = 1 349s Named num [1:8] -2.26 9.5 -3.58 -13.63 -4.54 ... 349s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 349s Named num [1:8] -2.26 9.5 -3.58 -13.63 -4.54 ... 349s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 349s double: NAs = FALSE, lag = 2, differences = 2, setNames = 1, useNames = 1 349s Named num [1:6] -1.33 -23.13 -0.96 19.86 14.44 ... 349s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 349s Named num [1:6] -1.33 -23.13 -0.96 19.86 14.44 ... 349s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 349s double: NAs = FALSE, lag = 2, differences = 3, setNames = 1, useNames = 1 349s Named num [1:4] 0.368 42.988 15.396 -29.313 349s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 349s Named num [1:4] 0.368 42.988 15.396 -29.313 349s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 349s double: NAs = FALSE, lag = 2, differences = 4, setNames = 1, useNames = 1 349s Named num [1:2] 15 -72.3 349s - attr(*, "names")= chr [1:2] "I" "J" 349s Named num [1:2] 15 -72.3 349s - attr(*, "names")= chr [1:2] "I" "J" 349s double: NAs = FALSE, lag = 3, differences = 1, setNames = 1, useNames = 1 349s Named num [1:7] 6.57 -2.91 -4.81 -16.95 5.01 ... 349s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 349s Named num [1:7] 6.57 -2.91 -4.81 -16.95 5.01 ... 349s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 349s double: NAs = FALSE, lag = 3, differences = 2, setNames = 1, useNames = 1 349s Named num [1:4] -23.52 7.92 11.38 23.27 349s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 349s Named num [1:4] -23.52 7.92 11.38 23.27 349s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 349s double: NAs = FALSE, lag = 3, differences = 3, setNames = 1, useNames = 1 349s Named num 46.8 349s - attr(*, "names")= chr "J" 349s Named num 46.8 349s - attr(*, "names")= chr "J" 349s double: NAs = FALSE, lag = 3, differences = 4, setNames = 1, useNames = 1 349s Named num(0) 349s - attr(*, "names")= chr(0) 349s Named num(0) 349s - attr(*, "names")= chr(0) 349s double: NAs = FALSE, lag = 1, differences = 1, setNames = 1, useNames = 0 349s num [1:9] -2.929 0.673 8.826 -12.409 -1.221 ... 349s num [1:9] -2.929 0.673 8.826 -12.409 -1.221 ... 349s double: NAs = FALSE, lag = 1, differences = 2, setNames = 1, useNames = 0 349s num [1:8] 3.6 8.15 -21.23 11.19 -2.1 ... 349s num [1:8] 3.6 8.15 -21.23 11.19 -2.1 ... 349s double: NAs = FALSE, lag = 1, differences = 3, setNames = 1, useNames = 0 349s num [1:7] 4.55 -29.39 32.42 -13.29 14.97 ... 349s num [1:7] 4.55 -29.39 32.42 -13.29 14.97 ... 349s double: NAs = FALSE, lag = 1, differences = 4, setNames = 1, useNames = 0 349s num [1:6] -33.9 61.8 -45.7 28.3 -37 ... 349s num [1:6] -33.9 61.8 -45.7 28.3 -37 ... 349s double: NAs = FALSE, lag = 2, differences = 1, setNames = 1, useNames = 0 349s num [1:8] -2.26 9.5 -3.58 -13.63 -4.54 ... 349s num [1:8] -2.26 9.5 -3.58 -13.63 -4.54 ... 349s double: NAs = FALSE, lag = 2, differences = 2, setNames = 1, useNames = 0 349s num [1:6] -1.33 -23.13 -0.96 19.86 14.44 ... 349s num [1:6] -1.33 -23.13 -0.96 19.86 14.44 ... 349s double: NAs = FALSE, lag = 2, differences = 3, setNames = 1, useNames = 0 349s num [1:4] 0.368 42.988 15.396 -29.313 349s num [1:4] 0.368 42.988 15.396 -29.313 349s double: NAs = FALSE, lag = 2, differences = 4, setNames = 1, useNames = 0 349s num [1:2] 15 -72.3 349s num [1:2] 15 -72.3 349s double: NAs = FALSE, lag = 3, differences = 1, setNames = 1, useNames = 0 349s num [1:7] 6.57 -2.91 -4.81 -16.95 5.01 ... 349s num [1:7] 6.57 -2.91 -4.81 -16.95 5.01 ... 349s double: NAs = FALSE, lag = 3, differences = 2, setNames = 1, useNames = 0 349s num [1:4] -23.52 7.92 11.38 23.27 349s num [1:4] -23.52 7.92 11.38 23.27 349s double: NAs = FALSE, lag = 3, differences = 3, setNames = 1, useNames = 0 349s num 46.8 349s num 46.8 349s double: NAs = FALSE, lag = 3, differences = 4, setNames = 1, useNames = 0 349s num(0) 349s num(0) 349s double: NAs = FALSE, lag = 1, differences = 1, setNames = 0, useNames = 1 349s Named num [1:9] -2.929 0.673 8.826 -12.409 -1.221 ... 349s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 349s Named num [1:9] -2.929 0.673 8.826 -12.409 -1.221 ... 349s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 349s double: NAs = FALSE, lag = 1, differences = 2, setNames = 0, useNames = 1 349s Named num [1:8] 3.6 8.15 -21.23 11.19 -2.1 ... 349s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 349s Named num [1:8] 3.6 8.15 -21.23 11.19 -2.1 ... 349s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 349s double: NAs = FALSE, lag = 1, differences = 3, setNames = 0, useNames = 1 349s Named num [1:7] 4.55 -29.39 32.42 -13.29 14.97 ... 349s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 349s Named num [1:7] 4.55 -29.39 32.42 -13.29 14.97 ... 349s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 349s double: NAs = FALSE, lag = 1, differences = 4, setNames = 0, useNames = 1 349s Named num [1:6] -33.9 61.8 -45.7 28.3 -37 ... 349s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 349s Named num [1:6] -33.9 61.8 -45.7 28.3 -37 ... 349s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 349s double: NAs = FALSE, lag = 2, differences = 1, setNames = 0, useNames = 1 349s Named num [1:8] -2.26 9.5 -3.58 -13.63 -4.54 ... 349s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 349s Named num [1:8] -2.26 9.5 -3.58 -13.63 -4.54 ... 349s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 349s double: NAs = FALSE, lag = 2, differences = 2, setNames = 0, useNames = 1 349s Named num [1:6] -1.33 -23.13 -0.96 19.86 14.44 ... 349s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 349s Named num [1:6] -1.33 -23.13 -0.96 19.86 14.44 ... 349s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 349s double: NAs = FALSE, lag = 2, differences = 3, setNames = 0, useNames = 1 349s Named num [1:4] 0.368 42.988 15.396 -29.313 349s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 349s Named num [1:4] 0.368 42.988 15.396 -29.313 349s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 349s double: NAs = FALSE, lag = 2, differences = 4, setNames = 0, useNames = 1 349s Named num [1:2] 15 -72.3 349s - attr(*, "names")= chr [1:2] "I" "J" 349s Named num [1:2] 15 -72.3 349s - attr(*, "names")= chr [1:2] "I" "J" 349s double: NAs = FALSE, lag = 3, differences = 1, setNames = 0, useNames = 1 349s Named num [1:7] 6.57 -2.91 -4.81 -16.95 5.01 ... 349s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 349s Named num [1:7] 6.57 -2.91 -4.81 -16.95 5.01 ... 349s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 349s double: NAs = FALSE, lag = 3, differences = 2, setNames = 0, useNames = 1 349s Named num [1:4] -23.52 7.92 11.38 23.27 349s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 349s Named num [1:4] -23.52 7.92 11.38 23.27 349s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 349s double: NAs = FALSE, lag = 3, differences = 3, setNames = 0, useNames = 1 349s Named num 46.8 349s - attr(*, "names")= chr "J" 349s Named num 46.8 349s - attr(*, "names")= chr "J" 349s double: NAs = FALSE, lag = 3, differences = 4, setNames = 0, useNames = 1 349s Named num(0) 349s - attr(*, "names")= chr(0) 349s Named num(0) 349s - attr(*, "names")= chr(0) 349s double: NAs = FALSE, lag = 1, differences = 1, setNames = 0, useNames = 0 349s num [1:9] -2.929 0.673 8.826 -12.409 -1.221 ... 349s num [1:9] -2.929 0.673 8.826 -12.409 -1.221 ... 349s double: NAs = FALSE, lag = 1, differences = 2, setNames = 0, useNames = 0 349s num [1:8] 3.6 8.15 -21.23 11.19 -2.1 ... 349s num [1:8] 3.6 8.15 -21.23 11.19 -2.1 ... 349s double: NAs = FALSE, lag = 1, differences = 3, setNames = 0, useNames = 0 349s num [1:7] 4.55 -29.39 32.42 -13.29 14.97 ... 349s num [1:7] 4.55 -29.39 32.42 -13.29 14.97 ... 349s double: NAs = FALSE, lag = 1, differences = 4, setNames = 0, useNames = 0 349s num [1:6] -33.9 61.8 -45.7 28.3 -37 ... 349s num [1:6] -33.9 61.8 -45.7 28.3 -37 ... 349s double: NAs = FALSE, lag = 2, differences = 1, setNames = 0, useNames = 0 349s num [1:8] -2.26 9.5 -3.58 -13.63 -4.54 ... 349s num [1:8] -2.26 9.5 -3.58 -13.63 -4.54 ... 349s double: NAs = FALSE, lag = 2, differences = 2, setNames = 0, useNames = 0 349s num [1:6] -1.33 -23.13 -0.96 19.86 14.44 ... 349s num [1:6] -1.33 -23.13 -0.96 19.86 14.44 ... 349s double: NAs = FALSE, lag = 2, differences = 3, setNames = 0, useNames = 0 349s num [1:4] 0.368 42.988 15.396 -29.313 349s num [1:4] 0.368 42.988 15.396 -29.313 349s double: NAs = FALSE, lag = 2, differences = 4, setNames = 0, useNames = 0 349s num [1:2] 15 -72.3 349s num [1:2] 15 -72.3 349s double: NAs = FALSE, lag = 3, differences = 1, setNames = 0, useNames = 0 349s num [1:7] 6.57 -2.91 -4.81 -16.95 5.01 ... 349s num [1:7] 6.57 -2.91 -4.81 -16.95 5.01 ... 349s double: NAs = FALSE, lag = 3, differences = 2, setNames = 0, useNames = 0 349s num [1:4] -23.52 7.92 11.38 23.27 349s num [1:4] -23.52 7.92 11.38 23.27 349s double: NAs = FALSE, lag = 3, differences = 3, setNames = 0, useNames = 0 349s num 46.8 349s num 46.8 349s double: NAs = FALSE, lag = 3, differences = 4, setNames = 0, useNames = 0 349s num(0) 349s num(0) 349s double: NAs = TRUE, lag = 1, differences = 1, setNames = 1, useNames = 1 349s Named num [1:9] -2.929 0.673 8.826 NA NA ... 349s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 349s Named num [1:9] -2.929 0.673 8.826 NA NA ... 349s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 349s double: NAs = TRUE, lag = 1, differences = 2, setNames = 1, useNames = 1 349s Named num [1:8] 3.6 8.15 NA NA NA ... 349s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 349s Named num [1:8] 3.6 8.15 NA NA NA ... 349s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 349s double: NAs = TRUE, lag = 1, differences = 3, setNames = 1, useNames = 1 349s Named num [1:7] 4.55 NA NA NA NA ... 349s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 349s Named num [1:7] 4.55 NA NA NA NA ... 349s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 349s double: NAs = TRUE, lag = 1, differences = 4, setNames = 1, useNames = 1 349s Named num [1:6] NA NA NA NA NA NA 349s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 349s Named num [1:6] NA NA NA NA NA NA 349s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 349s double: NAs = TRUE, lag = 2, differences = 1, setNames = 1, useNames = 1 349s Named num [1:8] -2.26 9.5 NA NA NA ... 349s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 349s Named num [1:8] -2.26 9.5 NA NA NA ... 349s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 349s double: NAs = TRUE, lag = 2, differences = 2, setNames = 1, useNames = 1 349s Named num [1:6] NA NA NA NA NA NA 349s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 349s Named num [1:6] NA NA NA NA NA NA 349s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 349s double: NAs = TRUE, lag = 2, differences = 3, setNames = 1, useNames = 1 349s Named num [1:4] NA NA NA NA 349s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 349s Named num [1:4] NA NA NA NA 349s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 349s double: NAs = TRUE, lag = 2, differences = 4, setNames = 1, useNames = 1 349s Named num [1:2] NA NA 349s - attr(*, "names")= chr [1:2] "I" "J" 349s Named num [1:2] NA NA 349s - attr(*, "names")= chr [1:2] "I" "J" 349s double: NAs = TRUE, lag = 3, differences = 1, setNames = 1, useNames = 1 349s Named num [1:7] 6.57 NA NA -16.95 NA ... 349s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 349s Named num [1:7] 6.57 NA NA -16.95 NA ... 349s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 349s double: NAs = TRUE, lag = 3, differences = 2, setNames = 1, useNames = 1 349s Named num [1:4] -23.5 NA NA 23.3 349s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 349s Named num [1:4] -23.5 NA NA 23.3 349s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 349s double: NAs = TRUE, lag = 3, differences = 3, setNames = 1, useNames = 1 349s Named num 46.8 349s - attr(*, "names")= chr "J" 349s Named num 46.8 349s - attr(*, "names")= chr "J" 349s double: NAs = TRUE, lag = 3, differences = 4, setNames = 1, useNames = 1 349s Named num(0) 349s - attr(*, "names")= chr(0) 349s Named num(0) 349s - attr(*, "names")= chr(0) 349s double: NAs = TRUE, lag = 1, differences = 1, setNames = 1, useNames = 0 349s num [1:9] NA 0.673 8.826 NA NA ... 349s num [1:9] NA 0.673 8.826 NA NA ... 349s double: NAs = TRUE, lag = 1, differences = 2, setNames = 1, useNames = 0 349s num [1:8] NA 8.15 NA NA NA ... 349s num [1:8] NA 8.15 NA NA NA ... 349s double: NAs = TRUE, lag = 1, differences = 3, setNames = 1, useNames = 0 349s num [1:7] NA NA NA NA NA NA NA 349s num [1:7] NA NA NA NA NA NA NA 349s double: NAs = TRUE, lag = 1, differences = 4, setNames = 1, useNames = 0 349s num [1:6] NA NA NA NA NA NA 349s num [1:6] NA NA NA NA NA NA 349s double: NAs = TRUE, lag = 2, differences = 1, setNames = 1, useNames = 0 349s num [1:8] NA 9.5 NA NA NA ... 349s num [1:8] NA 9.5 NA NA NA ... 349s double: NAs = TRUE, lag = 2, differences = 2, setNames = 1, useNames = 0 349s num [1:6] NA NA NA NA NA NA 349s num [1:6] NA NA NA NA NA NA 349s double: NAs = TRUE, lag = 2, differences = 3, setNames = 1, useNames = 0 349s num [1:4] NA NA NA NA 349s num [1:4] NA NA NA NA 349s double: NAs = TRUE, lag = 2, differences = 4, setNames = 1, useNames = 0 349s num [1:2] NA NA 349s num [1:2] NA NA 349s double: NAs = TRUE, lag = 3, differences = 1, setNames = 1, useNames = 0 349s num [1:7] NA NA NA NA NA NA NA 349s num [1:7] NA NA NA NA NA NA NA 349s double: NAs = TRUE, lag = 3, differences = 2, setNames = 1, useNames = 0 349s num [1:4] NA NA NA NA 349s num [1:4] NA NA NA NA 349s double: NAs = TRUE, lag = 3, differences = 3, setNames = 1, useNames = 0 349s num NA 349s num NA 349s double: NAs = TRUE, lag = 3, differences = 4, setNames = 1, useNames = 0 349s num(0) 349s num(0) 349s double: NAs = TRUE, lag = 1, differences = 1, setNames = 0, useNames = 1 349s Named num [1:9] NA 0.673 8.826 NA NA ... 349s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 349s Named num [1:9] NA 0.673 8.826 NA NA ... 349s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 349s double: NAs = TRUE, lag = 1, differences = 2, setNames = 0, useNames = 1 349s Named num [1:8] NA 8.15 NA NA NA ... 349s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 349s Named num [1:8] NA 8.15 NA NA NA ... 349s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 349s double: NAs = TRUE, lag = 1, differences = 3, setNames = 0, useNames = 1 349s Named num [1:7] NA NA NA NA NA NA NA 349s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 349s Named num [1:7] NA NA NA NA NA NA NA 349s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 349s double: NAs = TRUE, lag = 1, differences = 4, setNames = 0, useNames = 1 349s Named num [1:6] NA NA NA NA NA NA 349s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 349s Named num [1:6] NA NA NA NA NA NA 349s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 349s double: NAs = TRUE, lag = 2, differences = 1, setNames = 0, useNames = 1 349s Named num [1:8] NA 9.5 NA NA NA ... 349s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 349s Named num [1:8] NA 9.5 NA NA NA ... 349s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 349s double: NAs = TRUE, lag = 2, differences = 2, setNames = 0, useNames = 1 349s Named num [1:6] NA NA NA NA NA NA 349s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 349s Named num [1:6] NA NA NA NA NA NA 349s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 349s double: NAs = TRUE, lag = 2, differences = 3, setNames = 0, useNames = 1 349s Named num [1:4] NA NA NA NA 349s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 349s Named num [1:4] NA NA NA NA 349s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 349s double: NAs = TRUE, lag = 2, differences = 4, setNames = 0, useNames = 1 349s Named num [1:2] NA NA 349s - attr(*, "names")= chr [1:2] "I" "J" 349s Named num [1:2] NA NA 349s - attr(*, "names")= chr [1:2] "I" "J" 349s double: NAs = TRUE, lag = 3, differences = 1, setNames = 0, useNames = 1 349s Named num [1:7] NA NA NA NA NA NA NA 349s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 349s Named num [1:7] NA NA NA NA NA NA NA 349s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 349s double: NAs = TRUE, lag = 3, differences = 2, setNames = 0, useNames = 1 349s Named num [1:4] NA NA NA NA 349s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 349s Named num [1:4] NA NA NA NA 349s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 349s double: NAs = TRUE, lag = 3, differences = 3, setNames = 0, useNames = 1 349s Named num NA 349s - attr(*, "names")= chr "J" 349s Named num NA 349s - attr(*, "names")= chr "J" 349s double: NAs = TRUE, lag = 3, differences = 4, setNames = 0, useNames = 1 349s Named num(0) 349s - attr(*, "names")= chr(0) 349s Named num(0) 349s - attr(*, "names")= chr(0) 349s double: NAs = TRUE, lag = 1, differences = 1, setNames = 0, useNames = 0 349s num [1:9] NA 0.673 8.826 NA NA ... 349s num [1:9] NA 0.673 8.826 NA NA ... 349s double: NAs = TRUE, lag = 1, differences = 2, setNames = 0, useNames = 0 349s num [1:8] NA 8.15 NA NA NA ... 349s num [1:8] NA 8.15 NA NA NA ... 349s double: NAs = TRUE, lag = 1, differences = 3, setNames = 0, useNames = 0 349s num [1:7] NA NA NA NA NA NA NA 349s num [1:7] NA NA NA NA NA NA NA 349s double: NAs = TRUE, lag = 1, differences = 4, setNames = 0, useNames = 0 349s num [1:6] NA NA NA NA NA NA 349s num [1:6] NA NA NA NA NA NA 349s double: NAs = TRUE, lag = 2, differences = 1, setNames = 0, useNames = 0 349s num [1:8] NA 9.5 NA NA NA ... 349s num [1:8] NA 9.5 NA NA NA ... 349s double: NAs = TRUE, lag = 2, differences = 2, setNames = 0, useNames = 0 349s num [1:6] NA NA NA NA NA NA 349s num [1:6] NA NA NA NA NA NA 349s double: NAs = TRUE, lag = 2, differences = 3, setNames = 0, useNames = 0 349s num [1:4] NA NA NA NA 349s num [1:4] NA NA NA NA 349s double: NAs = TRUE, lag = 2, differences = 4, setNames = 0, useNames = 0 349s num [1:2] NA NA 349s num [1:2] NA NA 349s double: NAs = TRUE, lag = 3, differences = 1, setNames = 0, useNames = 0 349s num [1:7] NA NA NA NA NA NA NA 349s num [1:7] NA NA NA NA NA NA NA 349s double: NAs = TRUE, lag = 3, differences = 2, setNames = 0, useNames = 0 349s num [1:4] NA NA NA NA 349s num [1:4] NA NA NA NA 349s double: NAs = TRUE, lag = 3, differences = 3, setNames = 0, useNames = 0 349s num NA 349s num NA 349s double: NAs = TRUE, lag = 3, differences = 4, setNames = 0, useNames = 0 349s num(0) 349s num(0) 349s > 349s 349s R version 4.4.3 (2025-02-28) -- "Trophy Case" 349s Copyright (C) 2025 The R Foundation for Statistical Computing 349s Platform: arm-unknown-linux-gnueabihf (32-bit) 349s 349s R is free software and comes with ABSOLUTELY NO WARRANTY. 349s You are welcome to redistribute it under certain conditions. 349s Type 'license()' or 'licence()' for distribution details. 349s 349s R is a collaborative project with many contributors. 349s Type 'contributors()' for more information and 349s 'citation()' on how to cite R or R packages in publications. 349s 349s Type 'demo()' for some demos, 'help()' for on-line help, or 349s 'help.start()' for an HTML browser interface to help. 349s Type 'q()' to quit R. 349s 349s > library("matrixStats") 349s > 349s > diff2_R <- function(..., useNames=NA){ 349s + res <- diff(...) 349s + if (!useNames) names(res) <- NULL 349s + res 349s + } 349s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 349s > # Subsetted tests 349s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 349s > source("utils/validateIndicesFramework.R") 349s > x <- runif(6, min = -6, max = 6) 349s > for (setNames in c(TRUE, FALSE)) { 349s + if (setNames) names(x) <- LETTERS[1:6] 349s + else names(x) <- NULL 349s + for (l in 1:2) { 349s + for (d in 1:2) { 349s + for (idxs in index_cases) { 349s + for (useNames in c(TRUE, FALSE)) { 349s + validateIndicesTestVector(x, idxs, 349s + ftest = diff2, fsure = diff2_R, 349s + lag = l, differences = d, useNames = useNames) 349s + } 349s + } 349s + } 349s + } 349s + } 349s > 349s 349s R version 4.4.3 (2025-02-28) -- "Trophy Case" 349s Copyright (C) 2025 The R Foundation for Statistical Computing 349s Platform: arm-unknown-linux-gnueabihf (32-bit) 349s 349s R is free software and comes with ABSOLUTELY NO WARRANTY. 349s You are welcome to redistribute it under certain conditions. 349s Type 'license()' or 'licence()' for distribution details. 349s 349s R is a collaborative project with many contributors. 349s Type 'contributors()' for more information and 349s 'citation()' on how to cite R or R packages in publications. 349s 349s Type 'demo()' for some demos, 'help()' for on-line help, or 349s 'help.start()' for an HTML browser interface to help. 349s Type 'q()' to quit R. 349s 349s > library("matrixStats") 349s > 349s > indexByRow_R1 <- function(dim, idxs = NULL, ...) { 349s + n <- prod(dim) 349s + x <- matrix(seq_len(n), nrow = dim[2L], ncol = dim[1L], byrow = TRUE) 349s + if (!is.null(idxs)) 349s + x <- x[idxs] 349s + as.vector(x) 349s + } 349s > 349s > 349s > indexByRow_R2 <- function(dim, idxs = NULL, ...) { 349s + n <- prod(dim) 349s + if (is.null(idxs)) { 349s + x <- matrix(seq_len(n), nrow = dim[2L], ncol = dim[1L], byrow = TRUE) 349s + as.vector(x) 349s + } else { 349s + idxs <- idxs - 1L 349s + cols <- idxs %/% dim[2L] 349s + rows <- idxs %% dim[2L] 349s + cols + dim[1L] * rows + 1L 349s + } 349s + } 349s > 349s > 349s > dim <- c(5L, 4L) 349s > x <- matrix(NA_integer_, nrow = dim[1L], ncol = dim[2L]) 349s > y <- t(x) 349s > idxs_by_cols <- seq_along(x) 349s > 349s > # Assign by columns 349s > x[idxs_by_cols] <- idxs_by_cols 349s > print(x) 349s [,1] [,2] [,3] [,4] 349s [1,] 1 6 11 16 349s [2,] 2 7 12 17 349s [3,] 3 8 13 18 349s [4,] 4 9 14 19 349s [5,] 5 10 15 20 349s > 349s > # Truth 349s > y0 <- t(x) 349s > idxs_by_rows <- as.vector(y0) 349s > 349s > # Assert 349s > idxs <- indexByRow(dim) 349s > stopifnot(all.equal(idxs, idxs_by_rows)) 349s > y <- x 349s > y[idxs_by_rows] <- idxs 349s > print(y) 349s [,1] [,2] [,3] [,4] 349s [1,] 1 6 11 16 349s [2,] 2 7 12 17 349s [3,] 3 8 13 18 349s [4,] 4 9 14 19 349s [5,] 5 10 15 20 349s > stopifnot(all(as.vector(y) == as.vector(x))) 349s > 349s > idxs_R1 <- indexByRow_R1(dim) 349s > stopifnot(all.equal(idxs_R1, idxs_by_rows)) 349s > 349s > idxs_R2 <- indexByRow_R2(dim) 349s > stopifnot(all.equal(idxs_R2, idxs_by_rows)) 349s > 349s > # Assert 349s > idxs_by_cols <- seq(from = 1, to = length(x), by = 3L) 349s > idxs_by_rows <- as.vector(t(x)[idxs_by_cols]) 349s > 349s > idxs <- indexByRow(dim, idxs = idxs_by_cols) 349s > stopifnot(all(idxs == idxs_by_rows)) 349s > 349s > idxs_R1 <- indexByRow_R1(dim, idxs = idxs_by_cols) 349s > stopifnot(all(idxs_R1 == idxs_by_rows)) 349s > 349s > idxs_R2 <- indexByRow_R2(dim, idxs = idxs_by_cols) 349s > stopifnot(all(idxs_R2 == idxs_by_rows)) 349s > 349s > 349s > ## DEFUNCT: Backward compatibility 349s > res <- tryCatch({ 349s + idxs1 <- indexByRow(x) 349s + }, error = identity) 349s > stopifnot(inherits(res, "error")) 349s > 349s > 349s > ## Exceptions: 349s > ## Too large matrices are not supported, which happens 349s > ## when prod(dim) > .Machine$integer.max 349s > dim_too_large <- c(.Machine$integer.max, 2L) 349s > res <- tryCatch({ 349s + idxs <- indexByRow(dim_too_large, idxs = 1L) 349s + }, error = identity) 349s > stopifnot(inherits(res, "error")) 349s > 349s > ## Non-positive indices are not supported 349s > res <- tryCatch({ 349s + idxs <- indexByRow(c(1,1), idxs = 0L) 349s + }, error = identity) 349s > stopifnot(inherits(res, "error")) 349s > 349s > res <- tryCatch({ 349s + idxs <- indexByRow(c(1,1), idxs = -1L) 349s + }, error = identity) 349s > stopifnot(inherits(res, "error")) 349s > 349s 349s R version 4.4.3 (2025-02-28) -- "Trophy Case" 349s Copyright (C) 2025 The R Foundation for Statistical Computing 349s Platform: arm-unknown-linux-gnueabihf (32-bit) 349s 349s R is free software and comes with ABSOLUTELY NO WARRANTY. 349s You are welcome to redistribute it under certain conditions. 349s Type 'license()' or 'licence()' for distribution details. 349s 349s R is a collaborative project with many contributors. 349s Type 'contributors()' for more information and 349s 'citation()' on how to cite R or R packages in publications. 349s 349s Type 'demo()' for some demos, 'help()' for on-line help, or 349s 'help.start()' for an HTML browser interface to help. 349s Type 'q()' to quit R. 349s 350s > library("matrixStats") 350s > library("stats") 350s > 350s > logSumExp_R <- function(lx, na.rm = FALSE) { 350s + log(sum(exp(lx), na.rm = na.rm)) 350s + } 350s > 350s > ## R-help thread \emph{'[R] Beyond double-precision?'} on May 9, 2009. 350s > 350s > for (mode in c("integer", "double")) { 350s + cat("mode: ", mode, "\n", sep = "") 350s + 350s + set.seed(1) 350s + x <- runif(20, min = 1.0, max = 3.0) 350s + storage.mode(x) <- mode 350s + str(x) 350s + 350s + ## The logarithm of the harmonic mean 350s + y0 <- log(1 / mean(1 / x)) 350s + print(y0) ## -1.600885 350s + 350s + lx <- log(x) 350s + y1 <- log(length(x)) - logSumExp(-lx) 350s + print(y1) ## [1] -1.600885 350s + 350s + # Sanity check 350s + stopifnot(all.equal(y1, y0)) 350s + 350s + y2 <- log(length(x)) - logSumExp_R(-lx) 350s + # Sanity check 350s + stopifnot(all.equal(y2, y0)) 350s + } # for (mode ...) 350s mode: integer 350s int [1:20] 1 1 2 2 1 2 2 2 2 1 ... 350s [1] 0.3215836 350s [1] 0.3215836 350s mode: double 350s num [1:20] 1.53 1.74 2.15 2.82 1.4 ... 350s [1] 0.6673156 350s [1] 0.6673156 350s > 350s > 350s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 350s > # Missing values 350s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 350s > ## NA values 350s > lx <- c(1, 2, 3) 350s > lx[2] <- NA_real_ 350s > y0 <- logSumExp_R(lx, na.rm = FALSE) 350s > y <- logSumExp(lx, na.rm = FALSE) 350s > print(y) 350s [1] NA 350s > stopifnot(identical(y, NA_real_)) 350s > stopifnot(all.equal(y, y0)) 350s > 350s > y0 <- logSumExp_R(lx, na.rm = TRUE) 350s > y <- logSumExp(lx, na.rm = TRUE) 350s > print(y) 350s [1] 3.126928 350s > stopifnot(all.equal(y, y0)) 350s > 350s > ## NaN values 350s > lx <- c(1, 2, 3) 350s > lx[2] <- NaN 350s > y0 <- logSumExp_R(lx, na.rm = FALSE) 350s > y <- logSumExp(lx, na.rm = FALSE) 350s > print(y) 350s [1] NA 350s > stopifnot(identical(y, NA_real_)) 350s > stopifnot(all.equal(y, y0)) 350s > 350s > y0 <- logSumExp_R(lx, na.rm = TRUE) 350s > y <- logSumExp(lx, na.rm = TRUE) 350s > print(y) 350s [1] 3.126928 350s > stopifnot(all.equal(y, y0)) 350s > 350s > 350s > 350s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 350s > # Corner cases 350s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 350s > ## Zero-length vectors 350s > lx <- numeric(0L) 350s > y0 <- logSumExp_R(lx) 350s > y <- logSumExp(lx) 350s > print(y) 350s [1] -Inf 350s > stopifnot(identical(y, -Inf)) 350s > stopifnot(all.equal(y, y0)) 350s > 350s > ## Vectors of length one 350s > lx <- 1.0 350s > y0 <- logSumExp_R(lx) 350s > y <- logSumExp(lx) 350s > print(y) 350s [1] 1 350s > stopifnot(identical(y, lx)) 350s > stopifnot(all.equal(y, y0)) 350s > 350s > lx <- NA_real_ 350s > y0 <- logSumExp_R(lx, na.rm = TRUE) 350s > y <- logSumExp(lx, na.rm = TRUE) 350s > print(y) 350s [1] -Inf 350s > stopifnot(identical(y, -Inf)) 350s > stopifnot(all.equal(y, y0)) 350s > 350s > ## All missing values 350s > lx <- c(NA_real_, NA_real_) 350s > y0 <- logSumExp_R(lx, na.rm = TRUE) 350s > y <- logSumExp(lx, na.rm = TRUE) 350s > print(y) 350s [1] -Inf 350s > stopifnot(identical(y, -Inf)) 350s > stopifnot(all.equal(y, y0)) 350s > 350s > lx <- c(NA_real_, NA_real_) 350s > y0 <- logSumExp_R(lx, na.rm = FALSE) 350s > y <- logSumExp(lx, na.rm = FALSE) 350s > print(y) 350s [1] NA 350s > stopifnot(identical(y, NA_real_)) 350s > stopifnot(all.equal(y, y0)) 350s > 350s > 350s > ## +Inf values 350s > lx <- c(1, 2, +Inf) 350s > y0 <- logSumExp_R(lx) 350s > y <- logSumExp(lx) 350s > print(y) 350s [1] Inf 350s > stopifnot(identical(y, +Inf)) 350s > stopifnot(all.equal(y, y0)) 350s > 350s > ## First element is a missing value, cf. PR #33 350s > lx <- c(NA_real_, 1) 350s > y0 <- logSumExp_R(lx) 350s > print(y0) 350s [1] NA 350s > y <- logSumExp(lx, na.rm = FALSE) 350s > print(y) 350s [1] NA 350s > stopifnot(identical(y, NA_real_)) 350s > stopifnot(all.equal(y, y0)) 350s > 350s > y0 <- logSumExp_R(lx, na.rm = TRUE) 350s > print(y0) 350s [1] 1 350s > y <- logSumExp(lx, na.rm = TRUE) 350s > print(y) 350s [1] 1 350s > stopifnot(identical(y, 1)) 350s > stopifnot(all.equal(y, y0)) 350s > 350s > ## Multiple -Inf values, cf. issue #84 350s > lx <- c(-Inf, -Inf) 350s > y0 <- logSumExp_R(lx) 350s > y <- logSumExp(lx) 350s > print(y) 350s [1] -Inf 350s > stopifnot(identical(y, -Inf)) 350s > stopifnot(all.equal(y, y0)) 350s > 350s > lx <- c(-Inf, 5, -Inf) 350s > y0 <- logSumExp_R(lx) 350s > y <- logSumExp(lx) 350s > print(y) 350s [1] 5 350s > stopifnot(identical(y, 5)) 350s > stopifnot(all.equal(y, y0)) 350s > 350s 350s R version 4.4.3 (2025-02-28) -- "Trophy Case" 350s Copyright (C) 2025 The R Foundation for Statistical Computing 350s Platform: arm-unknown-linux-gnueabihf (32-bit) 350s 350s R is free software and comes with ABSOLUTELY NO WARRANTY. 350s You are welcome to redistribute it under certain conditions. 350s Type 'license()' or 'licence()' for distribution details. 350s 350s R is a collaborative project with many contributors. 350s Type 'contributors()' for more information and 350s 'citation()' on how to cite R or R packages in publications. 350s 350s Type 'demo()' for some demos, 'help()' for on-line help, or 350s 'help.start()' for an HTML browser interface to help. 350s Type 'q()' to quit R. 350s 350s > library("matrixStats") 350s > 350s > logSumExp_R <- function(lx, na.rm = FALSE) { 350s + log(sum(exp(lx), na.rm = na.rm)) 350s + } 350s > 350s > 350s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 350s > # Subsetted tests 350s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 350s > source("utils/validateIndicesFramework.R") 350s > x <- runif(6, min = -6, max = 6) 350s > for (idxs in index_cases) { 350s + validateIndicesTestVector(x, idxs, 350s + ftest = logSumExp, fsure = logSumExp_R, 350s + na.rm = FALSE) 350s + validateIndicesTestVector(x, idxs, 350s + ftest = logSumExp, fsure = logSumExp_R, 350s + na.rm = TRUE) 350s + } 350s > 350s 350s R version 4.4.3 (2025-02-28) -- "Trophy Case" 350s Copyright (C) 2025 The R Foundation for Statistical Computing 350s Platform: arm-unknown-linux-gnueabihf (32-bit) 350s 350s R is free software and comes with ABSOLUTELY NO WARRANTY. 350s You are welcome to redistribute it under certain conditions. 350s Type 'license()' or 'licence()' for distribution details. 350s 350s R is a collaborative project with many contributors. 350s Type 'contributors()' for more information and 350s 'citation()' on how to cite R or R packages in publications. 350s 350s Type 'demo()' for some demos, 'help()' for on-line help, or 350s 'help.start()' for an HTML browser interface to help. 350s Type 'q()' to quit R. 350s 350s > library("matrixStats") 350s > 350s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 350s > # Consistency checks 350s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 350s > set.seed(1) 350s > 350s > mean2_R <- function(x, na.rm = FALSE, idxs = NULL) { 350s + if (is.null(idxs)) { 350s + mean(x, na.rm = na.rm) 350s + } else { 350s + mean(x[idxs], na.rm = na.rm) 350s + } 350s + } # mean2_R() 350s > 350s > 350s > cat("Consistency checks:\n") 350s Consistency checks: 350s > for (kk in 1:20) { 350s + cat("Random test #", kk, "\n", sep = "") 350s + 350s + # Simulate data in a matrix of any shape 350s + n <- sample(100L, size = 1L) 350s + x <- rnorm(n, sd = 100) 350s + 350s + # Add NAs? 350s + if ((kk %% 4) %in% c(3, 0)) { 350s + cat("Adding NAs\n") 350s + nna <- sample(n, size = 1L) 350s + na_values <- c(NA_real_, NaN) 350s + t <- sample(na_values, size = nna, replace = TRUE) 350s + x[sample(length(x), size = nna)] <- t 350s + } 350s + 350s + # Integer or double? 350s + if ((kk %% 4) %in% c(2, 0)) { 350s + cat("Coercing to integers\n") 350s + storage.mode(x) <- "integer" 350s + } 350s + 350s + na.rm <- sample(c(TRUE, FALSE), size = 1L) 350s + 350s + # Sum over all 350s + y0 <- mean2_R(x, na.rm = na.rm) 350s + y1 <- mean2(x, na.rm = na.rm) 350s + stopifnot(all.equal(y1, y0)) 350s + 350s + # Sum over subset 350s + nidxs <- sample(n, size = 1L) 350s + idxs <- sample(n, size = nidxs) 350s + y0 <- mean2_R(x, na.rm = na.rm, idxs = idxs) 350s + y1 <- mean2(x, na.rm = na.rm, idxs = idxs) 350s + stopifnot(all.equal(y1, y0)) 350s + 350s + if (storage.mode(x) == "integer") { 350s + storage.mode(x) <- "logical" 350s + 350s + y0 <- mean2_R(x, na.rm = na.rm) 350s + y1 <- mean2(x, na.rm = na.rm) 350s + stopifnot(all.equal(y1, y0)) 350s + 350s + y0 <- mean2_R(x, na.rm = na.rm, idxs = idxs) 350s + y1 <- mean2(x, na.rm = na.rm, idxs = idxs) 350s + stopifnot(all.equal(y1, y0)) 350s + } 350s + } # for (kk ...) 350s Random test #1 350s Random test #2 350s Coercing to integers 350s Random test #3 350s Adding NAs 350s Random test #4 350s Adding NAs 350s Coercing to integers 350s Random test #5 350s Random test #6 350s Coercing to integers 350s Random test #7 350s Adding NAs 350s Random test #8 350s Adding NAs 350s Coercing to integers 350s Random test #9 350s Random test #10 350s Coercing to integers 350s Random test #11 350s Adding NAs 350s Random test #12 350s Adding NAs 350s Coercing to integers 350s Random test #13 350s Random test #14 350s Coercing to integers 350s Random test #15 350s Adding NAs 350s Random test #16 350s Adding NAs 350s Coercing to integers 350s Random test #17 350s Random test #18 350s Coercing to integers 350s Random test #19 350s Adding NAs 350s Random test #20 350s Adding NAs 350s Coercing to integers 350s > 350s > 350s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 350s > # Special cases 350s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 350s > for (na.rm in c(FALSE, TRUE)) { 350s + # Averaging over zero elements (integers) 350s + x <- integer(0) 350s + s1 <- mean(x, na.rm = na.rm) 350s + s2 <- mean2(x, na.rm = na.rm) 350s + stopifnot(identical(s1, s2)) 350s + 350s + x <- 1:5 350s + idxs <- integer(0) 350s + s1 <- mean(x[idxs], na.rm = na.rm) 350s + s2 <- mean2(x, idxs = idxs, na.rm = na.rm) 350s + stopifnot(identical(s1, s2)) 350s + 350s + # Averaging over NA_integer_:s 350s + x <- rep(NA_integer_, times = 5L) 350s + s1 <- mean(x, na.rm = na.rm) 350s + s2 <- mean2(x, na.rm = na.rm) 350s + stopifnot(identical(s1, s2)) 350s + 350s + x <- rep(NA_integer_, times = 5L) 350s + idxs <- 1:3 350s + s1 <- mean(x[idxs], na.rm = na.rm) 350s + s2 <- mean2(x, idxs = idxs, na.rm = na.rm) 350s + stopifnot(identical(s1, s2)) 350s + 350s + 350s + # Averaging over zero elements (doubles) 350s + x <- double(0) 350s + s1 <- mean(x) 350s + s2 <- mean2(x) 350s + stopifnot(identical(s1, s2)) 350s + 350s + x <- as.double(1:10) 350s + idxs <- integer(0) 350s + s1 <- mean(x[idxs]) 350s + s2 <- mean2(x, idxs = idxs) 350s + stopifnot(identical(s1, s2)) 350s + 350s + # Averaging over NA_real_:s 350s + x <- rep(NA_real_, times = 5L) 350s + s1 <- mean(x, na.rm = na.rm) 350s + s2 <- mean2(x, na.rm = na.rm) 350s + stopifnot(identical(s1, s2)) 350s + 350s + x <- rep(NA_real_, times = 5L) 350s + idxs <- 1:3 350s + s1 <- mean(x[idxs], na.rm = na.rm) 350s + s2 <- mean2(x, idxs = idxs, na.rm = na.rm) 350s + stopifnot(identical(s1, s2)) 350s + 350s + # Averaging over -Inf:s 350s + x <- rep(-Inf, times = 3L) 350s + s1 <- mean(x, na.rm = na.rm) 350s + s2 <- mean2(x, na.rm = na.rm) 350s + stopifnot(identical(s1, s2)) 350s + 350s + # Averaging over +Inf:s 350s + x <- rep(+Inf, times = 3L) 350s + s1 <- mean(x, na.rm = na.rm) 350s + s2 <- mean2(x, na.rm = na.rm) 350s + stopifnot(identical(s1, s2)) 350s + 350s + # Averaging over mix of -Inf:s and +Inf:s 350s + x <- rep(c(-Inf, +Inf), times = 3L) 350s + s1 <- mean(x, na.rm = na.rm) 350s + s2 <- mean2(x, na.rm = na.rm) 350s + stopifnot(identical(s1, s2)) 350s + 350s + # Averaging over mix of -Inf:s and +Inf:s and numerics 350s + x <- rep(c(-Inf, +Inf, 3.14), times = 2L) 350s + s1 <- mean(x, na.rm = na.rm) 350s + s2 <- mean2(x, na.rm = na.rm) 350s + stopifnot(identical(s1, s2)) 350s + 350s + # Averaging over mix of NaN, NA, +Inf, and numerics 350s + x <- c(NaN, NA, +Inf, 3.14) 350s + s1 <- mean(x, na.rm = na.rm) 350s + s2 <- mean2(x, na.rm = na.rm) 350s + if (na.rm) { 350s + stopifnot(identical(s2, s1)) 350s + } else { 350s + stopifnot(is.na(s1), is.na(s2)) 350s + ## NOTE, due to compiler optimization, it is not guaranteed that NA is 350s + ## returned here (as one would expect). NaN might very well be returned, 350s + ## when both NA and NaN are involved. This is an accepted feature in R, 350s + ## which is documented in help("is.nan"). See also 350s + ## https://stat.ethz.ch/pipermail/r-devel/2017-April/074009.html. 350s + ## Thus, we cannot guarantee that s1 is identical to s0. 350s + } 350s + 350s + # Averaging over mix of NaN, NA_real_, +Inf, and numerics 350s + x <- c(NA_real_, NaN, +Inf, 3.14) 350s + s1 <- mean(x, na.rm = na.rm) 350s + s2 <- mean2(x, na.rm = na.rm) 350s + if (na.rm) { 350s + stopifnot(identical(s2, s1)) 350s + } else { 350s + stopifnot(is.na(s1), is.na(s2)) 350s + ## NOTE, due to compiler optimization, it is not guaranteed that NA is 350s + ## returned here (as one would expect). NaN might very well be returned, 350s + ## when both NA and NaN are involved. This is an accepted feature in R, 350s + ## which is documented in help("is.nan"). See also 350s + ## https://stat.ethz.ch/pipermail/r-devel/2017-April/074009.html. 350s + ## Thus, we cannot guarantee that s1 is identical to s0. 350s + } 350s + } 350s > 350s > 350s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 350s > # Argument 'idxs' 350s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 350s > x <- 1:5 350s > idxs_list <- list( 350s + integer = 1:3, 350s + double = as.double(1:3), 350s + logical = (x <= 3) 350s + ) 350s > 350s > for (idxs in idxs_list) { 350s + cat("idxs:\n") 350s + str(idxs) 350s + s1 <- mean(x[idxs], na.rm = TRUE) 350s + s2 <- mean2(x, idxs = idxs, na.rm = TRUE) 350s + stopifnot(identical(s1, s2)) 350s + } 350s idxs: 350s int [1:3] 1 2 3 350s idxs: 350s num [1:3] 1 2 3 350s idxs: 350s logi [1:5] TRUE TRUE TRUE FALSE FALSE 350s > 351s 351s R version 4.4.3 (2025-02-28) -- "Trophy Case" 351s Copyright (C) 2025 The R Foundation for Statistical Computing 351s Platform: arm-unknown-linux-gnueabihf (32-bit) 351s 351s R is free software and comes with ABSOLUTELY NO WARRANTY. 351s You are welcome to redistribute it under certain conditions. 351s Type 'license()' or 'licence()' for distribution details. 351s 351s R is a collaborative project with many contributors. 351s Type 'contributors()' for more information and 351s 'citation()' on how to cite R or R packages in publications. 351s 351s Type 'demo()' for some demos, 'help()' for on-line help, or 351s 'help.start()' for an HTML browser interface to help. 351s Type 'q()' to quit R. 351s 351s > library("matrixStats") 351s > 351s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 351s > # Subsetted tests 351s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 351s > source("utils/validateIndicesFramework.R") 351s > x <- runif(6, min = -6, max = 6) 351s > storage.mode(x) <- "integer" 351s > for (idxs in index_cases) { 351s + validateIndicesTestVector(x, idxs, 351s + ftest = mean2, fsure = mean, 351s + na.rm = FALSE) 351s + validateIndicesTestVector(x, idxs, 351s + ftest = mean2, fsure = mean, 351s + na.rm = TRUE) 351s + } 351s > 351s 351s R version 4.4.3 (2025-02-28) -- "Trophy Case" 351s Copyright (C) 2025 The R Foundation for Statistical Computing 351s Platform: arm-unknown-linux-gnueabihf (32-bit) 351s 351s R is free software and comes with ABSOLUTELY NO WARRANTY. 351s You are welcome to redistribute it under certain conditions. 351s Type 'license()' or 'licence()' for distribution details. 351s 351s R is a collaborative project with many contributors. 351s Type 'contributors()' for more information and 351s 'citation()' on how to cite R or R packages in publications. 351s 351s Type 'demo()' for some demos, 'help()' for on-line help, or 351s 'help.start()' for an HTML browser interface to help. 351s Type 'q()' to quit R. 351s 351s > library("matrixStats") 351s > 351s > for (mode in c("integer", "double")) { 351s + cat("mode: ", mode, "\n", sep = "") 351s + 351s + # Empty vector 351s + x <- 0 351s + storage.mode(x) <- mode 351s + y <- prod(x, na.rm = TRUE) 351s + print(y) 351s + z <- product(x, na.rm = TRUE) 351s + print(z) 351s + stopifnot(all.equal(z, y)) 351s + 351s + # Test negative values 351s + x <- c(1, -4, 2) 351s + storage.mode(x) <- mode 351s + y <- prod(x, na.rm = TRUE) 351s + print(y) 351s + z <- product(x, na.rm = TRUE) 351s + print(z) 351s + stopifnot(all.equal(z, y)) 351s + 351s + # Test missing values 351s + x <- c(1, NA, NaN, 2) 351s + storage.mode(x) <- mode 351s + y <- prod(x, na.rm = TRUE) 351s + print(y) 351s + z <- product(x, na.rm = TRUE) 351s + print(z) 351s + stopifnot(all.equal(z, y)) 351s + 351s + x <- c(1, NA, NaN, 2) 351s + storage.mode(x) <- mode 351s + y <- prod(x, na.rm = FALSE) 351s + print(y) 351s + z <- product(x, na.rm = FALSE) 351s + print(z) 351s + stopifnot(all(is.na(z), is.na(y))) 351s + 351s + x <- c(1, NaN, 2) 351s + storage.mode(x) <- mode 351s + y <- prod(x, na.rm = FALSE) 351s + print(y) 351s + stopifnot(is.na(y)) 351s + z <- product(x, na.rm = FALSE) 351s + print(z) 351s + stopifnot(is.na(z)) 351s + 351s + } # for (mode ...) 351s mode: integer 351s [1] 0 351s [1] 0 351s [1] -8 351s [1] -8 351s [1] 2 351s [1] 2 351s [1] NA 351s [1] NA 351s [1] NA 351s [1] NA 351s mode: double 351s [1] 0 351s [1] 0 351s [1] -8 351s [1] -8 351s [1] 2 351s [1] 2 351s [1] NA 351s [1] NA 351s [1] NaN 351s [1] NA 351s > 351s > 351s > # NAs following 0s 351s > x <- c(0L, NA_integer_) 351s > y <- prod(x, na.rm = FALSE) 351s > print(y) 351s [1] NA 351s > z <- product(x, na.rm = FALSE) 351s > print(z) 351s [1] NA 351s > stopifnot(identical(z, y)) 351s > 351s 351s R version 4.4.3 (2025-02-28) -- "Trophy Case" 351s Copyright (C) 2025 The R Foundation for Statistical Computing 351s Platform: arm-unknown-linux-gnueabihf (32-bit) 351s 351s R is free software and comes with ABSOLUTELY NO WARRANTY. 351s You are welcome to redistribute it under certain conditions. 351s Type 'license()' or 'licence()' for distribution details. 351s 351s R is a collaborative project with many contributors. 351s Type 'contributors()' for more information and 351s 'citation()' on how to cite R or R packages in publications. 351s 351s Type 'demo()' for some demos, 'help()' for on-line help, or 351s 'help.start()' for an HTML browser interface to help. 351s Type 'q()' to quit R. 351s 351s > library("matrixStats") 351s > 351s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 351s > # Subsetted tests 351s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 351s > source("utils/validateIndicesFramework.R") 351s > x <- runif(6, min = -6, max = 6) 351s > storage.mode(x) <- "integer" 351s > for (idxs in index_cases) { 351s + validateIndicesTestVector(x, idxs, 351s + ftest = product, fsure = prod, 351s + na.rm = TRUE) 351s + validateIndicesTestVector(x, idxs, 351s + ftest = product, fsure = prod, 351s + na.rm = FALSE) 351s + } 351s > 352s 352s R version 4.4.3 (2025-02-28) -- "Trophy Case" 352s Copyright (C) 2025 The R Foundation for Statistical Computing 352s Platform: arm-unknown-linux-gnueabihf (32-bit) 352s 352s R is free software and comes with ABSOLUTELY NO WARRANTY. 352s You are welcome to redistribute it under certain conditions. 352s Type 'license()' or 'licence()' for distribution details. 352s 352s R is a collaborative project with many contributors. 352s Type 'contributors()' for more information and 352s 'citation()' on how to cite R or R packages in publications. 352s 352s Type 'demo()' for some demos, 'help()' for on-line help, or 352s 'help.start()' for an HTML browser interface to help. 352s Type 'q()' to quit R. 352s 352s > library("matrixStats") 352s > library("utils") ## utils::str 352s > 352s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 352s > # Local functions 352s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 352s > psortKM_R <- function(x, k, m) { 352s + x <- sort(x) 352s + x[(k - m + 1):k] 352s + } 352s > 352s > psortKM_R2 <- function(x, k, m) { 352s + partial <- (k - m + 1):k 352s + x <- sort.int(x, partial = partial) 352s + x[partial] 352s + } 352s > 352s > 352s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 352s > # Consistency checks 352s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 352s > set.seed(1) 352s > 352s > cat("Consistency checks:\n") 352s Consistency checks: 352s > x <- 1:30 352s > x[18:20] <- 20 352s > y <- sample(x) 352s > cat("x:\n") 352s x: 352s > str(x) 352s num [1:30] 1 2 3 4 5 6 7 8 9 10 ... 352s > cat("sample(x):\n") 352s sample(x): 352s > str(y) 352s num [1:30] 25 4 7 1 2 23 11 14 20 20 ... 352s > 352s > for (k in c(1L, 2L, 20L, 21L, length(x))) { 352s + for (m in 1:min(5L, k)) { 352s + px0 <- psortKM_R(x, k = k, m = m) 352s + px0b <- psortKM_R2(x, k = k, m = m) 352s + stopifnot(identical(px0b, px0)) 352s + px1 <- matrixStats:::.psortKM(x, k = k, m = m) 352s + cat(sprintf(".psortKM(x, k = %d, m = %d):\n", k, m)) 352s + print(px1) 352s + stopifnot(identical(px1, px0)) 352s + 352s + py0 <- psortKM_R(y, k = k, m = m) 352s + py0b <- psortKM_R2(y, k = k, m = m) 352s + stopifnot(identical(py0b, py0)) 352s + py1 <- matrixStats:::.psortKM(y, k = k, m = m) 352s + cat(sprintf(".psortKM(y, k = %d, m = %d):\n", k, m)) 352s + print(py1) 352s + stopifnot(identical(py1, py0)) 352s + stopifnot(identical(py1, px1)) 352s + } # for (m ...) 352s + } # for (k ...) 352s .psortKM(x, k = 1, m = 1): 352s [1] 1 352s .psortKM(y, k = 1, m = 1): 352s [1] 1 352s .psortKM(x, k = 2, m = 1): 352s [1] 2 352s .psortKM(y, k = 2, m = 1): 352s [1] 2 352s .psortKM(x, k = 2, m = 2): 352s [1] 1 2 352s .psortKM(y, k = 2, m = 2): 352s [1] 1 2 352s .psortKM(x, k = 20, m = 1): 352s [1] 20 352s .psortKM(y, k = 20, m = 1): 352s [1] 20 352s .psortKM(x, k = 20, m = 2): 352s [1] 20 20 352s .psortKM(y, k = 20, m = 2): 352s [1] 20 20 352s .psortKM(x, k = 20, m = 3): 352s [1] 20 20 20 352s .psortKM(y, k = 20, m = 3): 352s [1] 20 20 20 352s .psortKM(x, k = 20, m = 4): 352s [1] 17 20 20 20 352s .psortKM(y, k = 20, m = 4): 352s [1] 17 20 20 20 352s .psortKM(x, k = 20, m = 5): 352s [1] 16 17 20 20 20 352s .psortKM(y, k = 20, m = 5): 352s [1] 16 17 20 20 20 352s .psortKM(x, k = 21, m = 1): 352s [1] 21 352s .psortKM(y, k = 21, m = 1): 352s [1] 21 352s .psortKM(x, k = 21, m = 2): 352s [1] 20 21 352s .psortKM(y, k = 21, m = 2): 352s [1] 20 21 352s .psortKM(x, k = 21, m = 3): 352s [1] 20 20 21 352s .psortKM(y, k = 21, m = 3): 352s [1] 20 20 21 352s .psortKM(x, k = 21, m = 4): 352s [1] 20 20 20 21 352s .psortKM(y, k = 21, m = 4): 352s [1] 20 20 20 21 352s .psortKM(x, k = 21, m = 5): 352s [1] 17 20 20 20 21 352s .psortKM(y, k = 21, m = 5): 352s [1] 17 20 20 20 21 352s .psortKM(x, k = 30, m = 1): 352s [1] 30 352s .psortKM(y, k = 30, m = 1): 352s [1] 30 352s .psortKM(x, k = 30, m = 2): 352s [1] 29 30 352s .psortKM(y, k = 30, m = 2): 352s [1] 29 30 352s .psortKM(x, k = 30, m = 3): 352s [1] 28 29 30 352s .psortKM(y, k = 30, m = 3): 352s [1] 28 29 30 352s .psortKM(x, k = 30, m = 4): 352s [1] 27 28 29 30 352s .psortKM(y, k = 30, m = 4): 352s [1] 27 28 29 30 352s .psortKM(x, k = 30, m = 5): 352s [1] 26 27 28 29 30 352s .psortKM(y, k = 30, m = 5): 352s [1] 26 27 28 29 30 352s > 352s 352s R version 4.4.3 (2025-02-28) -- "Trophy Case" 352s Copyright (C) 2025 The R Foundation for Statistical Computing 352s Platform: arm-unknown-linux-gnueabihf (32-bit) 352s 352s R is free software and comes with ABSOLUTELY NO WARRANTY. 352s You are welcome to redistribute it under certain conditions. 352s Type 'license()' or 'licence()' for distribution details. 352s 352s R is a collaborative project with many contributors. 352s Type 'contributors()' for more information and 352s 'citation()' on how to cite R or R packages in publications. 352s 352s Type 'demo()' for some demos, 'help()' for on-line help, or 352s 'help.start()' for an HTML browser interface to help. 352s Type 'q()' to quit R. 352s 352s > library("matrixStats") 352s > 352s > rowAlls_R <- function(x, value = TRUE, na.rm = FALSE, ..., useNames = TRUE) { 352s + if (is.na(value)) { 352s + res <- apply(is.na(x), MARGIN = 1L, FUN = all, na.rm = na.rm) 352s + } else { 352s + y <- x == value 352s + 352s + # Preserve dimnames attribute 352s + dim <- dim(x) # for 0xN and Mx0 cases; needed in R (< 3.4.0) 352s + if (!isTRUE(all.equal(dim(y), dim))) { 352s + dim(y) <- dim 352s + dimnames(y) <- dimnames(x) 352s + } 352s + 352s + res <- apply(y, MARGIN = 1L, FUN = all, na.rm = na.rm) 352s + } 352s + if (!useNames) names(res) <- NULL 352s + res 352s + } 352s > 352s > rowAnys_R <- function(x, value = TRUE, na.rm = FALSE, ..., useNames = TRUE) { 352s + if (is.na(value)) { 352s + res <- apply(is.na(x), MARGIN = 1L, FUN = any, na.rm = na.rm) 352s + } else { 352s + y <- x == value 352s + 352s + # Preserve dimnames attribute 352s + dim <- dim(x) # for 0xN and Mx0 cases; needed in R (< 3.4.0) 352s + if (!isTRUE(all.equal(dim(y), dim))) { 352s + dim(y) <- dim 352s + dimnames(y) <- dimnames(x) 352s + } 352s + 352s + res <- apply(y, MARGIN = 1L, FUN = any, na.rm = na.rm) 352s + } 352s + if (!useNames) names(res) <- NULL 352s + res 352s + } 352s > 352s > rowAnyMissings_R <- function(x, ..., useNames = TRUE) { 352s + res <- apply(x, MARGIN = 1L, FUN = anyMissing) 352s + if (!useNames) names(res) <- NULL 352s + res 352s + } 352s > 352s > 352s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 352s > # Data type: logical 352s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 352s > x <- matrix(FALSE, nrow = 10L, ncol = 4L) 352s > x[7:8, 2:3] <- TRUE 352s > x[1:3, ] <- TRUE 352s > x[, 1] <- TRUE 352s > x[4, ] <- FALSE 352s > x[, 4] <- FALSE 352s > x[2, ] <- FALSE 352s > x[3, ] <- TRUE 352s > 352s > # To check names attribute 352s > dimnames <- list(letters[1:10], LETTERS[1:4]) 352s > 352s > for (kk in 1:3) { 352s + if (kk == 2) { 352s + x[2, 2] <- NA 352s + } else if (kk == 3) { 352s + x[, 2] <- NA 352s + x[2, ] <- NA 352s + } 352s + 352s + # Test with and without dimnames on x 352s + for (setDimnames in c(TRUE, FALSE)) { 352s + dimnames(x) <- if (setDimnames) dimnames else NULL 352s + 352s + for (na.rm in c(FALSE, TRUE)) { 352s + # Check names attribute 352s + for (useNames in c(TRUE, FALSE)) { 352s + m0 <- rowAlls_R(x, na.rm = na.rm, useNames = useNames) 352s + m1 <- rowAlls(x, na.rm = na.rm, useNames = useNames) 352s + m2 <- colAlls(t(x), na.rm = na.rm, useNames = useNames) 352s + str(list("all()", m0 = m0, m1 = m1, m2 = m2)) 352s + stopifnot(identical(m1, m0)) 352s + stopifnot(identical(m2, m0)) 352s + 352s + m0 <- rowAnys_R(x, na.rm = na.rm, useNames = useNames) 352s + m1 <- rowAnys(x, na.rm = na.rm, useNames = useNames) 352s + m2 <- colAnys(t(x), na.rm = na.rm, useNames = useNames) 352s + str(list("any()", m0 = m0, m1 = m1, m2 = m2)) 352s + stopifnot(identical(m1, m0)) 352s + stopifnot(identical(m2, m0)) 352s + 352s + m0 <- rowAnyMissings_R(x, useNames = useNames) 352s + m1 <- rowAnyMissings(x, useNames = useNames) 352s + m2 <- colAnyMissings(t(x), useNames = useNames) 352s + str(list("anyMissing()", m0 = m0, m1 = m1, m2 = m2)) 352s + stopifnot(identical(m1, m0)) 352s + stopifnot(identical(m2, m0)) 352s + } 352s + } 352s + } 352s + } # for (kk ...) 352s List of 4 352s $ : chr "all()" 352s $ m0: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 352s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 352s $ m1: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 352s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 352s $ m2: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 352s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 352s List of 4 352s $ : chr "any()" 352s $ m0: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 352s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 352s $ m1: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 352s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 352s $ m2: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 352s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 352s List of 4 352s $ : chr "anyMissing()" 352s $ m0: Named logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 352s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 352s $ m1: Named logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 352s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 352s $ m2: Named logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 352s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 352s List of 4 352s $ : chr "all()" 352s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 352s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 352s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 352s List of 4 352s $ : chr "any()" 352s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 352s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 352s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 352s List of 4 352s $ : chr "anyMissing()" 352s $ m0: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 352s $ m1: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 352s $ m2: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 352s List of 4 352s $ : chr "all()" 352s $ m0: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 352s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 352s $ m1: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 352s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 352s $ m2: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 352s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 352s List of 4 353s $ : chr "any()" 353s $ m0: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 353s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 353s $ m1: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 353s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 353s $ m2: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 353s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 353s List of 4 353s $ : chr "anyMissing()" 353s $ m0: Named logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 353s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 353s $ m1: Named logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 353s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 353s $ m2: Named logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 353s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 353s List of 4 353s $ : chr "all()" 353s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 353s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 353s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 353s List of 4 353s $ : chr "any()" 353s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 353s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 353s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 353s List of 4 353s $ : chr "anyMissing()" 353s $ m0: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 353s $ m1: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 353s $ m2: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 353s List of 4 353s $ : chr "all()" 353s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 353s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 353s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 353s List of 4 353s $ : chr "any()" 353s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 353s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 353s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 353s List of 4 353s $ : chr "anyMissing()" 353s $ m0: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 353s $ m1: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 353s $ m2: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 353s List of 4 353s $ : chr "all()" 353s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 353s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 353s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 353s List of 4 353s $ : chr "any()" 353s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 353s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 353s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 353s List of 4 353s $ : chr "anyMissing()" 353s $ m0: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 353s $ m1: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 353s $ m2: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 353s List of 4 353s $ : chr "all()" 353s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 353s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 353s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 353s List of 4 353s $ : chr "any()" 353s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 353s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 353s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 353s List of 4 353s $ : chr "anyMissing()" 353s $ m0: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 353s $ m1: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 353s $ m2: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 353s List of 4 353s $ : chr "all()" 353s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 353s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 353s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 353s List of 4 353s $ : chr "any()" 353s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 353s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 353s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 353s List of 4 353s $ : chr "anyMissing()" 353s $ m0: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 353s $ m1: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 353s $ m2: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 353s List of 4 353s $ : chr "all()" 353s $ m0: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 353s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 353s $ m1: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 353s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 353s $ m2: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 353s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 353s List of 4 353s $ : chr "any()" 353s $ m0: Named logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 353s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 353s $ m1: Named logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 353s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 353s $ m2: Named logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 353s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 353s List of 4 353s $ : chr "anyMissing()" 353s $ m0: Named logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 353s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 353s $ m1: Named logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 353s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 353s $ m2: Named logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 353s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 353s List of 4 353s $ : chr "all()" 353s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 353s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 353s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 353s List of 4 353s $ : chr "any()" 353s $ m0: logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 353s $ m1: logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 353s $ m2: logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 353s List of 4 353s $ : chr "anyMissing()" 353s $ m0: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 353s $ m1: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 353s $ m2: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 353s List of 4 353s $ : chr "all()" 353s $ m0: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 353s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 353s $ m1: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 353s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 353s $ m2: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 353s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 353s List of 4 353s $ : chr "any()" 353s $ m0: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 353s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 353s $ m1: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 353s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 353s $ m2: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 353s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 353s List of 4 353s $ : chr "anyMissing()" 353s $ m0: Named logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 353s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 353s $ m1: Named logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 353s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 353s $ m2: Named logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 353s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 353s List of 4 353s $ : chr "all()" 353s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 353s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 353s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 353s List of 4 353s $ : chr "any()" 353s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 353s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 353s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 353s List of 4 353s $ : chr "anyMissing()" 353s $ m0: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 353s $ m1: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 353s $ m2: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 353s List of 4 353s $ : chr "all()" 353s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 353s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 353s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 353s List of 4 353s $ : chr "any()" 353s $ m0: logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 353s $ m1: logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 353s $ m2: logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 353s List of 4 353s $ : chr "anyMissing()" 353s $ m0: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 353s $ m1: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 353s $ m2: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 353s List of 4 353s $ : chr "all()" 353s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 353s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 353s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 353s List of 4 353s $ : chr "any()" 353s $ m0: logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 353s $ m1: logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 353s $ m2: logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 353s List of 4 353s $ : chr "anyMissing()" 353s $ m0: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 353s $ m1: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 353s $ m2: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 353s List of 4 353s $ : chr "all()" 353s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 353s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 353s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 353s List of 4 353s $ : chr "any()" 353s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 353s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 353s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 353s List of 4 353s $ : chr "anyMissing()" 353s $ m0: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 353s $ m1: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 353s $ m2: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 353s List of 4 353s $ : chr "all()" 353s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 353s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 353s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 353s List of 4 353s $ : chr "any()" 353s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 353s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 353s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 353s List of 4 353s $ : chr "anyMissing()" 353s $ m0: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 353s $ m1: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 353s $ m2: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 353s List of 4 353s $ : chr "all()" 353s $ m0: Named logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 353s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 353s $ m1: Named logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 353s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 353s $ m2: Named logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 353s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 353s List of 4 353s $ : chr "any()" 353s $ m0: Named logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 353s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 353s $ m1: Named logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 353s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 353s $ m2: Named logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 353s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 353s List of 4 353s $ : chr "anyMissing()" 353s $ m0: Named logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 353s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 353s $ m1: Named logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 353s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 353s $ m2: Named logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 353s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 353s List of 4 353s $ : chr "all()" 353s $ m0: logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 353s $ m1: logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 353s $ m2: logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 353s List of 4 353s $ : chr "any()" 353s $ m0: logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 353s $ m1: logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 353s $ m2: logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 353s List of 4 353s $ : chr "anyMissing()" 353s $ m0: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 353s $ m1: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 353s $ m2: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 353s List of 4 353s $ : chr "all()" 353s $ m0: Named logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 353s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 353s $ m1: Named logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 353s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 353s $ m2: Named logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 353s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 353s List of 4 353s $ : chr "any()" 353s $ m0: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 353s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 353s $ m1: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 353s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 353s $ m2: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 353s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 353s List of 4 353s $ : chr "anyMissing()" 353s $ m0: Named logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 353s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 353s $ m1: Named logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 353s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 353s $ m2: Named logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 353s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 353s List of 4 353s $ : chr "all()" 353s $ m0: logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 353s $ m1: logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 353s $ m2: logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 353s List of 4 353s $ : chr "any()" 353s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 353s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 353s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 353s List of 4 353s $ : chr "anyMissing()" 353s $ m0: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 353s $ m1: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 353s $ m2: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 353s List of 4 353s $ : chr "all()" 353s $ m0: logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 353s $ m1: logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 353s $ m2: logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 353s List of 4 353s $ : chr "any()" 353s $ m0: logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 353s $ m1: logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 353s $ m2: logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 353s List of 4 353s $ : chr "anyMissing()" 353s $ m0: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 353s $ m1: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 353s $ m2: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 353s List of 4 353s $ : chr "all()" 353s $ m0: logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 353s $ m1: logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 353s $ m2: logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 353s List of 4 353s $ : chr "any()" 353s $ m0: logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 353s $ m1: logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 353s $ m2: logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 353s List of 4 353s $ : chr "anyMissing()" 353s $ m0: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 353s $ m1: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 353s $ m2: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 353s List of 4 353s $ : chr "all()" 353s $ m0: logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 353s $ m1: logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 353s $ m2: logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 353s List of 4 353s $ : chr "any()" 353s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 353s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 353s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 353s List of 4 353s $ : chr "anyMissing()" 353s $ m0: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 353s $ m1: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 353s $ m2: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 353s List of 4 353s $ : chr "all()" 353s $ m0: logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 353s $ m1: logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 353s $ m2: logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 353s List of 4 353s $ : chr "any()" 353s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 353s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 353s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 353s List of 4 353s $ : chr "anyMissing()" 353s $ m0: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 353s $ m1: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 353s $ m2: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 353s > 353s > 353s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 353s > # Data type: integer 353s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 353s > x <- matrix(rep(1:6, length.out = 4 * 5), nrow = 4L, ncol = 5L) 353s > x[2, ] <- 7L 353s > x[3, 1] <- 7L 353s > x[2:3, 3:4] <- NA_integer_ 353s > 353s > # To check names attribute 353s > dimnames <- list(letters[1:4], LETTERS[1:5]) 353s > 353s > # Row/column counts 353s > value <- 7L 353s > 353s > # Test with and without dimnames on x 353s > for (setDimnames in c(TRUE, FALSE)) { 353s + dimnames(x) <- if (setDimnames) dimnames else NULL 353s + for (na.rm in c(FALSE, TRUE)) { 353s + # Check names attribute 353s + for (useNames in c(TRUE, FALSE)) { 353s + r0 <- rowAlls_R(x, value = value, na.rm = na.rm, useNames = useNames) 353s + r1 <- rowAlls(x, value = value, na.rm = na.rm, useNames = useNames) 353s + r2 <- colAlls(t(x), value = value, na.rm = na.rm, useNames = useNames) 353s + stopifnot(identical(r1, r0)) 353s + stopifnot(identical(r2, r1)) 353s + if (!useNames && !setDimnames) { 353s + for (rr in seq_len(nrow(x))) { 353s + c <- allValue(x[rr, ], value = value, na.rm = na.rm) 353s + stopifnot(identical(c, r1[rr])) 353s + c <- allValue(x[rr, ], value = value, na.rm = na.rm) 353s + stopifnot(identical(c, r1[rr])) 353s + } 353s + } 353s + 353s + r0 <- rowAnys_R(x, value = value, na.rm = na.rm, useNames = useNames) 353s + r1 <- rowAnys(x, value = value, na.rm = na.rm, useNames = useNames) 353s + r2 <- colAnys(t(x), value = value, na.rm = na.rm, useNames = useNames) 353s + stopifnot(identical(r1, r0)) 353s + stopifnot(identical(r2, r1)) 353s + if (!useNames && !setDimnames) { 353s + for (rr in seq_len(nrow(x))) { 353s + c <- anyValue(x[rr, ], value = value, na.rm = na.rm) 353s + stopifnot(identical(c, r1[rr])) 353s + c <- anyValue(x[rr, ], value = value, na.rm = na.rm) 353s + stopifnot(identical(c, r1[rr])) 353s + } 353s + } 353s + } 353s + } 353s + } 353s > 353s > 353s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 353s > # rowAlls(x) et al. on numeric 'x' with logical 'value' 353s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 353s > x <- matrix(0, nrow = 4L, ncol = 5L) 353s > x[2:4, 2] <- (1:3) / 4 353s > x[2, 2:4] <- (1:3) / 4 353s > x[3:4, 3] <- (3:4) / 4 353s > x[3, 3:4] <- (3:4) / 4 353s > x[1:4, 5] <- (1:4) / 5 353s > x[4, 4] <- NA_real_ 353s > 353s > # To check names attribute 353s > dimnames <- list(letters[1:4], LETTERS[1:5]) 353s > 353s > for (value in c(TRUE, FALSE)) { 353s + for (na.rm in c(FALSE, TRUE)) { 353s + y0 <- suppressWarnings(apply(x, MARGIN = 1L, FUN = function(e) any(as.logical(e) == value, na.rm = na.rm))) 353s + y <- rowAnys(x, na.rm = na.rm, value = value) 353s + stopifnot(identical(y, y0)) 353s + # Check names attribute 353s + dimnames(x) <- dimnames 353s + y <- rowAnys(x, na.rm = na.rm, value = value, useNames = FALSE) 353s + stopifnot(all.equal(y, y0)) 353s + y0 <- suppressWarnings(apply(x, MARGIN = 1L, FUN = function(e) any(as.logical(e) == value, na.rm = na.rm))) 353s + y <- rowAnys(x, na.rm = na.rm, value = value, useNames = TRUE) 353s + stopifnot(all.equal(y, y0)) 353s + dimnames(x) <- NULL 353s + 353s + y0 <- suppressWarnings(apply(x, MARGIN = 2L, FUN = function(e) any(as.logical(e) == value, na.rm = na.rm))) 353s + y <- colAnys(x, na.rm = na.rm, value = value) 353s + stopifnot(identical(y, y0)) 353s + # Check names attribute 353s + dimnames(x) <- dimnames 353s + y <- colAnys(x, na.rm = na.rm, value = value, useNames = FALSE) 353s + stopifnot(all.equal(y, y0)) 353s + y0 <- suppressWarnings(apply(x, MARGIN = 2L, FUN = function(e) any(as.logical(e) == value, na.rm = na.rm))) 353s + y <- colAnys(x, na.rm = na.rm, value = value, useNames = TRUE) 353s + stopifnot(all.equal(y, y0)) 353s + dimnames(x) <- NULL 353s + 353s + y0 <- suppressWarnings(apply(x, MARGIN = 1L, FUN = function(e) all(as.logical(e) == value, na.rm = na.rm))) 353s + y <- rowAlls(x, na.rm = na.rm, value = value) 353s + stopifnot(identical(y, y0)) 353s + # Check names attribute 353s + dimnames(x) <- dimnames 353s + y <- rowAlls(x, na.rm = na.rm, value = value, useNames = FALSE) 353s + stopifnot(all.equal(y, y0)) 353s + y0 <- suppressWarnings(apply(x, MARGIN = 1L, FUN = function(e) all(as.logical(e) == value, na.rm = na.rm))) 353s + y <- rowAlls(x, na.rm = na.rm, value = value, useNames = TRUE) 353s + stopifnot(all.equal(y, y0)) 353s + dimnames(x) <- NULL 353s + 353s + y0 <- suppressWarnings(apply(x, MARGIN = 2L, FUN = function(e) all(as.logical(e) == value, na.rm = na.rm))) 353s + y <- colAlls(x, na.rm = na.rm, value = value) 353s + stopifnot(identical(y, y0)) 353s + print(y0) 353s + # Check names attribute 353s + dimnames(x) <- dimnames 353s + y <- colAlls(x, na.rm = na.rm, value = value, useNames = FALSE) 353s + stopifnot(all.equal(y, y0)) 353s + y0 <- suppressWarnings(apply(x, MARGIN = 2L, FUN = function(e) all(as.logical(e) == value, na.rm = na.rm))) 353s + y <- colAlls(x, na.rm = na.rm, value = value, useNames = TRUE) 353s + stopifnot(all.equal(y, y0)) 353s + dimnames(x) <- NULL 353s + } ## for (na.rm ...) 353s + } ## for(value ...) 353s [1] FALSE FALSE FALSE FALSE TRUE 353s [1] FALSE FALSE FALSE FALSE TRUE 353s [1] TRUE FALSE FALSE FALSE FALSE 353s [1] TRUE FALSE FALSE FALSE FALSE 353s > 353s > 353s > 353s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 353s > # Data type: character (not sure if this should be supported) 353s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 353s > all_R <- function(x, value = TRUE, ...) { 353s + if (is.na(value)) { 353s + all(is.na(x), ...) 353s + } else { 353s + all(x == value, ...) 353s + } 353s + } 353s > 353s > any_R <- function(x, value = TRUE, ...) { 353s + if (is.na(value)) { 353s + any(is.na(x), ...) 353s + } else { 353s + any(x == value, ...) 353s + } 353s + } 353s > 353s > x <- matrix(rep(letters, length.out = 10 * 5), nrow = 10L, ncol = 5L) 353s > x[2, ] <- "g" 353s > x[2:4, 3:4] <- NA_character_ 353s > 353s > # To check names attribute 353s > dimnames <- list(letters[1:10], LETTERS[1:5]) 353s > 353s > # Test with and without dimnames on x 353s > for (setDimnames in c(TRUE, FALSE)) { 353s + dimnames(x) <- if (setDimnames) dimnames else NULL 353s + 353s + # Row/column counts 353s + for (value in c("g", NA_character_)) { 353s + for (na.rm in c(FALSE, TRUE)) { 353s + # Check names attribute 353s + for (useNames in c(TRUE, FALSE)) { 353s + r0 <- rowAlls_R(x, value = value, na.rm = na.rm, useNames = useNames) 353s + r1 <- rowAlls(x, value = value, na.rm = na.rm, useNames = useNames) 353s + r2 <- colAlls(t(x), value = value, na.rm = na.rm, useNames = useNames) 353s + stopifnot(identical(r1, r0)) 353s + stopifnot(identical(r2, r1)) 353s + if (!useNames && !setDimnames) { 353s + for (rr in seq_len(nrow(x))) { 353s + c0 <- all_R(x[rr, ], value, na.rm = na.rm) 353s + c <- allValue(x[rr, ], value = value, na.rm = na.rm) 353s + stopifnot(identical(c, r1[rr])) 353s + stopifnot(identical(c, c0)) 353s + } 353s + } 353s + 353s + r0 <- rowAnys_R(x, value = value, na.rm = na.rm, useNames = useNames) 353s + r1 <- rowAnys(x, value = value, na.rm = na.rm, useNames = useNames) 353s + r2 <- colAnys(t(x), value = value, na.rm = na.rm, useNames = useNames) 353s + stopifnot(identical(r1, r0)) 353s + stopifnot(identical(r2, r1)) 353s + if (!useNames && !setDimnames) { 353s + for (rr in seq_len(nrow(x))) { 353s + c0 <- any_R(x[rr, ], value, na.rm = na.rm) 353s + c <- anyValue(x[rr, ], value = value, na.rm = na.rm) 353s + stopifnot(identical(c, c0)) 353s + stopifnot(identical(c, r1[rr])) 353s + } 353s + } 353s + } 353s + } 353s + } 353s + } 353s > 353s > 353s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 353s > # NA 0 test 353s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 353s > x <- matrix(0, nrow = 3L, ncol = 3L) 353s > x[1, ] <- c(NA_real_, NA_real_, 0) 353s > x[3, ] <- c(1, 0, 1) 353s > 353s > dimnames <- list(letters[1:3], LETTERS[1:3]) 353s > 353s > # Test with and without dimnames on x 353s > for (setDimnames in c(TRUE, FALSE)) { 353s + dimnames(x) <- if (setDimnames) dimnames else NULL 353s + # Check names attribute 353s + for (useNames in c(TRUE, FALSE)) { 353s + r0 <- rowAnys_R(x, value = 0, useNames = useNames) 353s + r1 <- rowAnys(x, value = 0, useNames = useNames) 353s + stopifnot(identical(r0, r1)) 353s + } 353s + } 353s > 354s 354s R version 4.4.3 (2025-02-28) -- "Trophy Case" 354s Copyright (C) 2025 The R Foundation for Statistical Computing 354s Platform: arm-unknown-linux-gnueabihf (32-bit) 354s 354s R is free software and comes with ABSOLUTELY NO WARRANTY. 354s You are welcome to redistribute it under certain conditions. 354s Type 'license()' or 'licence()' for distribution details. 354s 354s R is a collaborative project with many contributors. 354s Type 'contributors()' for more information and 354s 'citation()' on how to cite R or R packages in publications. 354s 354s Type 'demo()' for some demos, 'help()' for on-line help, or 354s 'help.start()' for an HTML browser interface to help. 354s Type 'q()' to quit R. 354s 354s > library("matrixStats") 354s > 354s > rowAlls_R <- function(x, value = TRUE, na.rm = FALSE, ..., useNames = TRUE) { 354s + if (is.na(value)) { 354s + res <- apply(is.na(x), MARGIN = 1L, FUN = all, na.rm = na.rm) 354s + } else { 354s + y <- x == value 354s + 354s + # Preserve dimnames attribute 354s + dim <- dim(x) # for 0xN and Mx0 cases; needed in R (< 3.4.0) 354s + if (!isTRUE(all.equal(dim(y), dim))) { 354s + dim(y) <- dim 354s + dimnames(y) <- dimnames(x) 354s + } 354s + 354s + res <- apply(y, MARGIN = 1L, FUN = all, na.rm = na.rm) 354s + } 354s + if (!useNames) names(res) <- NULL 354s + res 354s + } 354s > 354s > rowAnys_R <- function(x, value = TRUE, na.rm = FALSE, ..., useNames = TRUE) { 354s + if (is.na(value)) { 354s + res <- apply(is.na(x), MARGIN = 1L, FUN = any, na.rm = na.rm) 354s + } else { 354s + y <- x == value 354s + 354s + # Preserve dimnames attribute 354s + dim <- dim(x) # for 0xN and Mx0 cases; needed in R (< 3.4.0) 354s + if (!isTRUE(all.equal(dim(y), dim))) { 354s + dim(y) <- dim 354s + dimnames(y) <- dimnames(x) 354s + } 354s + 354s + res <- apply(y, MARGIN = 1L, FUN = any, na.rm = na.rm) 354s + } 354s + if (!useNames) names(res) <- NULL 354s + res 354s + } 354s > 354s > rowAnyMissings_R <- function(x, ..., useNames = TRUE) { 354s + res <- apply(x, MARGIN = 1L, FUN = anyMissing) 354s + if (!useNames) names(res) <- NULL 354s + res 354s + } 354s > 354s > 354s > all_R <- function(x, value = TRUE, ...) { 354s + if (is.na(value)) { 354s + all(is.na(x), ...) 354s + } else { 354s + all(x == value, ...) 354s + } 354s + } 354s > 354s > any_R <- function(x, value = TRUE, ...) { 354s + if (is.na(value)) { 354s + any(is.na(x), ...) 354s + } else { 354s + any(x == value, ...) 354s + } 354s + } 354s > 354s > 354s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 354s > # Subsetted tests 354s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 354s > source("utils/validateIndicesFramework.R") 354s > x <- matrix(runif(6 * 6, min = -3, max = 3), nrow = 6, ncol = 6) 354s > storage.mode(x) <- "integer" 354s > x[2:3, ] <- NA_integer_ 354s > x[2, 1] <- 0L 354s > x[4:5, ] <- 0L 354s > x[4, 6] <- NA_integer_ 354s > 354s > # To check names attribute 354s > dimnames <- list(letters[1:6], LETTERS[1:6]) 354s > 354s > # Test with and without dimnames on x 354s > for (setDimnames in c(TRUE, FALSE)) { 354s + if (setDimnames) dimnames(x) <- dimnames 354s + else dimnames(x) <- NULL 354s + 354s + count <- 0L 354s + for (rows in index_cases) { 354s + for (cols in index_cases) { 354s + count <- count + 1L 354s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 354s + useNames <- c(TRUE, FALSE) 354s + useNames <- useNames[count %% length(useNames) + 1] 354s + 354s + validateIndicesTestMatrix(x, rows, cols, 354s + ftest = rowAlls, fsure = rowAlls_R, 354s + value = 0, na.rm = TRUE, useNames = useNames) 354s + validateIndicesTestMatrix(x, rows, cols, 354s + ftest = rowAlls, fsure = rowAlls_R, 354s + value = 0, na.rm = FALSE, useNames = useNames) 354s + validateIndicesTestMatrix(x, rows, cols, 354s + ftest = rowAlls, fsure = rowAlls_R, 354s + value = NA_integer_, useNames = useNames) 354s + validateIndicesTestMatrix(x, rows, cols, 354s + fcoltest = colAlls, fsure = rowAlls_R, 354s + value = 0, na.rm = TRUE, useNames = useNames) 354s + validateIndicesTestMatrix(x, rows, cols, 354s + fcoltest = colAlls, fsure = rowAlls_R, 354s + value = 0, na.rm = FALSE, useNames = useNames) 354s + validateIndicesTestMatrix(x, rows, cols, 354s + fcoltest = colAlls, fsure = rowAlls_R, 354s + value = NA_integer_, useNames = useNames) 354s + 354s + validateIndicesTestMatrix(x, rows, cols, 354s + ftest = rowAnys, fsure = rowAnys_R, 354s + value = 0, na.rm = TRUE, useNames = useNames) 354s + validateIndicesTestMatrix(x, rows, cols, 354s + ftest = rowAnys, fsure = rowAnys_R, 354s + value = 0, na.rm = FALSE, useNames = useNames) 354s + validateIndicesTestMatrix(x, rows, cols, 354s + ftest = rowAnys, fsure = rowAnys_R, 354s + value = NA_integer_, useNames = useNames) 354s + validateIndicesTestMatrix(x, rows, cols, 354s + fcoltest = colAnys, fsure = rowAnys_R, 354s + value = 0, na.rm = TRUE, useNames = useNames) 354s + validateIndicesTestMatrix(x, rows, cols, 354s + fcoltest = colAnys, fsure = rowAnys_R, 354s + value = 0, na.rm = FALSE, useNames = useNames) 354s + validateIndicesTestMatrix(x, rows, cols, 354s + fcoltest = colAnys, fsure = rowAnys_R, 354s + value = NA_integer_, useNames = useNames) 354s + 354s + validateIndicesTestMatrix(x, rows, cols, 354s + ftest = rowAnyMissings, 354s + fsure = rowAnyMissings_R, useNames = useNames) 354s + validateIndicesTestMatrix(x, rows, cols, 354s + fcoltest = colAnyMissings, 354s + fsure = rowAnyMissings_R, useNames = useNames) 354s + } 354s + } 354s + } 357s > 357s > for (rr in seq_len(nrow(x))) { 357s + for (idxs in index_cases) { 357s + validateIndicesTestVector(x[rr, ], idxs, 357s + ftest = allValue, fsure = all_R, 357s + value = 0, na.rm = TRUE) 357s + validateIndicesTestVector(x[rr, ], idxs, 357s + ftest = allValue, fsure = all_R, 357s + value = 0, na.rm = FALSE) 357s + validateIndicesTestVector(x[rr, ], idxs, 357s + ftest = allValue, fsure = all_R, 357s + value = NA_integer_) 357s + 357s + validateIndicesTestVector(x[rr, ], idxs, 357s + ftest = anyValue, fsure = any_R, 357s + value = 0, na.rm = TRUE) 357s + validateIndicesTestVector(x[rr, ], idxs, 357s + ftest = anyValue, fsure = any_R, 357s + value = 0, na.rm = FALSE) 357s + validateIndicesTestVector(x[rr, ], idxs, 357s + ftest = anyValue, fsure = any_R, 357s + value = NA_integer_) 357s + } 357s + } 357s > 357s > 357s > storage.mode(x) <- "character" 357s > # Test with and without dimnames on x 357s > for (setDimnames in c(TRUE, FALSE)) { 357s + if (setDimnames) dimnames(x) <- dimnames 357s + else dimnames(x) <- NULL 357s + for (rows in index_cases) { 357s + for (cols in index_cases) { 357s + # Check names attribute 357s + for (useNames in c(TRUE, FALSE)) { 357s + validateIndicesTestMatrix(x, rows, cols, 357s + ftest = rowAlls, fsure = rowAlls_R, 357s + value = "0", na.rm = TRUE, useNames = useNames) 357s + validateIndicesTestMatrix(x, rows, cols, 357s + ftest = rowAlls, fsure = rowAlls_R, 357s + value = "0", na.rm = FALSE, useNames = useNames) 357s + validateIndicesTestMatrix(x, rows, cols, 357s + ftest = rowAlls, fsure = rowAlls_R, 357s + value = NA_character_, useNames = useNames) 357s + validateIndicesTestMatrix(x, rows, cols, 357s + fcoltest = colAlls, fsure = rowAlls_R, 357s + value = "0", na.rm = TRUE, useNames = useNames) 357s + validateIndicesTestMatrix(x, rows, cols, 357s + fcoltest = colAlls, fsure = rowAlls_R, 357s + value = "0", na.rm = FALSE, useNames = useNames) 357s + validateIndicesTestMatrix(x, rows, cols, 357s + fcoltest = colAlls, fsure = rowAlls_R, 357s + value = NA_character_, useNames = useNames) 357s + 357s + validateIndicesTestMatrix(x, rows, cols, 357s + ftest = rowAnys, fsure = rowAnys_R, 357s + value = "0", na.rm = TRUE, useNames = useNames) 357s + validateIndicesTestMatrix(x, rows, cols, 357s + ftest = rowAnys, fsure = rowAnys_R, 357s + value = "0", na.rm = FALSE, useNames = useNames) 357s + validateIndicesTestMatrix(x, rows, cols, 357s + ftest = rowAnys, fsure = rowAnys_R, 357s + value = NA_character_, useNames = useNames) 357s + validateIndicesTestMatrix(x, rows, cols, 357s + fcoltest = colAnys, fsure = rowAnys_R, 357s + value = "0", na.rm = TRUE, useNames = useNames) 357s + validateIndicesTestMatrix(x, rows, cols, 357s + fcoltest = colAnys, fsure = rowAnys_R, 357s + value = "0", na.rm = FALSE, useNames = useNames) 357s + validateIndicesTestMatrix(x, rows, cols, 357s + fcoltest = colAnys, fsure = rowAnys_R, 357s + value = NA_character_, useNames = useNames) 357s + 357s + validateIndicesTestMatrix(x, rows, cols, 357s + ftest = rowAnyMissings, 357s + fsure = rowAnyMissings_R, useNames = useNames) 357s + validateIndicesTestMatrix(x, rows, cols, 357s + fcoltest = colAnyMissings, 357s + fsure = rowAnyMissings_R, useNames = useNames) 357s + } 357s + } 357s + } 357s + } 361s > 361s > for (rr in seq_len(nrow(x))) { 361s + for (idxs in index_cases) { 361s + validateIndicesTestVector(x[rr, ], idxs, 361s + ftest = allValue, fsure = all_R, 361s + value = "0", na.rm = TRUE) 361s + validateIndicesTestVector(x[rr, ], idxs, 361s + ftest = allValue, fsure = all_R, 361s + value = "0", na.rm = FALSE) 361s + validateIndicesTestVector(x[rr, ], idxs, 361s + ftest = allValue, fsure = all_R, 361s + value = NA_integer_) 361s + 361s + validateIndicesTestVector(x[rr, ], idxs, 361s + ftest = anyValue, fsure = any_R, 361s + value = "0", na.rm = TRUE) 361s + validateIndicesTestVector(x[rr, ], idxs, 361s + ftest = anyValue, fsure = any_R, 361s + value = "0", na.rm = FALSE) 361s + validateIndicesTestVector(x[rr, ], idxs, 361s + ftest = anyValue, fsure = any_R, 361s + value = NA_integer_) 361s + } 361s + } 361s > 361s 361s R version 4.4.3 (2025-02-28) -- "Trophy Case" 361s Copyright (C) 2025 The R Foundation for Statistical Computing 361s Platform: arm-unknown-linux-gnueabihf (32-bit) 361s 361s R is free software and comes with ABSOLUTELY NO WARRANTY. 361s You are welcome to redistribute it under certain conditions. 361s Type 'license()' or 'licence()' for distribution details. 361s 361s R is a collaborative project with many contributors. 361s Type 'contributors()' for more information and 361s 'citation()' on how to cite R or R packages in publications. 361s 361s Type 'demo()' for some demos, 'help()' for on-line help, or 361s 'help.start()' for an HTML browser interface to help. 361s Type 'q()' to quit R. 361s 361s > library("matrixStats") 361s > 361s > X <- matrix(rnorm(20 * 6), nrow = 20, ncol = 6) 361s > rownames(X) <- LETTERS[1:nrow(X)] 361s > colnames(X) <- letters[1:ncol(X)] 361s > print(X) 361s a b c d e f 361s A -0.35140879 -1.22854581 -0.94979247 0.4489763 -0.59646407 -0.7595478 361s B 0.29156278 -1.73082711 -0.37389024 0.2351672 1.00587270 0.2294872 361s C 2.15827101 -0.30727872 -1.83761223 -0.7559642 -0.54227940 0.2939263 361s D 0.40639910 1.04361455 -0.29228894 0.5183875 -1.88856220 -1.5339132 361s E -0.69077805 -1.57383150 0.54894580 -1.0632475 -0.07293596 1.3667249 361s F -1.24478831 -1.38236737 -1.62090645 1.2535574 -1.01785382 -2.0780226 361s G -0.03327265 -0.94052522 -0.70436715 0.3456371 -1.11553488 -0.1253964 361s H -0.73064112 -0.02242984 -1.21727365 0.4086296 -0.52285248 -0.9486570 361s I -0.74532527 -0.45117496 0.99712148 -0.2883300 -0.81810116 0.2814717 361s J 1.68988190 0.84861543 -0.42281760 -1.1296276 -1.02214489 1.2794520 361s K 0.16361401 -0.36333511 -1.03198176 1.5120581 -2.26759503 -0.9788509 361s L 2.26319905 0.95930931 -0.96729927 0.7049738 -0.56465250 -0.4789547 361s M 0.88605250 -2.47541485 -0.23645040 0.4369156 -0.83402411 -1.3188910 361s N 0.55739082 0.86117926 0.62468012 0.7964080 0.68656699 0.5524914 361s O -1.25887048 -0.33331546 2.03435108 -0.6092877 -1.32146655 0.3925672 361s P -0.35916215 0.12721424 0.92339923 -1.2872568 -0.65268069 0.1676494 361s Q -0.05929644 1.84274091 -0.17963398 1.2694547 0.51066771 1.3493419 361s R -0.60642698 -0.71155436 0.05477791 -0.4481309 -2.35401254 2.0794051 361s S -1.23909876 -0.57368690 0.93672724 -0.1637712 -1.70930347 -0.3613689 361s T 1.31323233 0.64261109 -1.62072294 -1.0660264 0.73859499 1.0882413 361s > 361s > 361s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 361s > # Apply rowMeans() for 3 sets of 2 columns 361s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 361s > nbr_of_sets <- 3L 361s > S <- matrix(1:ncol(X), ncol = nbr_of_sets) 361s > colnames(S) <- sprintf("s%d", 1:nbr_of_sets) 361s > print(S) 361s s1 s2 s3 361s [1,] 1 3 5 361s [2,] 2 4 6 361s > 361s > Z <- rowAvgsPerColSet(X, S = S) 361s > print(Z) 361s s1 s2 s3 361s A -0.78997730 -0.25040807 -0.6780059 361s B -0.71963217 -0.06936153 0.6176800 361s C 0.92549614 -1.29678823 -0.1241766 361s D 0.72500682 0.11304929 -1.7112377 361s E -1.13230478 -0.25715086 0.6468944 361s F -1.31357784 -0.18367455 -1.5479382 361s G -0.48689893 -0.17936504 -0.6204656 361s H -0.37653548 -0.40432204 -0.7357547 361s I -0.59825011 0.35439575 -0.2683147 361s J 1.26924866 -0.77622258 0.1286536 361s K -0.09986055 0.24003818 -1.6232230 361s L 1.61125418 -0.13116276 -0.5218036 361s M -0.79468117 0.10023260 -1.0764575 361s N 0.70928504 0.71054405 0.6195292 361s O -0.79609297 0.71253170 -0.4644497 361s P -0.11597396 -0.18192877 -0.2425157 361s Q 0.89172223 0.54491038 0.9300048 361s R -0.65899067 -0.19667649 -0.1373037 361s S -0.90639283 0.38647801 -1.0353362 361s T 0.97792171 -1.34337465 0.9134182 361s > 361s > # Validation 361s > Z0 <- cbind(s1 = rowMeans(X[, 1:2]), s2 = rowMeans(X[, 3:4]), 361s + s3 = rowMeans(X[, 5:6])) 361s > stopifnot(identical(drop(Z), Z0)) 361s > 361s > 361s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 361s > # Apply colMeans() for 5 sets of 4 rows 361s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 361s > nbr_of_sets <- 5L 361s > S <- matrix(1:nrow(X), ncol = nbr_of_sets) 361s > colnames(S) <- sprintf("s%d", 1:nbr_of_sets) 361s > print(S) 362s s1 s2 s3 s4 s5 362s [1,] 1 5 9 13 17 362s [2,] 2 6 10 14 18 362s [3,] 3 7 11 15 19 362s [4,] 4 8 12 16 20 362s > 362s > Z <- colAvgsPerRowSet(X, S = S) 362s > print(Z) 362s a b c d e f 362s s1 0.62620602 -0.5557593 -0.8633960 0.1116417 -0.5053582 -0.44251187 362s s2 -0.67487003 -0.9797885 -0.7484004 0.2361441 -0.6822943 -0.44633779 362s s3 0.84284242 0.2483537 -0.3562443 0.1997686 -1.1681234 0.02577951 362s s4 -0.04364733 -0.4550842 0.8364950 -0.1658052 -0.5304011 -0.05154574 362s s5 -0.14789746 0.3000277 -0.2022129 -0.1021184 -0.7035133 1.03890486 362s > 362s > # Validation 362s > Z0 <- rbind(s1 = colMeans(X[1:4, ]), s2 = colMeans(X[5:8, ]), 362s + s3 = colMeans(X[9:12, ]), s4 = colMeans(X[13:16, ]), 362s + s5 = colMeans(X[17:20, ])) 362s > stopifnot(identical(drop(Z), Z0)) 362s > 362s > 362s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 362s > # When there is only one "complete" set 362s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 362s > nbr_of_sets <- 1L 362s > S <- matrix(1:ncol(X), ncol = nbr_of_sets) 362s > colnames(S) <- sprintf("s%d", 1:nbr_of_sets) 362s > print(S) 362s s1 362s [1,] 1 362s [2,] 2 362s [3,] 3 362s [4,] 4 362s [5,] 5 362s [6,] 6 362s > 362s > Z <- rowAvgsPerColSet(X, S = S, FUN = rowMeans) 362s > print(Z) 362s s1 362s A -0.57279710 362s B -0.05710458 362s C -0.16515622 362s D -0.29106052 362s E -0.24752040 362s F -1.01506354 362s G -0.42890987 362s H -0.50553741 362s I -0.17072303 362s J 0.20722655 362s K -0.49434845 362s L 0.31942927 362s M -0.59030203 362s N 0.67978610 362s O -0.18267031 362s P -0.18013946 362s Q 0.78887913 362s R -0.33099028 362s S -0.51841699 362s T 0.18265507 362s > 362s > Z0 <- rowMeans(X) 362s > stopifnot(identical(drop(Z), Z0)) 362s > 362s > 362s > nbr_of_sets <- 1L 362s > S <- matrix(1:nrow(X), ncol = nbr_of_sets) 362s > colnames(S) <- sprintf("s%d", 1:nbr_of_sets) 362s > print(S) 362s s1 362s [1,] 1 362s [2,] 2 362s [3,] 3 362s [4,] 4 362s [5,] 5 362s [6,] 6 362s [7,] 7 362s [8,] 8 362s [9,] 9 362s [10,] 10 362s [11,] 11 362s [12,] 12 362s [13,] 13 362s [14,] 14 362s [15,] 15 362s [16,] 16 362s [17,] 17 362s [18,] 18 362s [19,] 19 362s [20,] 20 362s > 362s > Z <- colAvgsPerRowSet(X, S = S, FUN = colMeans) 362s > print(Z) 362s a b c d e f 362s s1 0.1205267 -0.2884501 -0.2667517 0.05592615 -0.7179381 0.0248578 362s > 362s > Z0 <- colMeans(X) 362s > stopifnot(identical(drop(Z), Z0)) 362s > 362s > 362s > 362s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 362s > # Use weights 362s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 362s > nbr_of_sets <- 3L 362s > S <- matrix(1:ncol(X), ncol = nbr_of_sets) 362s > colnames(S) <- sprintf("s%d", 1:nbr_of_sets) 362s > print(S) 362s s1 s2 s3 362s [1,] 1 3 5 362s [2,] 2 4 6 362s > 362s > W <- matrix(runif(length(X)), nrow = nrow(X), ncol = ncol(X)) 362s > Z1 <- rowAvgsPerColSet(X, W = W, S = S, FUN = rowWeightedMeans) 362s > print(Z1) 362s s1 s2 s3 362s A -0.78997730 -0.25040807 -0.6780059 362s B -0.71963217 -0.06936153 0.6176800 362s C 0.92549614 -1.29678823 -0.1241766 362s D 0.72500682 0.11304929 -1.7112377 362s E -1.13230478 -0.25715086 0.6468944 362s F -1.31357784 -0.18367455 -1.5479382 362s G -0.48689893 -0.17936504 -0.6204656 362s H -0.37653548 -0.40432204 -0.7357547 362s I -0.59825011 0.35439575 -0.2683147 362s J 1.26924866 -0.77622258 0.1286536 362s K -0.09986055 0.24003818 -1.6232230 362s L 1.61125418 -0.13116276 -0.5218036 362s M -0.79468117 0.10023260 -1.0764575 362s N 0.70928504 0.71054405 0.6195292 362s O -0.79609297 0.71253170 -0.4644497 362s P -0.11597396 -0.18192877 -0.2425157 362s Q 0.89172223 0.54491038 0.9300048 362s R -0.65899067 -0.19667649 -0.1373037 362s S -0.90639283 0.38647801 -1.0353362 362s T 0.97792171 -1.34337465 0.9134182 362s > Z2 <- colAvgsPerRowSet(X, W = W, S = S, FUN = colWeightedMeans) 362s > print(Z2) 362s a b c d e f 362s s1 -0.02992301 -1.4796865 -0.6618414 0.34207175 0.2047043 -0.2650303 362s s2 1.28233506 0.3681679 -1.0649506 -0.11878836 -1.2154208 -0.6199934 362s s3 -0.96778318 -1.4780994 -0.5359803 0.09515491 -0.5453949 -0.3556489 362s > 362s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 362s > # Result should always be a matrix, including when nrow(X) <= 1 362s > # (https://github.com/HenrikBengtsson/matrixStats/issues/108) 362s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 362s > X <- matrix(1:3, nrow = 1L, ncol = 3L) 362s > S <- matrix(1, nrow = 1L, ncol = 1L) 362s > Z1 <- rowAvgsPerColSet(X, S = S) 362s > stopifnot(is.matrix(Z1)) 362s > Z2 <- rowAvgsPerColSet(X, S = S, rows = 0) 362s > stopifnot(is.matrix(Z2)) 362s > 362s > 362s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 362s > # Works with many, one or zero columns / rows 362s > # (https://github.com/HenrikBengtsson/matrixStats/issues/172) 362s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 362s > S <- cbind(1:2, 3:4, 5:6) 362s > X <- matrix(rnorm(2 * 6), nrow = 6, ncol = 2) 362s > Z2 <- colAvgsPerRowSet(X, S = S, FUN = colSums2) 362s > Z2_ref <- rbind(colSums2(X[S[,1], ,drop=FALSE]), 362s + colSums2(X[S[,2], ,drop=FALSE]), 362s + colSums2(X[S[,3], ,drop=FALSE])) 362s > stopifnot(identical(Z2, Z2_ref)) 362s > X <- matrix(rnorm(6), nrow = 6, ncol = 1) 362s > Z1 <- colAvgsPerRowSet(X, S = S, FUN = colSums2) 362s > Z1_ref <- rbind(colSums2(X[S[,1], ,drop=FALSE]), 362s + colSums2(X[S[,2], ,drop=FALSE]), 362s + colSums2(X[S[,3], ,drop=FALSE])) 362s > stopifnot(identical(Z1, Z1_ref)) 362s > X <- matrix(numeric(0), nrow = 6, ncol = 0) 362s > Z0 <- colAvgsPerRowSet(X, S = S, FUN = colSums2) 362s > Z0_ref <- matrix(numeric(0), nrow = ncol(S), ncol = 0) 362s > stopifnot(identical(Z0, unname(Z0_ref))) 362s > 362s > 362s > S <- rbind(1:4, 5:8) 362s > X <- matrix(rnorm(n = 2 * 8), nrow = 2, ncol = 8) 362s > Z2 <- rowAvgsPerColSet(X, S = S, FUN = rowMeans2) 362s > Z2_ref <- cbind(rowMeans2(X[,S[,1],drop=FALSE]), 362s + rowMeans2(X[,S[,2],drop=FALSE]), 362s + rowMeans2(X[,S[,3],drop=FALSE]), 362s + rowMeans2(X[,S[,4],drop=FALSE])) 362s > stopifnot(identical(Z2, Z2_ref)) 362s > X <- matrix(rnorm(n = 8), nrow = 1, ncol = 8) 362s > Z1 <- rowAvgsPerColSet(X, S = S, FUN = rowMeans2) 362s > Z1_ref <- cbind(rowMeans2(X[,S[,1],drop=FALSE]), 362s + rowMeans2(X[,S[,2],drop=FALSE]), 362s + rowMeans2(X[,S[,3],drop=FALSE]), 362s + rowMeans2(X[,S[,4],drop=FALSE])) 362s > stopifnot(identical(Z1, Z1_ref)) 362s > X <- matrix(numeric(0), nrow = 0, ncol = 8) 362s > Z0 <- rowAvgsPerColSet(X, S = S, FUN = rowMeans2) 362s > Z0_ref <- matrix(numeric(0), nrow = 0, ncol = ncol(S)) 362s > stopifnot(identical(Z0, Z0_ref)) 362s > 362s 362s R version 4.4.3 (2025-02-28) -- "Trophy Case" 362s Copyright (C) 2025 The R Foundation for Statistical Computing 362s Platform: arm-unknown-linux-gnueabihf (32-bit) 362s 362s R is free software and comes with ABSOLUTELY NO WARRANTY. 362s You are welcome to redistribute it under certain conditions. 362s Type 'license()' or 'licence()' for distribution details. 362s 362s R is a collaborative project with many contributors. 362s Type 'contributors()' for more information and 362s 'citation()' on how to cite R or R packages in publications. 362s 362s Type 'demo()' for some demos, 'help()' for on-line help, or 362s 'help.start()' for an HTML browser interface to help. 362s Type 'q()' to quit R. 362s 362s > library("matrixStats") 362s > 362s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 362s > # Subsetted tests 362s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 362s > source("utils/validateIndicesFramework.R") 362s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 362s > #W <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 362s > for (rows in index_cases) { 362s + for (cols in index_cases) { 362s + if (is.null(rows)) { 362s + rows <- seq_len(nrow(x)) 362s + rows_finite <- rows 362s + } else { 362s + rows_finite <- rows[is.finite(rows)] 362s + } 362s + 362s + if (is.null(cols)) { 362s + cols <- seq_len(ncol(x)) 362s + cols_finite <- cols 362s + } else { 362s + cols_finite <- cols[is.finite(cols)] 362s + } 362s + 362s + suppressWarnings({ 362s + actual <- tryCatch({ 362s + rowAvgsPerColSet(x, rows = rows, S = matrix(cols, ncol = 1), 362s + FUN = rowMeans) 362s + }, error = function(c) "error") 362s + expect <- tryCatch({ 362s + rowMeans(x[rows, cols_finite, drop = FALSE], na.rm = TRUE) 362s + }, error = function(c) "error") 362s + }) 362s + stopifnot(all.equal(as.vector(actual), expect)) 362s + 362s + suppressWarnings({ 362s + actual <- tryCatch({ 362s + colAvgsPerRowSet(x, cols = cols, S = matrix(rows, ncol = 1), 362s + FUN = colMeans) 362s + }, error = function(c) "error") 362s + expect <- tryCatch({ 362s + colMeans(x[rows_finite, cols, drop = FALSE], na.rm = TRUE) 362s + }, error = function(c) "error") 362s + }) 362s + stopifnot(all.equal(as.vector(actual), expect)) 362s + } 362s + } 362s > 362s 362s R version 4.4.3 (2025-02-28) -- "Trophy Case" 362s Copyright (C) 2025 The R Foundation for Statistical Computing 362s Platform: arm-unknown-linux-gnueabihf (32-bit) 362s 362s R is free software and comes with ABSOLUTELY NO WARRANTY. 362s You are welcome to redistribute it under certain conditions. 362s Type 'license()' or 'licence()' for distribution details. 362s 362s R is a collaborative project with many contributors. 362s Type 'contributors()' for more information and 362s 'citation()' on how to cite R or R packages in publications. 362s 362s Type 'demo()' for some demos, 'help()' for on-line help, or 362s 'help.start()' for an HTML browser interface to help. 362s Type 'q()' to quit R. 362s 362s > library("matrixStats") 362s > 362s > x <- matrix(1:27, ncol = 3) 362s > 362s > # To check names attribute 362s > dimnames <- list(letters[1:9], LETTERS[1:3]) 362s > 362s > rowCollapse_R <- function(x, idxs, ..., useNames = TRUE) { 362s + res <- x[, idxs] 362s + # Preserve names attribute? 362s + if (!useNames) names(res) <- NULL 362s + res 362s + } 362s > 362s > idxs <- 1L 362s > # Test with and without dimnames on x 362s > for (setDimnames in c(TRUE, FALSE)) { 362s + if (setDimnames) dimnames(x) <- dimnames 362s + else dimnames(x) <- NULL 362s + # Check names attribute 362s + for (useNames in c(TRUE, FALSE)) { 362s + y_truth <- rowCollapse_R(x, idxs, useNames = useNames) 362s + y <- rowCollapse(x, idxs, useNames = useNames) 362s + stopifnot(identical(y, y_truth)) 362s + y2 <- colCollapse(t(x), idxs, useNames = useNames) 362s + stopifnot(identical(y2, y)) 362s + } 362s + } 362s > 362s > idxs <- 2L 362s > # Test with and without dimnames on x 362s > for (setDimnames in c(TRUE, FALSE)) { 362s + if (setDimnames) dimnames(x) <- dimnames 362s + else dimnames(x) <- NULL 362s + # Check names attribute 362s + for (useNames in c(TRUE, FALSE)) { 362s + y_truth <- rowCollapse_R(x, idxs, useNames = useNames) 362s + y <- rowCollapse(x, idxs, useNames = useNames) 362s + stopifnot(identical(y, y_truth)) 362s + y2 <- colCollapse(t(x), idxs, useNames = useNames) 362s + stopifnot(identical(y2, y)) 362s + } 362s + } 362s > 362s > 362s > rowCollapse_R <- function(x, idxs, ..., useNames = TRUE) { 362s + res <- c(x[1:5, 1], x[6:9, 3]) 362s + # Preserve names attribute? 362s + if (!useNames) names(res) <- NULL 362s + res 362s + } 362s > 362s > idxs <- c(1, 1, 1, 1, 1, 3, 3, 3, 3) 362s > # Test with and without dimnames on x 362s > for (setDimnames in c(TRUE, FALSE)) { 362s + if (setDimnames) dimnames(x) <- dimnames 362s + else dimnames(x) <- NULL 362s + # Check names attribute 362s + for (useNames in c(TRUE, FALSE)) { 362s + y_truth <- rowCollapse_R(x, idxs, useNames = useNames) 362s + y <- rowCollapse(x, idxs, useNames = useNames) 362s + stopifnot(identical(y, y_truth)) 362s + y2 <- colCollapse(t(x), idxs, useNames = useNames) 362s + stopifnot(identical(y2, y)) 362s + } 362s + } 362s > 362s > 362s > rowCollapse_R <- function(x, idxs, ..., useNames = TRUE) { 362s + res <- c(x[1, 1], x[2, 2], x[3, 3], x[4, 1], x[5, 2], 362s + x[6, 3], x[7, 1], x[8, 2], x[9, 3]) 362s + # Preserve names attribute? 362s + if (useNames) { 362s + names <- rownames(x) 362s + if (!is.null(names)) names(res) <- names 362s + } 362s + res 362s + } 362s > 362s > idxs <- 1:3 362s > # Test with and without dimnames on x 362s > for (setDimnames in c(TRUE, FALSE)) { 362s + if (setDimnames) dimnames(x) <- dimnames 362s + else dimnames(x) <- NULL 362s + # Check names attribute 362s + for (useNames in c(TRUE, FALSE)) { 362s + y_truth <- rowCollapse_R(x, idxs, useNames = useNames) 362s + y <- rowCollapse(x, idxs, useNames = useNames) 362s + stopifnot(identical(y, y_truth)) 362s + y2 <- colCollapse(t(x), idxs, useNames = useNames) 362s + stopifnot(identical(y2, y)) 362s + } 362s + } 362s > 362s 362s R version 4.4.3 (2025-02-28) -- "Trophy Case" 362s Copyright (C) 2025 The R Foundation for Statistical Computing 362s Platform: arm-unknown-linux-gnueabihf (32-bit) 362s 362s R is free software and comes with ABSOLUTELY NO WARRANTY. 362s You are welcome to redistribute it under certain conditions. 362s Type 'license()' or 'licence()' for distribution details. 362s 362s R is a collaborative project with many contributors. 362s Type 'contributors()' for more information and 362s 'citation()' on how to cite R or R packages in publications. 362s 362s Type 'demo()' for some demos, 'help()' for on-line help, or 362s 'help.start()' for an HTML browser interface to help. 362s Type 'q()' to quit R. 362s 363s > library("matrixStats") 363s > 363s > rowCollapse_R <- function(x, idxs, ..., useNames = TRUE) { 363s + ans <- c() 363s + storage.mode(ans) <- storage.mode(x) 363s + for (ii in seq_len(length(idxs))) { 363s + ans[ii] <- x[ii, idxs[ii]] 363s + } 363s + 363s + # Preserve names attribute 363s + if (useNames) { 363s + names <- rownames(x) 363s + if (!is.null(names)) names(ans) <- names 363s + } 363s + 363s + ans 363s + } 363s > 363s > 363s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 363s > # Subsetted tests 363s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 363s > source("utils/validateIndicesFramework.R") 363s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 363s > storage.mode(x) <- "integer" 363s > 363s > # To check names attribute 363s > dimnames <- list(letters[1:6], LETTERS[1:6]) 363s > 363s > for (rows in index_cases) { 363s + if (is.null(rows)) rows <- seq_len(nrow(x)) 363s + 363s + for (idxs in list(2L, seq_len(6L))) { 363s + for (useNames in c(TRUE, FALSE)) { 363s + suppressWarnings({ 363s + actual <- tryCatch(rowCollapse(x, idxs, rows = rows, useNames = useNames), 363s + error = function(c) "error") 363s + expect <- tryCatch({ 363s + idxs_0 <- rep(idxs, length.out = nrow(x))[rows] 363s + rowCollapse_R(x[rows, , drop = FALSE], idxs_0, useNames = useNames) 363s + }, error = function(c) "error") 363s + }) 363s + stopifnot(all.equal(actual, expect)) 363s + 363s + suppressWarnings({ 363s + actual <- tryCatch(colCollapse(t(x), idxs, cols = rows, useNames = useNames), 363s + error = function(c) "error") 363s + }) 363s + stopifnot(all.equal(actual, expect)) 363s + 363s + # Check names attribute 363s + dimnames(x) <- dimnames 363s + suppressWarnings({ 363s + actual <- tryCatch(rowCollapse(x, idxs, rows = rows, useNames = useNames), 363s + error = function(c) "error") 363s + expect <- tryCatch({ 363s + idxs_0 <- rep(idxs, length.out = nrow(x))[rows] 363s + rowCollapse_R(x[rows, , drop = FALSE], idxs_0, useNames = useNames) 363s + }, error = function(c) "error") 363s + }) 363s + stopifnot(all.equal(actual, expect)) 363s + 363s + suppressWarnings({ 363s + actual <- tryCatch(colCollapse(t(x), idxs, cols = rows, useNames = useNames), 363s + error = function(c) "error") 363s + }) 363s + stopifnot(all.equal(actual, expect)) 363s + 363s + dimnames(x) <- NULL 363s + } 363s + } 363s + } 363s > 363s 363s R version 4.4.3 (2025-02-28) -- "Trophy Case" 363s Copyright (C) 2025 The R Foundation for Statistical Computing 363s Platform: arm-unknown-linux-gnueabihf (32-bit) 363s 363s R is free software and comes with ABSOLUTELY NO WARRANTY. 363s You are welcome to redistribute it under certain conditions. 363s Type 'license()' or 'licence()' for distribution details. 363s 363s R is a collaborative project with many contributors. 363s Type 'contributors()' for more information and 363s 'citation()' on how to cite R or R packages in publications. 363s 363s Type 'demo()' for some demos, 'help()' for on-line help, or 363s 'help.start()' for an HTML browser interface to help. 363s Type 'q()' to quit R. 363s 363s > library("matrixStats") 363s > 363s > rowCounts_R <- function(x, value = TRUE, na.rm = FALSE, ...) { 363s + if (is.na(value)) { 363s + counts <- apply(x, MARGIN = 1L, FUN = function(x) 363s + sum(is.na(x)) 363s + ) 363s + } else { 363s + counts <- apply(x, MARGIN = 1L, FUN = function(x) 363s + sum(x == value, na.rm = na.rm) 363s + ) 363s + } 363s + # Preserve names attribute 363s + names <- names(counts) 363s + counts <- as.integer(counts) 363s + if (useNames && !is.null(names)) names(counts) <- names 363s + counts 363s + } 363s > 363s > 363s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 363s > # Data type: integer and numeric 363s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 363s > for (mode in c("integer", "double")) { 363s + x <- matrix(runif(10 * 5, min = -3, max = 3), nrow = 10L, ncol = 5L) 363s + x[sample.int(length(x), size = 7L)] <- 0 363s + storage.mode(x) <- mode 363s + 363s + dimnames = list(letters[1:10], LETTERS[1:5]) 363s + 363s + # Test with and without dimnames on x 363s + for (setDimnames in c(TRUE, FALSE)) { 363s + if (setDimnames) dimnames(x) <- dimnames 363s + else dimnames(x) <- NULL 363s + for (na.rm in c(FALSE, TRUE)) { 363s + # Check names attribute 363s + for (useNames in c(TRUE, FALSE)) { 363s + # Count zeros 363s + r0 <- rowCounts_R(x, value = 0, na.rm = na.rm, useNames = useNames) 363s + r1 <- rowCounts(x, value = 0, na.rm = na.rm, useNames = useNames) 363s + r2 <- colCounts(t(x), value = 0, na.rm = na.rm, useNames = useNames) 363s + stopifnot(identical(r1, r0)) 363s + stopifnot(identical(r2, r0)) 363s + 363s + # Count NAs 363s + r0 <- rowCounts_R(x, value = NA, na.rm = na.rm, useNames = useNames) 363s + r1 <- rowCounts(x, value = NA, na.rm = na.rm, useNames = useNames) 363s + r2 <- colCounts(t(x), value = NA, na.rm = na.rm, useNames = useNames) 363s + stopifnot(identical(r1, r0)) 363s + stopifnot(identical(r2, r0)) 363s + 363s + if (mode == "integer") { 363s + ux <- unique(as.vector(x)) 363s + r0 <- r1 <- r2 <- integer(nrow(x)) 363s + for (value in ux) { 363s + r0 <- r0 + rowCounts_R(x, value = value, na.rm = na.rm, useNames = useNames) 363s + r1 <- r1 + rowCounts(x, value = value, na.rm = na.rm, useNames = useNames) 363s + r2 <- r2 + colCounts(t(x), value = value, na.rm = na.rm, useNames = useNames) 363s + stopifnot(identical(r1, r0)) 363s + stopifnot(identical(r2, r0)) 363s + } 363s + stopifnot(all(r0 == ncol(x))) 363s + } # if (mode == "integer") 363s + } # for (useNames ...) 363s + } # for (na.rm ...) 363s + } # for (setDimnames ...) 363s + } # for (mode ...) 363s > 363s > 363s > # All NAs 363s > na_list <- list(NA_integer_, NA_real_, NaN) 363s > for (na_value in na_list) { 363s + x <- matrix(na_value, nrow = 10L, ncol = 5L) 363s + # Test with and without dimnames on x 363s + for (setDimnames in c(TRUE, FALSE)) { 363s + if (setDimnames) dimnames(x) <- dimnames 363s + else dimnames(x) <- NULL 363s + for (na.rm in c(FALSE, TRUE)) { 363s + # Check names attribute 363s + for (useNames in c(TRUE, FALSE)) { 363s + r0 <- rowCounts_R(x, na.rm = na.rm, useNames = useNames) 363s + r1 <- rowCounts(x, na.rm = na.rm, useNames = useNames) 363s + r2 <- colCounts(t(x), na.rm = na.rm, useNames = useNames) 363s + stopifnot(identical(r1, r0)) 363s + stopifnot(identical(r2, r0)) 363s + 363s + # Count NAs 363s + r0 <- rowCounts_R(x, value = NA, na.rm = na.rm, useNames = useNames) 363s + r1 <- rowCounts(x, value = NA, na.rm = na.rm, useNames = useNames) 363s + r2 <- colCounts(t(x), value = NA, na.rm = na.rm, useNames = useNames) 363s + stopifnot(all(r0 == ncol(x))) 363s + stopifnot(identical(r1, r0)) 363s + stopifnot(identical(r2, r0)) 363s + } 363s + } 363s + } 363s + } # for (na_value ...) 363s > 363s > 363s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 363s > # Data type: logical 363s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 363s > x <- matrix(FALSE, nrow = 10L, ncol = 4L) 363s > x[7:8, 2:3] <- TRUE 363s > x[1:3, ] <- TRUE 363s > x[, 1] <- TRUE 363s > x[4, ] <- FALSE 363s > x[, 4] <- FALSE 363s > x[2, ] <- FALSE 363s > x[3, ] <- TRUE 363s > 363s > # To check names attribute 363s > dimnames <- list(letters[1:10], LETTERS[1:4]) 363s > 363s > # Test with and without dimnames on x 363s > for (setDimnames in c(TRUE, FALSE)) { 363s + if (setDimnames) dimnames(x) <- dimnames 363s + else dimnames(x) <- NULL 363s + # Row/column counts 363s + for (na.rm in c(FALSE, TRUE)) { 363s + # Check names attribute 363s + for (useNames in c(TRUE, FALSE)) { 363s + r0 <- rowCounts_R(x, na.rm = na.rm, useNames = useNames) 363s + r1 <- rowCounts(x, na.rm = na.rm, useNames = useNames) 363s + r2 <- colCounts(t(x), na.rm = na.rm, useNames = useNames) 363s + stopifnot(identical(r1, r0)) 363s + stopifnot(identical(r2, r0)) 363s + 363s + r_true <- rowCounts(x, value = TRUE, na.rm = na.rm, useNames = useNames) 363s + r_false <- rowCounts(x, value = FALSE, na.rm = na.rm, useNames = useNames) 363s + stopifnot(r_true + r_false == ncol(x)) 363s + 363s + c_true <- colCounts(x, value = TRUE, na.rm = na.rm, useNames = useNames) 363s + c_false <- colCounts(x, value = FALSE, na.rm = na.rm, useNames = useNames) 363s + stopifnot(c_true + c_false == nrow(x)) 363s + 363s + # Count NAs 363s + r0 <- rowCounts_R(x, value = NA, na.rm = na.rm, useNames = useNames) 363s + r1 <- rowCounts(x, value = NA, na.rm = na.rm, useNames = useNames) 363s + r2 <- colCounts(t(x), value = NA, na.rm = na.rm, useNames = useNames) 363s + stopifnot(identical(r1, r0)) 363s + stopifnot(identical(r2, r0)) 363s + } 363s + } 363s + } 363s > 363s > 363s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 363s > # Data type: character (not sure if this should be supported) 363s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 363s > x <- matrix(rep(letters, length.out = 10 * 5), nrow = 10L, ncol = 5L) 363s > x[2:3, 3:4] <- NA_character_ 363s > 363s > # Row/column counts 363s > for (na.rm in c(FALSE, TRUE)) { 363s + for (value in c("g", NA_character_)) { 363s + r0 <- rowCounts_R(x, value = value, na.rm = na.rm) 363s + r1 <- rowCounts(x, value = value, na.rm = na.rm) 363s + r2 <- colCounts(t(x), value = value, na.rm = na.rm) 363s + stopifnot(identical(r1, r0)) 363s + stopifnot(identical(r2, r0)) 363s + 363s + c <- count(x[1, ], value = value, na.rm = na.rm) 363s + stopifnot(identical(c, r1[1])) 363s + 363s + c <- count(x[2, ], value = value, na.rm = na.rm) 363s + stopifnot(identical(c, r1[2])) 363s + } 363s + } 363s > 363s > # NA row 363s > x <- matrix(0, nrow = 2L, ncol = 2L) 363s > x[1, ] <- NA_integer_ 363s > 363s > dimnames <- list(letters[1:2], LETTERS[1:2]) 363s > 363s > # Test with and without dimnames on x 363s > for (setDimnames in c(TRUE, FALSE)) { 363s + if (setDimnames) dimnames(x) <- dimnames 363s + else dimnames(x) <- NULL 363s + # Check names attribute 363s + for (useNames in c(TRUE, FALSE)) { 363s + r0 <- rowCounts(x, value = 0, useNames = useNames) 363s + r1 <- rowCounts_R(x, value = 0, useNames = useNames) 363s + stopifnot(identical(r0, r1)) 363s + } 363s + } 363s > 363s 363s R version 4.4.3 (2025-02-28) -- "Trophy Case" 363s Copyright (C) 2025 The R Foundation for Statistical Computing 363s Platform: arm-unknown-linux-gnueabihf (32-bit) 363s 363s R is free software and comes with ABSOLUTELY NO WARRANTY. 363s You are welcome to redistribute it under certain conditions. 363s Type 'license()' or 'licence()' for distribution details. 363s 363s R is a collaborative project with many contributors. 363s Type 'contributors()' for more information and 363s 'citation()' on how to cite R or R packages in publications. 363s 363s Type 'demo()' for some demos, 'help()' for on-line help, or 363s 'help.start()' for an HTML browser interface to help. 363s Type 'q()' to quit R. 363s 363s > library("matrixStats") 363s > 363s > rowCounts_R <- function(x, value = TRUE, na.rm = FALSE, ..., useNames = TRUE) { 363s + if (is.na(value)) { 363s + counts <- apply(x, MARGIN = 1L, FUN = function(x) 363s + sum(is.na(x)) 363s + ) 363s + } else { 363s + counts <- apply(x, MARGIN = 1L, FUN = function(x) 363s + sum(x == value, na.rm = na.rm) 363s + ) 363s + } 363s + # Preserve names attribute 363s + names <- names(counts) 363s + counts <- as.integer(counts) 363s + if (useNames && !is.null(names)) names(counts) <- names 363s + counts 363s + } # rowCounts_R() 363s > 363s > 363s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 363s > # Subsetted tests 363s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 363s > source("utils/validateIndicesFramework.R") 363s > x <- matrix(runif(6 * 6, min = -3, max = 3), nrow = 6, ncol = 6) 363s > x[2:3, 3:4] <- NA_real_ 363s > storage.mode(x) <- "integer" 363s > 363s > # To check names attribute 363s > dimnames <- list(letters[1:6], LETTERS[1:6]) 363s > 363s > # Test with and without dimnames on x 363s > for (setDimnames in c(TRUE, FALSE)) { 363s + if (setDimnames) dimnames(x) <- dimnames 363s + else dimnames(x) <- NULL 363s + for (rows in index_cases) { 363s + for (cols in index_cases) { 363s + # Check names attribute 363s + for (useNames in c(TRUE, FALSE)) { 363s + validateIndicesTestMatrix(x, rows, cols, 363s + ftest = rowCounts, fsure = rowCounts_R, 363s + value = 0, na.rm = TRUE, useNames = useNames) 363s + validateIndicesTestMatrix(x, rows, cols, 363s + fcoltest = colCounts, fsure = rowCounts_R, 363s + value = 0, na.rm = TRUE, useNames = useNames) 363s + for (value in c(0, NA_integer_)) { 363s + validateIndicesTestMatrix(x, rows, cols, 363s + ftest = rowCounts, fsure = rowCounts_R, 363s + value = value, useNames = useNames) 363s + validateIndicesTestMatrix(x, rows, cols, 363s + fcoltest = colCounts, fsure = rowCounts_R, 363s + value = value, useNames = useNames) 363s + } 363s + } 363s + } 363s + } 363s + } 366s > 366s > x <- matrix(rep(letters, length.out = 6 * 6), nrow = 6, ncol = 6) 366s > x[2:3, 3:4] <- NA_character_ 366s > # Test with and without dimnames on x 366s > for (setDimnames in c(TRUE, FALSE)) { 366s + if (setDimnames) dimnames(x) <- dimnames 366s + else dimnames(x) <- NULL 366s + 366s + count <- 0L 366s + for (rows in index_cases) { 366s + for (cols in index_cases) { 366s + count <- count + 1L 366s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 366s + useNames <- c(TRUE, FALSE) 366s + useNames <- useNames[count %% length(useNames) + 1] 366s + 366s + validateIndicesTestMatrix(x, rows, cols, 366s + ftest = rowCounts, fsure = rowCounts_R, 366s + value = "g", na.rm = TRUE, useNames = useNames) 366s + validateIndicesTestMatrix(x, rows, cols, 366s + fcoltest = colCounts, fsure = rowCounts_R, 366s + value = "g", na.rm = TRUE, useNames = useNames) 366s + for (value in c("g", NA_character_)) { 366s + validateIndicesTestMatrix(x, rows, cols, 366s + ftest = rowCounts, fsure = rowCounts_R, 366s + value = value, useNames = useNames) 366s + validateIndicesTestMatrix(x, rows, cols, 366s + fcoltest = colCounts, fsure = rowCounts_R, 366s + value = value, useNames = useNames) 366s + } 366s + } 366s + } 366s + } 368s > 368s 368s R version 4.4.3 (2025-02-28) -- "Trophy Case" 368s Copyright (C) 2025 The R Foundation for Statistical Computing 368s Platform: arm-unknown-linux-gnueabihf (32-bit) 368s 368s R is free software and comes with ABSOLUTELY NO WARRANTY. 368s You are welcome to redistribute it under certain conditions. 368s Type 'license()' or 'licence()' for distribution details. 368s 368s R is a collaborative project with many contributors. 368s Type 'contributors()' for more information and 368s 'citation()' on how to cite R or R packages in publications. 368s 368s Type 'demo()' for some demos, 'help()' for on-line help, or 368s 'help.start()' for an HTML browser interface to help. 368s Type 'q()' to quit R. 368s 368s > library("matrixStats") 368s > 368s > rowCummins_R <- function(x, ..., useNames = TRUE) { 368s + suppressWarnings({ 368s + y <- t(apply(x, MARGIN = 1L, FUN = cummin)) 368s + }) 368s + 368s + # Preserve dimnames attribute? 368s + dim(y) <- dim(x) 368s + dimnames(y) <- if (useNames) dimnames(x) else NULL 368s + y 368s + } 368s > 368s > rowCummaxs_R <- function(x, ..., useNames = TRUE) { 368s + mode <- storage.mode(x) 368s + # Change mode because a bug is detected on cummax for integer in R-3.2.0 368s + storage.mode(x) <- "numeric" 368s + suppressWarnings({ 368s + y <- t(apply(x, MARGIN = 1L, FUN = cummax)) 368s + }) 368s + 368s + # Preserve dimnames attribute? 368s + dim(y) <- dim(x) 368s + dimnames(y) <- if (useNames) dimnames(x) else NULL 368s + 368s + y 368s + } 368s > 368s > 368s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 368s > # With and without some NAs 368s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 368s > for (mode in c("logical", "integer", "double")) { 368s + for (add_na in c(FALSE, TRUE)) { 368s + cat("add_na = ", add_na, "\n", sep = "") 368s + 368s + x <- matrix(1:50, nrow = 10L, ncol = 5L) 368s + diag(x) <- 0 368s + if (add_na) { 368s + x[3:7, c(2, 4)] <- NA_real_ 368s + } 368s + cat("mode: ", mode, "\n", sep = "") 368s + storage.mode(x) <- mode 368s + str(x) 368s + 368s + # To check dimnames attribute 368s + dimnames <- list(letters[1:10], LETTERS[1:5]) 368s + 368s + # Test with and without dimnames on x 368s + for (setDimnames in c(TRUE, FALSE)) { 368s + if (setDimnames) dimnames(x) <- dimnames 368s + else dimnames(x) <- NULL 368s + # Check names attribute 368s + for (useNames in c(TRUE, FALSE)) { 368s + # Row/column ranges 368s + r0 <- rowCummins_R(x, useNames = useNames) 368s + r1 <- rowCummins(x, useNames = useNames) 368s + r2 <- t(colCummins(t(x), useNames = useNames)) 368s + stopifnot(all.equal(r1, r2)) 368s + stopifnot(all.equal(r1, r0)) 368s + stopifnot(all.equal(r2, r0)) 368s + 368s + r0 <- rowCummaxs_R(x, useNames = useNames) 368s + r1 <- rowCummaxs(x, useNames = useNames) 368s + r2 <- t(colCummaxs(t(x), useNames = useNames)) 368s + stopifnot(all.equal(r1, r2)) 368s + stopifnot(all.equal(r1, r0)) 368s + stopifnot(all.equal(r2, r0)) 368s + } # for (useNames ...) 368s + } # for (setDimnames ...) 368s + } # for (add_na ...) 368s + } # for (mode ...) 368s add_na = FALSE 368s mode: logical 368s logi [1:10, 1:5] FALSE TRUE TRUE TRUE TRUE TRUE ... 368s add_na = TRUE 368s mode: logical 368s logi [1:10, 1:5] FALSE TRUE TRUE TRUE TRUE TRUE ... 368s add_na = FALSE 368s mode: integer 368s int [1:10, 1:5] 0 2 3 4 5 6 7 8 9 10 ... 368s add_na = TRUE 368s mode: integer 368s int [1:10, 1:5] 0 2 3 4 5 6 7 8 9 10 ... 368s add_na = FALSE 368s mode: double 368s num [1:10, 1:5] 0 2 3 4 5 6 7 8 9 10 ... 368s add_na = TRUE 368s mode: double 368s num [1:10, 1:5] 0 2 3 4 5 6 7 8 9 10 ... 368s > 368s > 368s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 368s > # All NAs 368s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 368s > for (mode in c("logical", "integer", "double")) { 368s + x <- matrix(NA_real_, nrow = 10L, ncol = 5L) 368s + cat("mode: ", mode, "\n", sep = "") 368s + storage.mode(x) <- mode 368s + str(x) 368s + 368s + # Test with and without dimnames on x 368s + for (setDimnames in c(TRUE, FALSE)) { 368s + if (setDimnames) dimnames(x) <- dimnames 368s + else dimnames(x) <- NULL 368s + # Check names attribute 368s + for (useNames in c(TRUE, FALSE)) { 368s + r0 <- rowCummins_R(x, useNames = useNames) 368s + r1 <- rowCummins(x, useNames = useNames) 368s + r2 <- t(colCummins(t(x), useNames = useNames)) 368s + stopifnot(all.equal(r1, r2)) 368s + stopifnot(all.equal(r1, r0)) 368s + stopifnot(all.equal(r2, r0)) 368s + 368s + r0 <- rowCummaxs_R(x, useNames = useNames) 368s + r1 <- rowCummaxs(x, useNames = useNames) 368s + r2 <- t(colCummaxs(t(x), useNames = useNames)) 368s + stopifnot(all.equal(r1, r2)) 368s + stopifnot(all.equal(r1, r0)) 368s + stopifnot(all.equal(r2, r0)) 368s + } # for (useNames ...) 368s + } # for (setDimnames ...) 368s + } # for (mode ...) 368s mode: logical 368s logi [1:10, 1:5] NA NA NA NA NA NA ... 368s mode: integer 368s int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 368s mode: double 368s num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 368s > 368s > 368s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 368s > # A 1x1 matrix 368s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 368s > for (mode in c("logical", "integer", "double")) { 368s + x <- matrix(0, nrow = 1L, ncol = 1L) 368s + cat("mode: ", mode, "\n", sep = "") 368s + storage.mode(x) <- mode 368s + str(x) 368s + 368s + # To check dimnames attribute 368s + dimnames <- list("a", "A") 368s + 368s + # Test with and without dimnames on x 368s + for (setDimnames in c(TRUE, FALSE)) { 368s + if (setDimnames) dimnames(x) <- dimnames 368s + else dimnames(x) <- NULL 368s + # Check names attribute 368s + for (useNames in c(TRUE, FALSE)) { 368s + r0 <- rowCummins_R(x, useNames = useNames) 368s + r1 <- rowCummins(x, useNames = useNames) 368s + r2 <- t(colCummins(t(x), useNames = useNames)) 368s + stopifnot(all.equal(r1, r2)) 368s + stopifnot(all.equal(r1, r0)) 368s + stopifnot(all.equal(r2, r0)) 368s + 368s + r0 <- rowCummaxs_R(x, useNames = useNames) 368s + r1 <- rowCummaxs(x, useNames = useNames) 368s + r2 <- t(colCummaxs(t(x), useNames = useNames)) 368s + stopifnot(all.equal(r1, r2)) 368s + stopifnot(all.equal(r1, r0)) 368s + stopifnot(all.equal(r2, r0)) 368s + } # for (useNames ...) 368s + } # for (setDimnames ...) 368s + } # for (mode ...) 368s mode: logical 368s logi [1, 1] FALSE 368s mode: integer 368s int [1, 1] 0 368s mode: double 368s num [1, 1] 0 368s > 368s > 368s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 368s > # Corner cases 368s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 368s > for (mode in c("logical", "integer", "double")) { 368s + cat("mode: ", mode, "\n", sep = "") 368s + value <- 0 368s + storage.mode(value) <- mode 368s + value0 <- if (mode == "logical") 0L else value 368s + 368s + # A 0x0 matrix 368s + x <- matrix(value, nrow = 0L, ncol = 0L) 368s + str(x) 368s + r0 <- matrix(value0, nrow = nrow(x), ncol = ncol(x)) 368s + r1 <- rowCummins(x) 368s + r2 <- t(colCummins(t(x))) 368s + stopifnot(all.equal(r1, r2)) 368s + stopifnot(all.equal(r1, r0)) 368s + stopifnot(all.equal(r2, r0)) 368s + 368s + # A 0xK matrix 368s + x <- matrix(value, nrow = 0L, ncol = 5L) 368s + str(x) 368s + colnames <- LETTERS[1:5] 368s + # Test with and without dimnames on x 368s + for (setDimnames in c(TRUE, FALSE)) { 368s + if (setDimnames) colnames(x) <- colnames 368s + else dimnames(x) <- NULL 368s + # Check names attribute 368s + for (useNames in c(TRUE, FALSE)) { 368s + r0 <- rowCummins_R(x, useNames = useNames) 368s + r1 <- rowCummins(x, useNames = useNames) 368s + r2 <- t(colCummins(t(x), useNames = useNames)) 368s + stopifnot(all.equal(r1, r2)) 368s + stopifnot(all.equal(r1, r0)) 368s + stopifnot(all.equal(r2, r0)) 368s + r0 <- rowCummaxs_R(x, useNames = useNames) 368s + r1 <- rowCummaxs(x, useNames = useNames) 368s + r2 <- t(colCummaxs(t(x), useNames = useNames)) 368s + stopifnot(all.equal(r1, r2)) 368s + stopifnot(all.equal(r1, r0)) 368s + stopifnot(all.equal(r2, r0)) 368s + } # for (useNames ...) 368s + } # for (setDimnames ...) 368s + 368s + # A Nx0 matrix 368s + x <- matrix(value, nrow = 5L, ncol = 0L) 368s + str(x) 368s + rownames <- LETTERS[1:5] 368s + # Test with and without dimnames on x 368s + for (setDimnames in c(TRUE, FALSE)) { 368s + if (setDimnames) rownames(x) <- rownames 368s + else dimnames(x) <- NULL 368s + # Check names attribute 368s + for (useNames in c(TRUE, FALSE)) { 368s + r0 <- rowCummins_R(x, useNames = useNames) 368s + r1 <- rowCummins(x, useNames = useNames) 368s + r2 <- t(colCummins(t(x), useNames = useNames)) 368s + stopifnot(all.equal(r1, r2)) 368s + stopifnot(all.equal(r1, r0)) 368s + stopifnot(all.equal(r2, r0)) 368s + 368s + r0 <- rowCummaxs_R(x, useNames = useNames) 368s + r1 <- rowCummaxs(x, useNames = useNames) 368s + r2 <- t(colCummaxs(t(x), useNames = useNames)) 368s + stopifnot(all.equal(r1, r2)) 368s + stopifnot(all.equal(r1, r0)) 368s + stopifnot(all.equal(r2, r0)) 368s + } # for (useNames ...) 368s + } # for (setDimnames ...) 368s + } # for (mode ...) 369s mode: logical 369s logi[0 , 0 ] 369s logi[0 , 1:5] 369s logi[1:5, 0 ] 369s mode: integer 369s int[0 , 0 ] 369s int[0 , 1:5] 369s int[1:5, 0 ] 369s mode: double 369s num[0 , 0 ] 369s num[0 , 1:5] 369s num[1:5, 0 ] 369s > 369s 369s R version 4.4.3 (2025-02-28) -- "Trophy Case" 369s Copyright (C) 2025 The R Foundation for Statistical Computing 369s Platform: arm-unknown-linux-gnueabihf (32-bit) 369s 369s R is free software and comes with ABSOLUTELY NO WARRANTY. 369s You are welcome to redistribute it under certain conditions. 369s Type 'license()' or 'licence()' for distribution details. 369s 369s R is a collaborative project with many contributors. 369s Type 'contributors()' for more information and 369s 'citation()' on how to cite R or R packages in publications. 369s 369s Type 'demo()' for some demos, 'help()' for on-line help, or 369s 'help.start()' for an HTML browser interface to help. 369s Type 'q()' to quit R. 369s 369s > library("matrixStats") 369s > 369s > rowCummins_R <- function(x, ..., useNames = TRUE) { 369s + suppressWarnings({ 369s + y <- t(apply(x, MARGIN = 1L, FUN = cummin)) 369s + }) 369s + 369s + # Preserve dimnames attribute? 369s + dim(y) <- dim(x) 369s + dimnames(y) <- if (useNames) dimnames(x) else NULL 369s + 369s + y 369s + } 369s > 369s > rowCummaxs_R <- function(x, ..., useNames = TRUE) { 369s + mode <- storage.mode(x) 369s + # Change mode because a bug is detected on cummax for integer in R-3.2.0 369s + storage.mode(x) <- "numeric" 369s + suppressWarnings({ 369s + y <- t(apply(x, MARGIN = 1L, FUN = cummax)) 369s + }) 369s + 369s + # Preserve dimnames attribute? 369s + dim(y) <- dim(x) 369s + dimnames(y) <- if (useNames) dimnames(x) else NULL 369s + 369s + storage.mode(y) <- mode 369s + y 369s + } 369s > 369s > 369s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 369s > # Subsetted tests 369s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 369s > source("utils/validateIndicesFramework.R") 369s > x <- matrix(runif(6 * 6, min = -3, max = 3), nrow = 6, ncol = 6) 369s > storage.mode(x) <- "integer" 369s > 369s > # To check dimnames attribute 369s > dimnames <- list(letters[1:6], LETTERS[1:6]) 369s > 369s > # Test with and without dimnames on x 369s > for (setDimnames in c(TRUE, FALSE)) { 369s + if (setDimnames) dimnames(x) <- dimnames 369s + else dimnames(x) <- NULL 369s + for (rows in index_cases) { 369s + for (cols in index_cases) { 369s + # Check names attribute 369s + for (useNames in c(TRUE, FALSE)) { 369s + validateIndicesTestMatrix(x, rows, cols, 369s + ftest = rowCummins, fsure = rowCummins_R, useNames = useNames,verbose=TRUE) 369s + validateIndicesTestMatrix(x, rows, cols, 369s + ftest = function(x, rows, cols, ..., useNames) { 369s + t(colCummins(t(x), rows = cols, cols = rows, useNames = useNames)) 369s + }, fsure = rowCummins_R, useNames = useNames) 369s + 369s + validateIndicesTestMatrix(x, rows, cols, 369s + ftest = rowCummaxs, fsure = rowCummaxs_R, useNames = useNames) 369s + validateIndicesTestMatrix(x, rows, cols, 369s + ftest = function(x, rows, cols, ..., useNames) { 369s + t(colCummaxs(t(x), rows = cols, cols = rows, useNames = useNames)) 369s + }, fsure = rowCummaxs_R, useNames = useNames) 369s + } 369s + } 369s + } 369s + } 372s > 372s 372s R version 4.4.3 (2025-02-28) -- "Trophy Case" 372s Copyright (C) 2025 The R Foundation for Statistical Computing 372s Platform: arm-unknown-linux-gnueabihf (32-bit) 372s 372s R is free software and comes with ABSOLUTELY NO WARRANTY. 372s You are welcome to redistribute it under certain conditions. 372s Type 'license()' or 'licence()' for distribution details. 372s 372s R is a collaborative project with many contributors. 372s Type 'contributors()' for more information and 372s 'citation()' on how to cite R or R packages in publications. 372s 372s Type 'demo()' for some demos, 'help()' for on-line help, or 372s 'help.start()' for an HTML browser interface to help. 372s Type 'q()' to quit R. 372s 372s > library("matrixStats") 372s > 372s > rowCumprods_R <- function(x, ..., useNames = TRUE) { 372s + suppressWarnings({ 372s + y <- t(apply(x, MARGIN = 1L, FUN = cumprod)) 372s + }) 372s + 372s + # Preserve dimnames attribute? 372s + dim(y) <- dim(x) 372s + dimnames(y) <- if (useNames) dimnames(x) else NULL 372s + 372s + y 372s + } 372s > 372s > 372s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 372s > # With and without some NAs 372s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 372s > for (mode in c("logical", "integer", "double")) { 372s + for (add_na in c(FALSE, TRUE)) { 372s + cat("add_na = ", add_na, "\n", sep = "") 372s + 372s + x <- matrix(1:50, nrow = 10L, ncol = 5L) 372s + if (add_na) { 372s + x[3:7, c(2, 4)] <- NA_real_ 372s + } 372s + cat("mode: ", mode, "\n", sep = "") 372s + storage.mode(x) <- mode 372s + str(x) 372s + 372s + # To check dimnames attribute 372s + dimnames <- list(letters[1:10], LETTERS[1:5]) 372s + 372s + # Test with and without dimnames on x 372s + for (setDimnames in c(TRUE, FALSE)) { 372s + if (setDimnames) dimnames(x) <- dimnames 372s + else dimnames(x) <- NULL 372s + # Check names attribute 372s + for (useNames in c(TRUE, FALSE)) { 372s + # Row/column ranges 372s + r0 <- rowCumprods_R(x, useNames = useNames) 372s + r1 <- rowCumprods(x, useNames = useNames) 372s + r2 <- t(colCumprods(t(x), useNames = useNames)) 372s + stopifnot(all.equal(r1, r2)) 372s + stopifnot(all.equal(r1, r0)) 372s + stopifnot(all.equal(r2, r0)) 372s + } # for (useNames ...) 372s + } # for (setDimnames ...) 372s + } # for (add_na ...) 372s + } # for (mode ...) 372s add_na = FALSE 372s mode: logical 372s logi [1:10, 1:5] TRUE TRUE TRUE TRUE TRUE TRUE ... 372s add_na = TRUE 372s mode: logical 372s logi [1:10, 1:5] TRUE TRUE TRUE TRUE TRUE TRUE ... 372s add_na = FALSE 372s mode: integer 372s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 372s add_na = TRUE 372s mode: integer 372s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 372s add_na = FALSE 372s mode: double 372s num [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 372s add_na = TRUE 372s mode: double 372s num [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 372s > 372s > 372s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 372s > # All NAs 372s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 372s > for (mode in c("logical", "integer", "double")) { 372s + x <- matrix(NA_real_, nrow = 10L, ncol = 5L) 372s + cat("mode: ", mode, "\n", sep = "") 372s + storage.mode(x) <- mode 372s + str(x) 372s + 372s + # Test with and without dimnames on x 372s + for (setDimnames in c(TRUE, FALSE)) { 372s + if (setDimnames) dimnames(x) <- dimnames 372s + else dimnames(x) <- NULL 372s + # Check names attribute 372s + for (useNames in c(TRUE, FALSE)) { 372s + # Row/column ranges 372s + r0 <- rowCumprods_R(x, useNames = useNames) 372s + r1 <- rowCumprods(x, useNames = useNames) 372s + r2 <- t(colCumprods(t(x), useNames = useNames)) 372s + stopifnot(all.equal(r1, r2)) 372s + stopifnot(all.equal(r1, r0)) 372s + stopifnot(all.equal(r2, r0)) 372s + } # for (useNames ...) 372s + } # for (setDimnames ...) 372s + } # for (mode ...) 372s mode: logical 372s logi [1:10, 1:5] NA NA NA NA NA NA ... 372s mode: integer 372s int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 372s mode: double 372s num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 372s > 372s > 372s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 372s > # A 1x1 matrix 372s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 372s > for (mode in c("logical", "integer", "double")) { 372s + x <- matrix(0, nrow = 1L, ncol = 1L) 372s + cat("mode: ", mode, "\n", sep = "") 372s + storage.mode(x) <- mode 372s + str(x) 372s + 372s + dimnames <- list("a", "A") 372s + # Test with and without dimnames on x 372s + for (setDimnames in c(TRUE, FALSE)) { 372s + if (setDimnames) dimnames(x) <- dimnames 372s + else dimnames(x) <- NULL 372s + # Check names attribute 372s + for (useNames in c(TRUE, FALSE)) { 372s + # Row/column ranges 372s + r0 <- rowCumprods_R(x, useNames = useNames) 372s + r1 <- rowCumprods(x, useNames = useNames) 372s + r2 <- t(colCumprods(t(x), useNames = useNames)) 372s + stopifnot(all.equal(r1, r2)) 372s + stopifnot(all.equal(r1, r0)) 372s + stopifnot(all.equal(r2, r0)) 372s + } # for (useNames ...) 372s + } # for (setDimnames ...) 372s + } 372s mode: logical 372s logi [1, 1] FALSE 372s mode: integer 372s int [1, 1] 0 372s mode: double 372s num [1, 1] 0 372s > 372s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 372s > # BUG FIX TEST: Assert zeros don't trump NAs in integer matrices 372s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 372s > for (mode in c("logical", "integer", "double")) { 372s + x <- matrix(NA_real_, nrow = 3L, ncol = 2L) 372s + x[1, 2] <- 0 372s + x[2, 2] <- 1 372s + x[3, 1] <- 0 372s + storage.mode(x) <- mode 372s + cat("mode: ", mode, "\n", sep = "") 372s + str(x) 372s + 372s + dimnames <- list(letters[1:3], LETTERS[1:2]) 372s + # Test with and without dimnames on x 372s + for (setDimnames in c(TRUE, FALSE)) { 372s + if (setDimnames) dimnames(x) <- dimnames 372s + else dimnames(x) <- NULL 372s + # Check names attribute 372s + for (useNames in c(TRUE, FALSE)) { 372s + # Row/column ranges 372s + r0 <- rowCumprods_R(x, useNames = useNames) 372s + r1 <- rowCumprods(x, useNames = useNames) 372s + r2 <- t(colCumprods(t(x), useNames = useNames)) 372s + stopifnot(all.equal(r1, r2)) 372s + stopifnot(all.equal(r1, r0)) 372s + stopifnot(all.equal(r2, r0)) 372s + } # for (useNames ...) 372s + } # for (setDimnames ...) 372s + } 372s mode: logical 372s logi [1:3, 1:2] NA NA FALSE FALSE TRUE NA 372s mode: integer 372s int [1:3, 1:2] NA NA 0 0 1 NA 372s mode: double 372s num [1:3, 1:2] NA NA 0 0 1 NA 372s > 372s > 372s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 372s > # Corner cases 372s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 372s > for (mode in c("logical", "integer", "double")) { 372s + cat("mode: ", mode, "\n", sep = "") 372s + value <- 0 372s + storage.mode(value) <- mode 372s + if (mode == "logical") value2 <- 0L 372s + 372s + # A 0x0 matrix 372s + x <- matrix(value, nrow = 0L, ncol = 0L) 372s + str(x) 372s + r0 <- matrix(value2, nrow = nrow(x), ncol = ncol(x)) 372s + r1 <- rowCumprods(x) 372s + r2 <- t(colCumprods(t(x))) 372s + stopifnot(all.equal(r1, r2)) 372s + stopifnot(all.equal(r1, r0)) 372s + stopifnot(all.equal(r2, r0)) 372s + 372s + # A 0xK matrix 372s + x <- matrix(value, nrow = 0L, ncol = 5L) 372s + str(x) 372s + colnames <- LETTERS[1:5] 372s + # Test with and without dimnames on x 372s + for (setDimnames in c(TRUE, FALSE)) { 372s + if (setDimnames) colnames(x) <- colnames 372s + else dimnames(x) <- NULL 372s + # Check names attribute 372s + for (useNames in c(TRUE, FALSE)) { 372s + r0 <- rowCumprods_R(x, useNames = useNames) 372s + r1 <- rowCumprods(x, useNames = useNames) 372s + r2 <- t(rowCumprods(t(x), useNames = useNames)) 372s + stopifnot(all.equal(r1, r2)) 372s + stopifnot(all.equal(r1, r0)) 372s + stopifnot(all.equal(r2, r0)) 372s + } # for (useNames ...) 372s + } # for (setDimnames ...) 372s + 372s + # A Nx0 matrix 372s + x <- matrix(value, nrow = 5L, ncol = 0L) 372s + str(x) 372s + rownames <- LETTERS[1:5] 372s + # Test with and without dimnames on x 372s + for (setDimnames in c(TRUE, FALSE)) { 372s + if (setDimnames) rownames(x) <- rownames 372s + else dimnames(x) <- NULL 372s + # Check names attribute 372s + for (useNames in c(TRUE, FALSE)) { 372s + r0 <- rowCumprods_R(x, useNames = useNames) 372s + r1 <- rowCumprods(x, useNames = useNames) 372s + r2 <- t(rowCumprods(t(x), useNames = useNames)) 372s + stopifnot(all.equal(r1, r2)) 372s + stopifnot(all.equal(r1, r0)) 372s + stopifnot(all.equal(r2, r0)) 372s + } # for (useNames ...) 372s + } # for (setDimnames ...) 372s + } # for (mode ...) 372s mode: logical 372s logi[0 , 0 ] 372s logi[0 , 1:5] 372s logi[1:5, 0 ] 372s mode: integer 372s int[0 , 0 ] 372s int[0 , 1:5] 372s int[1:5, 0 ] 372s mode: double 372s num[0 , 0 ] 372s num[0 , 1:5] 372s num[1:5, 0 ] 373s > 373s 373s R version 4.4.3 (2025-02-28) -- "Trophy Case" 373s Copyright (C) 2025 The R Foundation for Statistical Computing 373s Platform: arm-unknown-linux-gnueabihf (32-bit) 373s 373s R is free software and comes with ABSOLUTELY NO WARRANTY. 373s You are welcome to redistribute it under certain conditions. 373s Type 'license()' or 'licence()' for distribution details. 373s 373s R is a collaborative project with many contributors. 373s Type 'contributors()' for more information and 373s 'citation()' on how to cite R or R packages in publications. 373s 373s Type 'demo()' for some demos, 'help()' for on-line help, or 373s 'help.start()' for an HTML browser interface to help. 373s Type 'q()' to quit R. 373s 373s > library("matrixStats") 373s > 373s > rowCumprods_R <- function(x, ..., useNames = TRUE) { 373s + suppressWarnings({ 373s + y <- t(apply(x, MARGIN = 1L, FUN = cumprod)) 373s + }) 373s + 373s + # Preserve dimnames attribute? 373s + dim(y) <- dim(x) 373s + dimnames(y) <- if (useNames) dimnames(x) else NULL 373s + 373s + y 373s + } 373s > 373s > 373s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 373s > # Subsetted tests 373s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 373s > source("utils/validateIndicesFramework.R") 373s > x <- matrix(runif(6 * 6, min = -3, max = 3), nrow = 6, ncol = 6) 373s > storage.mode(x) <- "integer" 373s > 373s > # To check dimnames attribute 373s > dimnames <- list(letters[1:6], LETTERS[1:6]) 373s > 373s > # Test with and without dimnames on x 373s > for (setDimnames in c(TRUE, FALSE)) { 373s + if (setDimnames) dimnames(x) <- dimnames 373s + else dimnames(x) <- NULL 373s + for (rows in index_cases) { 373s + for (cols in index_cases) { 373s + # Check names attribute 373s + for (useNames in c(TRUE, FALSE)) { 373s + validateIndicesTestMatrix(x, rows, cols, 373s + ftest = rowCumprods, fsure = rowCumprods_R, useNames = useNames) 373s + validateIndicesTestMatrix(x, rows, cols, 373s + ftest = function(x, rows, cols, ..., useNames) { 373s + t(colCumprods(t(x), rows = cols, cols = rows, useNames = useNames)) 373s + }, fsure = rowCumprods_R, useNames = useNames) 373s + } 373s + } 373s + } 373s + } 375s > 375s 375s R version 4.4.3 (2025-02-28) -- "Trophy Case" 375s Copyright (C) 2025 The R Foundation for Statistical Computing 375s Platform: arm-unknown-linux-gnueabihf (32-bit) 375s 375s R is free software and comes with ABSOLUTELY NO WARRANTY. 375s You are welcome to redistribute it under certain conditions. 375s Type 'license()' or 'licence()' for distribution details. 375s 375s R is a collaborative project with many contributors. 375s Type 'contributors()' for more information and 375s 'citation()' on how to cite R or R packages in publications. 375s 375s Type 'demo()' for some demos, 'help()' for on-line help, or 375s 'help.start()' for an HTML browser interface to help. 375s Type 'q()' to quit R. 375s 375s > library("matrixStats") 375s > 375s > rowCumsums_R <- function(x, ..., useNames = TRUE) { 375s + suppressWarnings({ 375s + y <- t(apply(x, MARGIN = 1L, FUN = cumsum)) 375s + }) 375s + 375s + # Preserve dimnames attribute? 375s + dim(y) <- dim(x) 375s + dimnames(y) <- if (useNames) dimnames(x) else NULL 375s + 375s + y 375s + } 375s > 375s > 375s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 375s > # With and without some NAs 375s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 375s > dimnames <- list(letters[1:10], LETTERS[1:5]) # to check dimnames attribute 375s > for (mode in c("logical", "integer", "double")) { 375s + for (add_na in c(FALSE, TRUE)) { 375s + cat("add_na = ", add_na, "\n", sep = "") 375s + 375s + x <- matrix(1:50, nrow = 10L, ncol = 5L) 375s + if (add_na) { 375s + x[3:7, c(2, 4)] <- NA_real_ 375s + } 375s + cat("mode: ", mode, "\n", sep = "") 375s + storage.mode(x) <- mode 375s + str(x) 375s + 375s + # Test with and without dimnames on x 375s + for (setDimnames in c(TRUE, FALSE)) { 375s + if (setDimnames) dimnames(x) <- dimnames 375s + else dimnames(x) <- NULL 375s + # Check names attribute 375s + for (useNames in c(TRUE, FALSE)) { 375s + # Row/column ranges 375s + r0 <- rowCumsums_R(x, useNames = useNames) 375s + r1 <- rowCumsums(x, useNames = useNames) 375s + r2 <- t(colCumsums(t(x), useNames = useNames)) 375s + stopifnot(all.equal(r1, r2)) 375s + stopifnot(all.equal(r1, r0)) 375s + stopifnot(all.equal(r2, r0)) 375s + } # for (useNames ...) 375s + } # for (setDimnames ...) 375s + } # for (add_na ...) 375s + } 375s add_na = FALSE 375s mode: logical 375s logi [1:10, 1:5] TRUE TRUE TRUE TRUE TRUE TRUE ... 375s add_na = TRUE 375s mode: logical 375s logi [1:10, 1:5] TRUE TRUE TRUE TRUE TRUE TRUE ... 375s add_na = FALSE 375s mode: integer 375s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 375s add_na = TRUE 375s mode: integer 375s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 375s add_na = FALSE 375s mode: double 375s num [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 375s add_na = TRUE 375s mode: double 375s num [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 375s > 375s > 375s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 375s > # All NAs 375s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 375s > for (mode in c("logical", "integer", "double")) { 375s + x <- matrix(NA_real_, nrow = 10L, ncol = 5L) 375s + cat("mode: ", mode, "\n", sep = "") 375s + storage.mode(x) <- mode 375s + str(x) 375s + 375s + # Test with and without dimnames on x 375s + for (setDimnames in c(TRUE, FALSE)) { 375s + if (setDimnames) dimnames(x) <- dimnames 375s + else dimnames(x) <- NULL 375s + # Check names attribute 375s + for (useNames in c(TRUE, FALSE)) { 375s + # Row/column ranges 375s + r0 <- rowCumsums_R(x, useNames = useNames) 375s + r1 <- rowCumsums(x, useNames = useNames) 375s + r2 <- t(colCumsums(t(x), useNames = useNames)) 375s + stopifnot(all.equal(r1, r2)) 375s + stopifnot(all.equal(r1, r0)) 375s + stopifnot(all.equal(r2, r0)) 375s + } # for (useNames ...) 375s + } # for (setDimnames ...) 375s + } # for (mode ...) 375s mode: logical 375s logi [1:10, 1:5] NA NA NA NA NA NA ... 375s mode: integer 375s int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 375s mode: double 375s num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 375s > 375s > 375s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 375s > # A 1x1 matrix 375s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 375s > dimnames <- list("a", "A") # to check dimnames attribute 375s > for (mode in c("logical", "integer", "double")) { 375s + x <- matrix(0, nrow = 1L, ncol = 1L) 375s + cat("mode: ", mode, "\n", sep = "") 375s + storage.mode(x) <- mode 375s + str(x) 375s + 375s + r0 <- rowCumsums_R(x) 375s + r1 <- rowCumsums(x) 375s + r2 <- t(colCumsums(t(x))) 375s + stopifnot(all.equal(r1, r2)) 375s + stopifnot(all.equal(r1, r0)) 375s + stopifnot(all.equal(r2, r0)) 375s + 375s + # Check dimnames attribute 375s + dimnames(x) <- dimnames 375s + # r0 <- rowCumsums_R(x) 375s + # > r0 375s + # a 375s + # [1,] 0 375s + r1 <- rowCumsums(x, useNames = TRUE) 375s + r2 <- t(colCumsums(t(x), useNames = TRUE)) 375s + stopifnot(identical(dimnames(r1), dimnames)) 375s + stopifnot(identical(dimnames(r2), dimnames)) 375s + dimnames(x) <- NULL 375s + } 375s mode: logical 375s logi [1, 1] FALSE 375s mode: integer 375s int [1, 1] 0 375s mode: double 375s num [1, 1] 0 375s > 375s > 375s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 375s > # Corner cases 375s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 375s > names <- LETTERS[1:5] # to check dimnames attribute 375s > for (mode in c("logical", "integer", "double")) { 375s + cat("mode: ", mode, "\n", sep = "") 375s + value <- 0 375s + storage.mode(value) <- mode 375s + value2 <- value 375s + if (mode == "logical") value2 <- 0L 375s + 375s + # A 0x0 matrix 375s + x <- matrix(value, nrow = 0L, ncol = 0L) 375s + str(x) 375s + r0 <- matrix(value2, nrow = nrow(x), ncol = ncol(x)) 375s + r1 <- rowCumsums(x) 375s + r2 <- t(colCumsums(t(x))) 375s + stopifnot(all.equal(r1, r2)) 375s + stopifnot(all.equal(r1, r0)) 375s + stopifnot(all.equal(r2, r0)) 375s + 375s + # A 0xK matrix 375s + x <- matrix(value, nrow = 0L, ncol = 5L) 375s + str(x) 375s + colnames <- LETTERS[1:5] 375s + # Test with and without dimnames on x 375s + for (setDimnames in c(TRUE, FALSE)) { 375s + if (setDimnames) colnames(x) <- colnames 375s + else dimnames(x) <- NULL 375s + # Check names attribute 375s + for (useNames in c(TRUE, FALSE)) { 375s + r0 <- rowCumsums_R(x, useNames = useNames) 375s + r1 <- rowCumsums(x, useNames = useNames) 375s + r2 <- t(rowCumsums(t(x), useNames = useNames)) 375s + stopifnot(all.equal(r1, r2)) 375s + stopifnot(all.equal(r1, r0)) 375s + stopifnot(all.equal(r2, r0)) 375s + } # for (useNames ...) 375s + } # for (setDimnames ...) 375s + 375s + # A Nx0 matrix 375s + x <- matrix(value, nrow = 5L, ncol = 0L) 375s + str(x) 375s + rownames <- LETTERS[1:5] 375s + # Test with and without dimnames on x 375s + for (setDimnames in c(TRUE, FALSE)) { 375s + if (setDimnames) rownames(x) <- rownames 375s + else dimnames(x) <- NULL 375s + # Check names attribute 375s + for (useNames in c(TRUE, FALSE)) { 375s + r0 <- rowCumsums_R(x, useNames = useNames) 375s + r1 <- rowCumsums(x, useNames = useNames) 375s + r2 <- t(rowCumsums(t(x), useNames = useNames)) 375s + stopifnot(all.equal(r1, r2)) 375s + stopifnot(all.equal(r1, r0)) 375s + stopifnot(all.equal(r2, r0)) 375s + } # for (useNames ...) 375s + } # for (setDimnames ...) 375s + } # for (mode ...) 375s mode: logical 375s logi[0 , 0 ] 375s logi[0 , 1:5] 375s logi[1:5, 0 ] 375s mode: integer 375s int[0 , 0 ] 375s int[0 , 1:5] 375s int[1:5, 0 ] 375s mode: double 375s num[0 , 0 ] 375s num[0 , 1:5] 375s num[1:5, 0 ] 375s > 375s 375s R version 4.4.3 (2025-02-28) -- "Trophy Case" 375s Copyright (C) 2025 The R Foundation for Statistical Computing 375s Platform: arm-unknown-linux-gnueabihf (32-bit) 375s 375s R is free software and comes with ABSOLUTELY NO WARRANTY. 375s You are welcome to redistribute it under certain conditions. 375s Type 'license()' or 'licence()' for distribution details. 375s 375s R is a collaborative project with many contributors. 375s Type 'contributors()' for more information and 375s 'citation()' on how to cite R or R packages in publications. 375s 375s Type 'demo()' for some demos, 'help()' for on-line help, or 375s 'help.start()' for an HTML browser interface to help. 375s Type 'q()' to quit R. 375s 375s > library("matrixStats") 375s > 375s > rowCumsums_R <- function(x, ..., useNames = TRUE) { 375s + suppressWarnings({ 375s + y <- t(apply(x, MARGIN = 1L, FUN = cumsum)) 375s + }) 375s + 375s + # Preserve dimnames attribute? 375s + dim(y) <- dim(x) 375s + dimnames(y) <- if (useNames) dimnames(x) else NULL 375s + 375s + y 375s + } 375s > 375s > 375s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 375s > # Subsetted tests 375s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 375s > source("utils/validateIndicesFramework.R") 375s > x <- matrix(runif(6 * 6, min = -3, max = 3), nrow = 6, ncol = 6) 375s > storage.mode(x) <- "integer" 375s > 375s > # To check dimnames attribute 375s > dimnames <- list(letters[1:6], LETTERS[1:6]) 375s > 375s > # Test with and without dimnames on x 375s > for (setDimnames in c(TRUE, FALSE)) { 375s + if (setDimnames) dimnames(x) <- dimnames 375s + else dimnames(x) <- NULL 375s + for (rows in index_cases) { 375s + for (cols in index_cases) { 375s + # Check names attribute 375s + for (useNames in c(TRUE, FALSE)) { 375s + validateIndicesTestMatrix(x, rows, cols, 375s + ftest = rowCumsums, fsure = rowCumsums_R, useNames = useNames) 375s + validateIndicesTestMatrix(x, rows, cols, 375s + ftest = function(x, rows, cols, ..., useNames) { 375s + t(colCumsums(t(x), rows = cols, cols = rows, useNames = useNames)) 375s + }, fsure = rowCumsums_R, useNames = useNames) 375s + } 375s + } 375s + } 375s + } 377s > 377s 377s R version 4.4.3 (2025-02-28) -- "Trophy Case" 377s Copyright (C) 2025 The R Foundation for Statistical Computing 377s Platform: arm-unknown-linux-gnueabihf (32-bit) 377s 377s R is free software and comes with ABSOLUTELY NO WARRANTY. 377s You are welcome to redistribute it under certain conditions. 377s Type 'license()' or 'licence()' for distribution details. 377s 377s R is a collaborative project with many contributors. 377s Type 'contributors()' for more information and 377s 'citation()' on how to cite R or R packages in publications. 377s 377s Type 'demo()' for some demos, 'help()' for on-line help, or 377s 'help.start()' for an HTML browser interface to help. 377s Type 'q()' to quit R. 377s 377s > library("matrixStats") 377s > 377s > rowDiffs_R <- function(x, lag = 1L, differences = 1L, ..., useNames = TRUE) { 377s + ncol2 <- ncol(x) - lag * differences 377s + if (ncol2 <= 0) { 377s + y <- matrix(x[integer(0L)], nrow = nrow(x), ncol = 0L) 377s + # Preserve names attribute 377s + if (useNames && !is.null(rownames(x))) rownames(y) <- rownames(x) 377s + return(y) 377s + } 377s + suppressWarnings({ 377s + y <- apply(x, MARGIN = 1L, FUN = diff, lag = lag, differences = differences) 377s + }) 377s + y <- t(y) 377s + 377s + # Preserve dimnames attribute 377s + dim(y) <- c(nrow(x), ncol2) 377s + if (useNames && !is.null(dimnames(x))) { 377s + colnames <- colnames(x) 377s + if (!is.null(colnames)) { 377s + len <- length(colnames) 377s + colnames <- colnames[(len - ncol2 + 1):len] 377s + } 377s + dimnames(y) <- list(rownames(x), colnames) 377s + } 377s + else dimnames(y) <- NULL 377s + 377s + y 377s + } 377s > 377s > 377s > set.seed(0x42) 377s > 377s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 377s > # With and without some NAs 377s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 377s > for (mode in c("integer", "double")) { 377s + cat("mode: ", mode, "\n", sep = "") 377s + 377s + for (add_na in c(FALSE, TRUE)) { 377s + cat("add_na = ", add_na, "\n", sep = "") 377s + 377s + x <- matrix(sample(10 * 8) + 0.1, nrow = 10L, ncol = 8L) 377s + if (add_na) { 377s + x[3:7, c(2, 4)] <- NA_real_ 377s + } 377s + storage.mode(x) <- mode 377s + str(x) 377s + 377s + dimnames <- list(letters[1:10], LETTERS[1:8]) 377s + 377s + # Test with and without dimnames on x 377s + for (setDimnames in c(TRUE, FALSE)) { 377s + if (setDimnames) dimnames(x) <- dimnames 377s + else dimnames(x) <- NULL 377s + # Check dimnames attribute 377s + for (useNames in c(TRUE, FALSE)) { 377s + for (lag in 1:4) { 377s + for (differences in 1:3) { 377s + cat(sprintf("mode: %s, lag = %d, differences = %d\n", 377s + mode, lag, differences)) 377s + # Row/column ranges 377s + r0 <- rowDiffs_R(x, lag = lag, differences = differences, useNames = useNames) 377s + r1 <- rowDiffs(x, lag = lag, differences = differences, useNames = useNames) 377s + r2 <- t(colDiffs(t(x), lag = lag, differences = differences, useNames = useNames)) 377s + stopifnot(all.equal(r1, r0)) 377s + stopifnot(all.equal(r2, r0)) 377s + stopifnot(all.equal(r1, r2)) 377s + } 377s + } 377s + } # for (useNames ...) 377s + } # for (setDimnames ...) 377s + } # for (add_na ...) 377s + } # for (mode ...) 377s mode: integer 377s add_na = FALSE 377s int [1:10, 1:8] 68 26 29 47 48 10 1 38 16 40 ... 377s mode: integer, lag = 1, differences = 1 377s mode: integer, lag = 1, differences = 2 377s mode: integer, lag = 1, differences = 3 377s mode: integer, lag = 2, differences = 1 377s mode: integer, lag = 2, differences = 2 377s mode: integer, lag = 2, differences = 3 377s mode: integer, lag = 3, differences = 1 377s mode: integer, lag = 3, differences = 2 377s mode: integer, lag = 3, differences = 3 377s mode: integer, lag = 4, differences = 1 377s mode: integer, lag = 4, differences = 2 377s mode: integer, lag = 4, differences = 3 377s mode: integer, lag = 1, differences = 1 377s mode: integer, lag = 1, differences = 2 377s mode: integer, lag = 1, differences = 3 377s mode: integer, lag = 2, differences = 1 377s mode: integer, lag = 2, differences = 2 377s mode: integer, lag = 2, differences = 3 377s mode: integer, lag = 3, differences = 1 377s mode: integer, lag = 3, differences = 2 377s mode: integer, lag = 3, differences = 3 377s mode: integer, lag = 4, differences = 1 377s mode: integer, lag = 4, differences = 2 377s mode: integer, lag = 4, differences = 3 377s mode: integer, lag = 1, differences = 1 377s mode: integer, lag = 1, differences = 2 377s mode: integer, lag = 1, differences = 3 377s mode: integer, lag = 2, differences = 1 377s mode: integer, lag = 2, differences = 2 377s mode: integer, lag = 2, differences = 3 377s mode: integer, lag = 3, differences = 1 377s mode: integer, lag = 3, differences = 2 377s mode: integer, lag = 3, differences = 3 377s mode: integer, lag = 4, differences = 1 377s mode: integer, lag = 4, differences = 2 377s mode: integer, lag = 4, differences = 3 377s mode: integer, lag = 1, differences = 1 377s mode: integer, lag = 1, differences = 2 377s mode: integer, lag = 1, differences = 3 377s mode: integer, lag = 2, differences = 1 377s mode: integer, lag = 2, differences = 2 377s mode: integer, lag = 2, differences = 3 377s mode: integer, lag = 3, differences = 1 377s mode: integer, lag = 3, differences = 2 377s mode: integer, lag = 3, differences = 3 377s mode: integer, lag = 4, differences = 1 377s mode: integer, lag = 4, differences = 2 377s mode: integer, lag = 4, differences = 3 377s add_na = TRUE 377s int [1:10, 1:8] 80 71 7 52 79 22 31 10 29 63 ... 377s mode: integer, lag = 1, differences = 1 377s mode: integer, lag = 1, differences = 2 377s mode: integer, lag = 1, differences = 3 377s mode: integer, lag = 2, differences = 1 377s mode: integer, lag = 2, differences = 2 377s mode: integer, lag = 2, differences = 3 377s mode: integer, lag = 3, differences = 1 377s mode: integer, lag = 3, differences = 2 377s mode: integer, lag = 3, differences = 3 377s mode: integer, lag = 4, differences = 1 377s mode: integer, lag = 4, differences = 2 377s mode: integer, lag = 4, differences = 3 377s mode: integer, lag = 1, differences = 1 377s mode: integer, lag = 1, differences = 2 377s mode: integer, lag = 1, differences = 3 377s mode: integer, lag = 2, differences = 1 377s mode: integer, lag = 2, differences = 2 377s mode: integer, lag = 2, differences = 3 377s mode: integer, lag = 3, differences = 1 377s mode: integer, lag = 3, differences = 2 377s mode: integer, lag = 3, differences = 3 377s mode: integer, lag = 4, differences = 1 377s mode: integer, lag = 4, differences = 2 377s mode: integer, lag = 4, differences = 3 377s mode: integer, lag = 1, differences = 1 377s mode: integer, lag = 1, differences = 2 377s mode: integer, lag = 1, differences = 3 377s mode: integer, lag = 2, differences = 1 377s mode: integer, lag = 2, differences = 2 377s mode: integer, lag = 2, differences = 3 377s mode: integer, lag = 3, differences = 1 377s mode: integer, lag = 3, differences = 2 377s mode: integer, lag = 3, differences = 3 377s mode: integer, lag = 4, differences = 1 377s mode: integer, lag = 4, differences = 2 377s mode: integer, lag = 4, differences = 3 377s mode: integer, lag = 1, differences = 1 377s mode: integer, lag = 1, differences = 2 377s mode: integer, lag = 1, differences = 3 377s mode: integer, lag = 2, differences = 1 377s mode: integer, lag = 2, differences = 2 377s mode: integer, lag = 2, differences = 3 377s mode: integer, lag = 3, differences = 1 377s mode: integer, lag = 3, differences = 2 377s mode: integer, lag = 3, differences = 3 377s mode: integer, lag = 4, differences = 1 377s mode: integer, lag = 4, differences = 2 377s mode: integer, lag = 4, differences = 3 377s mode: double 377s add_na = FALSE 377s 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 ... 377s mode: double, lag = 1, differences = 1 377s mode: double, lag = 1, differences = 2 377s mode: double, lag = 1, differences = 3 377s mode: double, lag = 2, differences = 1 377s mode: double, lag = 2, differences = 2 377s mode: double, lag = 2, differences = 3 377s mode: double, lag = 3, differences = 1 377s mode: double, lag = 3, differences = 2 377s mode: double, lag = 3, differences = 3 377s mode: double, lag = 4, differences = 1 377s mode: double, lag = 4, differences = 2 377s mode: double, lag = 4, differences = 3 377s mode: double, lag = 1, differences = 1 377s mode: double, lag = 1, differences = 2 377s mode: double, lag = 1, differences = 3 377s mode: double, lag = 2, differences = 1 377s mode: double, lag = 2, differences = 2 377s mode: double, lag = 2, differences = 3 377s mode: double, lag = 3, differences = 1 377s mode: double, lag = 3, differences = 2 377s mode: double, lag = 3, differences = 3 377s mode: double, lag = 4, differences = 1 377s mode: double, lag = 4, differences = 2 377s mode: double, lag = 4, differences = 3 377s mode: double, lag = 1, differences = 1 377s mode: double, lag = 1, differences = 2 377s mode: double, lag = 1, differences = 3 377s mode: double, lag = 2, differences = 1 377s mode: double, lag = 2, differences = 2 377s mode: double, lag = 2, differences = 3 377s mode: double, lag = 3, differences = 1 377s mode: double, lag = 3, differences = 2 377s mode: double, lag = 3, differences = 3 377s mode: double, lag = 4, differences = 1 377s mode: double, lag = 4, differences = 2 377s mode: double, lag = 4, differences = 3 377s mode: double, lag = 1, differences = 1 377s mode: double, lag = 1, differences = 2 377s mode: double, lag = 1, differences = 3 377s mode: double, lag = 2, differences = 1 377s mode: double, lag = 2, differences = 2 377s mode: double, lag = 2, differences = 3 377s mode: double, lag = 3, differences = 1 377s mode: double, lag = 3, differences = 2 377s mode: double, lag = 3, differences = 3 377s mode: double, lag = 4, differences = 1 377s mode: double, lag = 4, differences = 2 377s mode: double, lag = 4, differences = 3 377s add_na = TRUE 377s 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 ... 377s mode: double, lag = 1, differences = 1 377s mode: double, lag = 1, differences = 2 377s mode: double, lag = 1, differences = 3 377s mode: double, lag = 2, differences = 1 377s mode: double, lag = 2, differences = 2 377s mode: double, lag = 2, differences = 3 377s mode: double, lag = 3, differences = 1 377s mode: double, lag = 3, differences = 2 377s mode: double, lag = 3, differences = 3 377s mode: double, lag = 4, differences = 1 377s mode: double, lag = 4, differences = 2 377s mode: double, lag = 4, differences = 3 377s mode: double, lag = 1, differences = 1 377s mode: double, lag = 1, differences = 2 377s mode: double, lag = 1, differences = 3 377s mode: double, lag = 2, differences = 1 377s mode: double, lag = 2, differences = 2 377s mode: double, lag = 2, differences = 3 377s mode: double, lag = 3, differences = 1 377s mode: double, lag = 3, differences = 2 377s mode: double, lag = 3, differences = 3 377s mode: double, lag = 4, differences = 1 377s mode: double, lag = 4, differences = 2 377s mode: double, lag = 4, differences = 3 377s mode: double, lag = 1, differences = 1 377s mode: double, lag = 1, differences = 2 377s mode: double, lag = 1, differences = 3 377s mode: double, lag = 2, differences = 1 377s mode: double, lag = 2, differences = 2 377s mode: double, lag = 2, differences = 3 377s mode: double, lag = 3, differences = 1 377s mode: double, lag = 3, differences = 2 377s mode: double, lag = 3, differences = 3 377s mode: double, lag = 4, differences = 1 377s mode: double, lag = 4, differences = 2 377s mode: double, lag = 4, differences = 3 377s mode: double, lag = 1, differences = 1 377s mode: double, lag = 1, differences = 2 377s mode: double, lag = 1, differences = 3 377s mode: double, lag = 2, differences = 1 377s mode: double, lag = 2, differences = 2 377s mode: double, lag = 2, differences = 3 377s mode: double, lag = 3, differences = 1 377s mode: double, lag = 3, differences = 2 377s mode: double, lag = 3, differences = 3 377s mode: double, lag = 4, differences = 1 377s mode: double, lag = 4, differences = 2 377s mode: double, lag = 4, differences = 3 377s > 377s > 377s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 377s > # All NAs 377s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 377s > for (mode in c("integer", "double")) { 377s + cat("mode: ", mode, "\n", sep = "") 377s + x <- matrix(NA_real_, nrow = 10L, ncol = 5L) 377s + storage.mode(x) <- mode 377s + str(x) 377s + 377s + dimnames <- list(letters[1:10], LETTERS[1:5]) 377s + 377s + # Test with and without dimnames on x 377s + for (setDimnames in c(TRUE, FALSE)) { 377s + if (setDimnames) dimnames(x) <- dimnames 377s + else dimnames(x) <- NULL 377s + # Check dimnames attribute 377s + for (useNames in c(TRUE, FALSE)) { 377s + r0 <- rowDiffs_R(x, useNames = useNames) 377s + r1 <- rowDiffs(x, useNames = useNames) 377s + r2 <- t(colDiffs(t(x), useNames = useNames)) 377s + stopifnot(all.equal(r1, r0)) 377s + stopifnot(all.equal(r2, r0)) 377s + stopifnot(all.equal(r1, r2)) 377s + } # for (useNames ...) 377s + } # for (setDimnames ...) 377s + } # for (mode ...) 377s mode: integer 377s int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 377s mode: double 377s num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 377s > 377s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 377s > # A 1x1 matrix 377s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 377s > x <- matrix(0, nrow = 1L, ncol = 1L) 377s > dimnames <- list("a", "A") 377s > # Test with and without dimnames on x 377s > for (setDimnames in c(TRUE, FALSE)) { 377s + if (setDimnames) dimnames(x) <- dimnames 377s + else dimnames(x) <- NULL 377s + # Check dimnames attribute 377s + for (useNames in c(TRUE, FALSE)) { 377s + r0 <- rowDiffs_R(x, useNames = useNames) 377s + r1 <- rowDiffs(x, useNames = useNames) 377s + r2 <- t(colDiffs(t(x), useNames = useNames)) 377s + stopifnot(all.equal(r1, r0)) 377s + stopifnot(all.equal(r2, r0)) 377s + stopifnot(all.equal(r1, r2)) 377s + } # for (useNames ...) 377s + } # for (setDimnames ...) 377s > 378s 378s R version 4.4.3 (2025-02-28) -- "Trophy Case" 378s Copyright (C) 2025 The R Foundation for Statistical Computing 378s Platform: arm-unknown-linux-gnueabihf (32-bit) 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 > rowDiffs_R <- function(x, lag = 1L, differences = 1L, ..., useNames = TRUE) { 378s + ncol2 <- ncol(x) - lag * differences 378s + if (ncol2 <= 0) { 378s + y <- matrix(x[integer(0L)], nrow = nrow(x), ncol = 0L) 378s + # Preserve names attribute 378s + if (useNames && !is.null(rownames(x))) rownames(y) <- rownames(x) 378s + return(y) 378s + } 378s + suppressWarnings({ 378s + y <- apply(x, MARGIN = 1L, FUN = diff, lag = lag, differences = differences) 378s + }) 378s + y <- t(y) 378s + 378s + # Preserve dimnames attribute 378s + dim(y) <- c(nrow(x), ncol2) 378s + if (useNames && !is.null(dimnames(x))) { 378s + colnames <- colnames(x) 378s + if (!is.null(colnames)) { 378s + len <- length(colnames) 378s + colnames <- colnames[(len - ncol2 + 1):len] 378s + } 378s + dimnames(y) <- list(rownames(x), colnames) 378s + } 378s + else dimnames(y) <- NULL 378s + 378s + y 378s + } 378s > 378s > 378s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 378s > # Subsetted tests 378s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 378s > source("utils/validateIndicesFramework.R") 378s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 378s > storage.mode(x) <- "integer" 378s > 378s > # To check dimnames attribute 378s > dimnames <- list(letters[1:6], LETTERS[1:6]) 378s > 378s > # Test with and without dimnames on x 378s > for (setDimnames in c(TRUE, FALSE)) { 378s + if (setDimnames) dimnames(x) <- dimnames 378s + else dimnames(x) <- NULL 378s + 378s + count <- 0L 378s + for (rows in index_cases) { 378s + for (cols in index_cases) { 378s + count <- count + 1L 378s + for (lag in 1:2) { 378s + for (differences in 1:3) { 378s + # Check dimnames attribute 378s + useNames <- c(TRUE, FALSE) 378s + useNames <- useNames[count %% length(useNames) + 1] 378s + validateIndicesTestMatrix(x, rows, cols, 378s + ftest = rowDiffs, fsure = rowDiffs_R, 378s + lag = lag, differences = differences, useNames = useNames) 378s + validateIndicesTestMatrix(x, rows, cols, 378s + ftest = function(x, rows, cols, ..., useNames) { 378s + t(colDiffs(t(x), rows = cols, cols = rows, ..., useNames = useNames)) 378s + }, fsure = rowDiffs_R, 378s + lag = lag, differences = differences, useNames = useNames) 378s + } 378s + } 378s + } 378s + } 378s + } 381s > 381s 381s R version 4.4.3 (2025-02-28) -- "Trophy Case" 381s Copyright (C) 2025 The R Foundation for Statistical Computing 381s Platform: arm-unknown-linux-gnueabihf (32-bit) 381s 381s R is free software and comes with ABSOLUTELY NO WARRANTY. 381s You are welcome to redistribute it under certain conditions. 381s Type 'license()' or 'licence()' for distribution details. 381s 381s R is a collaborative project with many contributors. 381s Type 'contributors()' for more information and 381s 'citation()' on how to cite R or R packages in publications. 381s 381s Type 'demo()' for some demos, 'help()' for on-line help, or 381s 'help.start()' for an HTML browser interface to help. 381s Type 'q()' to quit R. 381s 381s > library("matrixStats") 382s > 382s > rowIQRs_R <- function(x, na.rm = FALSE, ..., useNames = TRUE) { 382s + quantile_na <- function(x, ..., na.rm = FALSE) { 382s + if (!na.rm && anyMissing(x)) 382s + return(c(NA_real_, NA_real_)) 382s + quantile(x, ..., na.rm = na.rm) 382s + } 382s + q <- apply(x, MARGIN = 1L, FUN = quantile_na, 382s + probs = c(0.25, 0.75), na.rm = na.rm) 382s + rownames(q) <- NULL # Not needed anymore 382s + 382s + # Preserve names attribute 382s + dim(q) <- c(2L, nrow(x)) 382s + colnames(q) <- if (useNames) rownames(x) else NULL 382s + 382s + q[2L, , drop = TRUE] - q[1L, , drop = TRUE] 382s + } 382s > 382s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 382s > # Test with multiple quantiles 382s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 382s > for (mode in c("integer", "double")) { 382s + cat("mode: ", mode, "\n", sep = "") 382s + x <- matrix(1:100 + 0.1, nrow = 10, ncol = 10) 382s + storage.mode(x) <- mode 382s + str(x) 382s + 382s + # To check names attribute 382s + dimnames <- list(letters[1:10], LETTERS[1:10]) 382s + 382s + for (add_na in c(FALSE, TRUE)) { 382s + if (add_na) { 382s + x[3:5, 6:9] <- NA 382s + } 382s + # Test with and without dimnames on x 382s + for (setDimnames in c(TRUE, FALSE)) { 382s + if (setDimnames) dimnames(x) <- dimnames 382s + else dimnames(x) <- NULL 382s + for (na.rm in c(FALSE, TRUE)) { 382s + # Check names attribute 382s + for (useNames in c(TRUE, FALSE)) { 382s + probs <- c(0, 0.5, 1) 382s + q0 <- rowIQRs_R(x, na.rm = na.rm, useNames = useNames) 382s + print(q0) 382s + q1 <- rowIQRs(x, na.rm = na.rm, useNames = useNames) 382s + print(q1) 382s + stopifnot(all.equal(q1, q0)) 382s + q2 <- colIQRs(t(x), na.rm = na.rm, useNames = useNames) 382s + stopifnot(all.equal(q2, q0)) 382s + 382s + q <- iqr(x[3, ], na.rm = na.rm) 382s + print(q) 382s + } # for (useNames ...) 382s + } # for (na.rm ...) 382s + } # for (setDimnames ...) 382s + } # for (add_na ...) 382s + } # for (mode ...) 382s mode: integer 382s int [1:10, 1:10] 1 2 3 4 5 6 7 8 9 10 ... 382s a b c d e f g h i j 382s 45 45 45 45 45 45 45 45 45 45 382s a b c d e f g h i j 382s 45 45 45 45 45 45 45 45 45 45 382s [1] 45 382s [1] 45 45 45 45 45 45 45 45 45 45 382s [1] 45 45 45 45 45 45 45 45 45 45 382s [1] 45 382s a b c d e f g h i j 382s 45 45 45 45 45 45 45 45 45 45 382s a b c d e f g h i j 382s 45 45 45 45 45 45 45 45 45 45 382s [1] 45 382s [1] 45 45 45 45 45 45 45 45 45 45 382s [1] 45 45 45 45 45 45 45 45 45 45 382s [1] 45 382s [1] 45 45 45 45 45 45 45 45 45 45 382s [1] 45 45 45 45 45 45 45 45 45 45 382s [1] 45 382s [1] 45 45 45 45 45 45 45 45 45 45 382s [1] 45 45 45 45 45 45 45 45 45 45 382s [1] 45 382s [1] 45 45 45 45 45 45 45 45 45 45 382s [1] 45 45 45 45 45 45 45 45 45 45 382s [1] 45 382s [1] 45 45 45 45 45 45 45 45 45 45 382s [1] 45 45 45 45 45 45 45 45 45 45 382s [1] 45 382s a b c d e f g h i j 382s 45 45 NA NA NA 45 45 45 45 45 382s a b c d e f g h i j 382s 45 45 NA NA NA 45 45 45 45 45 382s [1] NA 382s [1] 45 45 NA NA NA 45 45 45 45 45 382s [1] 45 45 NA NA NA 45 45 45 45 45 382s [1] NA 382s a b c d e f g h i j 382s 45 45 25 25 25 45 45 45 45 45 382s a b c d e f g h i j 382s 45 45 25 25 25 45 45 45 45 45 382s [1] 25 382s [1] 45 45 25 25 25 45 45 45 45 45 382s [1] 45 45 25 25 25 45 45 45 45 45 382s [1] 25 382s [1] 45 45 NA NA NA 45 45 45 45 45 382s [1] 45 45 NA NA NA 45 45 45 45 45 382s [1] NA 382s [1] 45 45 NA NA NA 45 45 45 45 45 382s [1] 45 45 NA NA NA 45 45 45 45 45 382s [1] NA 382s [1] 45 45 25 25 25 45 45 45 45 45 382s [1] 45 45 25 25 25 45 45 45 45 45 382s [1] 25 382s [1] 45 45 25 25 25 45 45 45 45 45 382s [1] 45 45 25 25 25 45 45 45 45 45 382s [1] 25 382s mode: double 382s 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 ... 382s a b c d e f g h i j 382s 45 45 45 45 45 45 45 45 45 45 382s a b c d e f g h i j 382s 45 45 45 45 45 45 45 45 45 45 382s [1] 45 382s [1] 45 45 45 45 45 45 45 45 45 45 382s [1] 45 45 45 45 45 45 45 45 45 45 382s [1] 45 382s a b c d e f g h i j 382s 45 45 45 45 45 45 45 45 45 45 382s a b c d e f g h i j 382s 45 45 45 45 45 45 45 45 45 45 382s [1] 45 382s [1] 45 45 45 45 45 45 45 45 45 45 382s [1] 45 45 45 45 45 45 45 45 45 45 382s [1] 45 382s [1] 45 45 45 45 45 45 45 45 45 45 382s [1] 45 45 45 45 45 45 45 45 45 45 382s [1] 45 382s [1] 45 45 45 45 45 45 45 45 45 45 382s [1] 45 45 45 45 45 45 45 45 45 45 382s [1] 45 382s [1] 45 45 45 45 45 45 45 45 45 45 382s [1] 45 45 45 45 45 45 45 45 45 45 382s [1] 45 382s [1] 45 45 45 45 45 45 45 45 45 45 382s [1] 45 45 45 45 45 45 45 45 45 45 382s [1] 45 382s a b c d e f g h i j 382s 45 45 NA NA NA 45 45 45 45 45 382s a b c d e f g h i j 382s 45 45 NA NA NA 45 45 45 45 45 382s [1] NA 382s [1] 45 45 NA NA NA 45 45 45 45 45 382s [1] 45 45 NA NA NA 45 45 45 45 45 382s [1] NA 382s a b c d e f g h i j 382s 45 45 25 25 25 45 45 45 45 45 382s a b c d e f g h i j 382s 45 45 25 25 25 45 45 45 45 45 382s [1] 25 382s [1] 45 45 25 25 25 45 45 45 45 45 382s [1] 45 45 25 25 25 45 45 45 45 45 382s [1] 25 382s [1] 45 45 NA NA NA 45 45 45 45 45 382s [1] 45 45 NA NA NA 45 45 45 45 45 382s [1] NA 382s [1] 45 45 NA NA NA 45 45 45 45 45 382s [1] 45 45 NA NA NA 45 45 45 45 45 382s [1] NA 382s [1] 45 45 25 25 25 45 45 45 45 45 382s [1] 45 45 25 25 25 45 45 45 45 45 382s [1] 25 382s [1] 45 45 25 25 25 45 45 45 45 45 382s [1] 45 45 25 25 25 45 45 45 45 45 382s [1] 25 382s > 382s > 382s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 382s > # Test corner cases 382s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 382s > for (mode in c("integer", "double")) { 382s + cat("mode: ", mode, "\n", sep = "") 382s + # Empty vectors 382s + x <- integer(0L) 382s + storage.mode(x) <- mode 382s + str(x) 382s + q <- iqr(x) 382s + print(q) 382s + stopifnot(identical(q, NA_real_)) 382s + 382s + # Scalar 382s + x <- 1L 382s + storage.mode(x) <- mode 382s + str(x) 382s + q <- iqr(x) 382s + str(q) 382s + stopifnot(identical(q, 0)) 382s + } 382s mode: integer 382s int(0) 382s [1] NA 382s int 1 382s num 0 382s mode: double 382s num(0) 382s [1] NA 382s num 1 382s num 0 382s > 382s > 382s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 382s > # Single row matrices 382s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 382s > x <- matrix(1, nrow = 1L, ncol = 2L) 382s > dimnames <- list("a", LETTERS[1:2]) 382s > # Test with and without dimnames on x 382s > for (setDimnames in c(TRUE, FALSE)) { 382s + if (setDimnames) dimnames(x) <- dimnames 382s + else dimnames(x) <- NULL 382s + # Check names attribute 382s + for (useNames in c(TRUE, FALSE)) { 382s + q0 <- rowIQRs_R(x, useNames = useNames) 382s + q1 <- rowIQRs(x, useNames = useNames) 382s + q2 <- colIQRs(t(x), useNames = useNames) 382s + stopifnot(all.equal(q0, q1)) 382s + stopifnot(all.equal(q0, q2)) 382s + } 382s + } 382s > 382s > x <- matrix(1, nrow = 2L, ncol = 1L) 382s > q <- colIQRs(x) 382s > stopifnot(identical(q, 0)) 382s > 382s 382s R version 4.4.3 (2025-02-28) -- "Trophy Case" 382s Copyright (C) 2025 The R Foundation for Statistical Computing 382s Platform: arm-unknown-linux-gnueabihf (32-bit) 382s 382s R is free software and comes with ABSOLUTELY NO WARRANTY. 382s You are welcome to redistribute it under certain conditions. 382s Type 'license()' or 'licence()' for distribution details. 382s 382s R is a collaborative project with many contributors. 382s Type 'contributors()' for more information and 382s 'citation()' on how to cite R or R packages in publications. 382s 382s Type 'demo()' for some demos, 'help()' for on-line help, or 382s 'help.start()' for an HTML browser interface to help. 382s Type 'q()' to quit R. 382s 382s > library("matrixStats") 382s > 382s > rowIQRs_R <- function(x, na.rm = FALSE, ..., useNames = TRUE) { 382s + quantile_na <- function(x, ..., na.rm = FALSE) { 382s + if (!na.rm && anyMissing(x)) 382s + return(c(NA_real_, NA_real_)) 382s + quantile(x, ..., na.rm = na.rm) 382s + } 382s + q <- apply(x, MARGIN = 1L, FUN = quantile_na, 382s + probs = c(0.25, 0.75), na.rm = na.rm) 382s + rownames(q) <- NULL # Not needed anymore 382s + 382s + # Preserve names attribute 382s + dim(q) <- c(2L, nrow(x)) 382s + colnames(q) <- if (useNames) rownames(x) else NULL 382s + 382s + q[2L, , drop = TRUE] - q[1L, , drop = TRUE] 382s + } 382s > 382s > 382s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 382s > # Subsetted tests 382s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 382s > source("utils/validateIndicesFramework.R") 382s > x <- runif(6, min = -6, max = 6) 382s > for (idxs in index_cases) { 382s + for (na.rm in c(TRUE, FALSE)) { 382s + validateIndicesTestVector(x, idxs, ftest = iqr, fsure = function(x, na.rm) { 382s + dim(x) <- c(1L, length(x)) 382s + rowIQRs_R(x, na.rm = na.rm) 382s + }, na.rm = na.rm) 382s + } 382s + } 382s > 382s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 382s > 382s > # To check names attribute 382s > dimnames <- list(letters[1:6], LETTERS[1:6]) 382s > 382s > # Test with and without dimnames on x 382s > for (setDimnames in c(TRUE, FALSE)) { 382s + if (setDimnames) dimnames(x) <- dimnames 382s + else dimnames(x) <- NULL 382s + 382s + count <- 0L 382s + for (rows in index_cases) { 382s + for (cols in index_cases) { 382s + count <- count + 1L 382s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 382s + useNames <- c(TRUE, FALSE) 382s + useNames <- useNames[count %% length(useNames) + 1] 382s + 382s + validateIndicesTestMatrix(x, rows, cols, 382s + ftest = rowIQRs, fsure = rowIQRs_R, 382s + na.rm = na.rm, useNames = useNames) 382s + validateIndicesTestMatrix(x, rows, cols, 382s + fcoltest = colIQRs, fsure = rowIQRs_R, 382s + na.rm = na.rm, useNames = useNames) 382s + } 382s + } 382s + } 384s > 384s 384s R version 4.4.3 (2025-02-28) -- "Trophy Case" 384s Copyright (C) 2025 The R Foundation for Statistical Computing 384s Platform: arm-unknown-linux-gnueabihf (32-bit) 384s 384s R is free software and comes with ABSOLUTELY NO WARRANTY. 384s You are welcome to redistribute it under certain conditions. 384s Type 'license()' or 'licence()' for distribution details. 384s 384s R is a collaborative project with many contributors. 384s Type 'contributors()' for more information and 384s 'citation()' on how to cite R or R packages in publications. 384s 384s Type 'demo()' for some demos, 'help()' for on-line help, or 384s 'help.start()' for an HTML browser interface to help. 384s Type 'q()' to quit R. 384s 384s > # Test inspired by the harmonic mean example in R-help 384s > # thread '[R] Beyond double-precision?' on May 9, 2009. 384s > 384s > library("matrixStats") 384s > library("stats") 384s > 384s > logSumExp0 <- function(lx) { 384s + idx_max <- which.max(lx) 384s + log1p(sum(exp(lx[-idx_max] - lx[idx_max]))) + lx[idx_max] 384s + } 384s > 384s > n <- 200L 384s > set.seed(1) 384s > 384s > for (mode in c("integer", "double")) { 384s + cat("mode: ", mode, "\n", sep = "") 384s + x <- matrix(runif(n, min = 1.0, max = 3.0), nrow = 20L) 384s + storage.mode(x) <- mode 384s + str(x) 384s + 384s + # The logarithm of the harmonic mean by rows 384s + y_h <- log(1 / rowMeans(1 / x)) 384s + str(y_h) 384s + 384s + lx_neg <- -log(x) 384s + 384s + y0 <- log(ncol(x)) - apply(lx_neg, MARGIN = 1L, FUN = logSumExp0) 384s + stopifnot(all.equal(y0, y_h)) 384s + 384s + y1 <- log(ncol(x)) - apply(lx_neg, MARGIN = 1L, FUN = logSumExp) 384s + stopifnot(all.equal(y1, y0)) 384s + 384s + y2 <- log(ncol(x)) - rowLogSumExps(lx_neg) 384s + stopifnot(all.equal(y2, y0)) 384s + 384s + y3 <- log(ncol(x)) - colLogSumExps(t(lx_neg)) 384s + stopifnot(all.equal(y3, y0)) 384s + 384s + 384s + # The logarithm of the harmonic mean by columns 384s + y_h <- log(1 / colMeans(1 / x)) 384s + str(y_h) 384s + 384s + y0 <- log(nrow(x)) - apply(lx_neg, MARGIN = 2L, FUN = logSumExp0) 384s + stopifnot(all.equal(y0, y_h)) 384s + 384s + y1 <- log(nrow(x)) - apply(lx_neg, MARGIN = 2L, FUN = logSumExp) 384s + stopifnot(all.equal(y1, y0)) 384s + 384s + y2 <- log(nrow(x)) - colLogSumExps(lx_neg) 384s + stopifnot(all.equal(y2, y0)) 384s + 384s + y3 <- log(nrow(x)) - rowLogSumExps(t(lx_neg)) 384s + stopifnot(all.equal(y3, y0)) 384s + 384s + # Testing names 384s + rownames(lx_neg) <- seq_len(nrow(x)) 384s + colnames(lx_neg) <- seq_len(ncol(x)) 384s + y2 <- rowLogSumExps(lx_neg, useNames = TRUE) 384s + stopifnot(identical(names(y2), rownames(lx_neg))) 384s + y3 <- colLogSumExps(t(lx_neg), useNames = TRUE) 384s + stopifnot(identical(names(y3), rownames(lx_neg))) 384s + } # for (mode ...) 384s mode: integer 384s int [1:20, 1:10] 1 1 2 2 1 2 2 2 2 1 ... 384s num [1:20] 0.357 0.223 0.223 0.288 0.511 ... 384s num [1:10] 0.322 0.223 0.322 0.255 0.255 ... 384s mode: double 384s num [1:20, 1:10] 1.54 1.44 2.03 1.54 1.36 ... 384s num [1:20] 0.526 0.466 0.734 0.638 0.604 ... 384s num [1:10] 0.627 0.582 0.617 0.474 0.418 ... 384s > 384s > 384s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 384s > # Corner cases 384s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 384s > ## Zero-size matrices 384s > lx <- matrix(numeric(0L), nrow = 0L, ncol = 0L) 384s > y <- rowLogSumExps(lx) 384s > print(y) 384s numeric(0) 384s > stopifnot(length(y) == nrow(lx)) 384s > 384s > y <- colLogSumExps(lx) 384s > print(y) 384s numeric(0) 384s > stopifnot(length(y) == ncol(lx)) 384s > 384s > ## Zero-height matrices 384s > lx <- matrix(numeric(0L), nrow = 0L, ncol = 5L) 384s > y <- rowLogSumExps(lx) 384s > print(y) 384s numeric(0) 384s > stopifnot(length(y) == nrow(lx)) 384s > 384s > y <- colLogSumExps(lx) 384s > print(y) 384s [1] -Inf -Inf -Inf -Inf -Inf 384s > stopifnot(length(y) == ncol(lx)) 384s > stopifnot(all(y == -Inf)) 384s > 384s > ## Zero-width matrices 384s > lx <- matrix(numeric(0L), nrow = 5L, ncol = 0L) 384s > y <- colLogSumExps(lx) 384s > print(y) 384s numeric(0) 384s > stopifnot(length(y) == ncol(lx)) 384s > 384s > y <- rowLogSumExps(lx) 384s > print(y) 384s [1] -Inf -Inf -Inf -Inf -Inf 384s > stopifnot(length(y) == nrow(lx)) 384s > stopifnot(all(y == -Inf)) 384s > 384s > 384s > ## Matrices with one element 384s > lx <- matrix(1.0, nrow = 1L, ncol = 1L) 384s > y <- rowLogSumExps(lx) 384s > print(y) 384s [1] 1 384s > stopifnot(length(y) == nrow(lx)) 384s > stopifnot(all(y == lx)) 384s > 384s > y <- colLogSumExps(lx) 384s > print(y) 384s [1] 1 384s > stopifnot(length(y) == ncol(lx)) 384s > stopifnot(all(y == lx)) 384s > 384s > ## All missing values 384s > lx <- matrix(NA_real_, nrow = 1L, ncol = 1L) 384s > y <- rowLogSumExps(lx, na.rm = TRUE) 384s > print(y) 384s [1] -Inf 384s > stopifnot(length(y) == nrow(lx)) 384s > stopifnot(identical(y, -Inf)) 384s > 384s > lx <- matrix(NA_real_, nrow = 1L, ncol = 1L) 384s > y <- colLogSumExps(lx, na.rm = TRUE) 384s > print(y) 384s [1] -Inf 384s > stopifnot(length(y) == ncol(lx)) 384s > stopifnot(identical(y, -Inf)) 384s > 384s > lx <- matrix(NA_real_, nrow = 2L, ncol = 2L) 384s > y <- rowLogSumExps(lx, na.rm = TRUE) 384s > print(y) 384s [1] -Inf -Inf 384s > stopifnot(length(y) == nrow(lx)) 384s > stopifnot(all(y == -Inf)) 384s > 384s > y <- rowLogSumExps(lx, na.rm = FALSE) 384s > print(y) 384s [1] NA NA 384s > stopifnot(length(y) == nrow(lx)) 384s > stopifnot(all(is.na(y) & !is.nan(y))) 384s > 384s > lx <- matrix(NA_real_, nrow = 2L, ncol = 2L) 384s > y <- colLogSumExps(lx, na.rm = TRUE) 384s > print(y) 384s [1] -Inf -Inf 384s > stopifnot(length(y) == ncol(lx)) 384s > stopifnot(all(y == -Inf)) 384s > 384s > y <- colLogSumExps(lx, na.rm = FALSE) 384s > print(y) 384s [1] NA NA 384s > stopifnot(length(y) == ncol(lx)) 384s > stopifnot(all(is.na(y) & !is.nan(y))) 384s > 384s > ## +Inf values 384s > lx <- matrix(c(1, 2, +Inf), nrow = 3L, ncol = 2L) 384s > y <- colLogSumExps(lx, na.rm = TRUE) 384s > print(y) 384s [1] Inf Inf 384s > stopifnot(length(y) == ncol(lx)) 384s > stopifnot(all(y == +Inf)) 384s > 384s > ## multiple -Inf values 384s > lx <- matrix(c(-Inf, -Inf), nrow = 2L, ncol = 3L) 384s > y <- rowLogSumExps(lx) 384s > print(y) 384s [1] -Inf -Inf 384s > stopifnot(length(y) == nrow(lx)) 384s > stopifnot(all(y == -Inf)) 384s > 384s > lx <- matrix(c(-Inf, 5, -Inf), nrow = 2L, ncol = 3L, byrow = TRUE) 384s > y <- rowLogSumExps(lx) 384s > print(y) 384s [1] 5 5 384s > stopifnot(length(y) == nrow(lx)) 384s > stopifnot(all(y == 5)) 384s > 384s > ## Bug report #104 (https://github.com/HenrikBengtsson/matrixStats/issues/104) 384s > ## (This would core dump on Windows) 384s > x <- matrix(0.0, nrow = 2L, ncol = 32762L) 384s > y <- colLogSumExps(x) 384s > str(y) 384s num [1:32762] 0.693 0.693 0.693 0.693 0.693 ... 384s > 384s > ## Bug report #120 (https://github.com/HenrikBengtsson/matrixStats/issues/120) 384s > ## (This would error if x had rownames/colnames and non-NULL rows/cols were 384s > ## used) 384s > x <- matrix(runif(6), nrow = 2L, ncol = 3L, 384s + dimnames = list(c("A", "B"), c("a", "b", "c"))) 384s > y <- colLogSumExps(x, cols = 3:1, useNames = TRUE) 384s > stopifnot(names(y) == c("c", "b", "a")) 384s > y <- rowLogSumExps(x, rows = 2, useNames = TRUE) 384s > stopifnot(names(y) == "B") 384s > 384s > 384s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 384s > # Check names attributes 384s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 384s > 384s > ## Create isFALSE() if running on an old version of R 384s > if (!exists("isFALSE", mode="function")) { 384s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 384s + } 384s > 384s > rowLogSumExps_R <- function(x, ..., useNames = TRUE) { 384s + res <- apply(x, MARGIN = 1L, FUN = function(rx, ...) { 384s + log(sum(exp(rx), ...)) 384s + }, ...) 384s + if (isFALSE(useNames)) names(res) <- NULL 384s + res 384s + } 384s > 384s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6L, ncol = 6L) 384s > 384s > # To check names attribute 384s > dimnames <- list(letters[1:6], LETTERS[1:6]) 384s > 384s > # Test with and without dimnames on x 384s > for (setDimnames in c(TRUE, FALSE)) { 384s + if (setDimnames) dimnames(x) <- dimnames 384s + else dimnames(x) <- NULL 384s + for (useNames in c(TRUE, FALSE)) { 384s + y0 <- rowLogSumExps_R(x, useNames = useNames) 384s + y1 <- rowLogSumExps(x, useNames = useNames) 384s + y2 <- colLogSumExps(t(x), useNames = useNames) 384s + stopifnot(all.equal(y1, y0)) 384s + stopifnot(all.equal(y2, y0)) 384s + } 384s + } 384s > 384s 384s R version 4.4.3 (2025-02-28) -- "Trophy Case" 384s Copyright (C) 2025 The R Foundation for Statistical Computing 384s Platform: arm-unknown-linux-gnueabihf (32-bit) 384s 384s R is free software and comes with ABSOLUTELY NO WARRANTY. 384s You are welcome to redistribute it under certain conditions. 384s Type 'license()' or 'licence()' for distribution details. 384s 384s R is a collaborative project with many contributors. 384s Type 'contributors()' for more information and 384s 'citation()' on how to cite R or R packages in publications. 384s 384s Type 'demo()' for some demos, 'help()' for on-line help, or 384s 'help.start()' for an HTML browser interface to help. 384s Type 'q()' to quit R. 384s 384s > library("matrixStats") 384s > 384s > ## Create isFALSE() if running on an old version of R 384s > if (!exists("isFALSE", mode="function")) { 384s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 384s + } 384s > 384s > rowLogSumExps_R <- function(x, ..., useNames = TRUE) { 384s + res <- apply(x, MARGIN = 1L, FUN = function(rx, ...) { 384s + log(sum(exp(rx), ...)) 384s + }, ...) 384s + if (isFALSE(useNames)) names(res) <- NULL 384s + res 384s + } 384s > 384s > 384s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 384s > # Subsetted tests 384s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 384s > source("utils/validateIndicesFramework.R") 384s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 384s > 384s > # To check names attribute 384s > dimnames <- list(letters[1:6], LETTERS[1:6]) 384s > 384s > # Test with and without dimnames on x 384s > for (setDimnames in c(TRUE, FALSE)) { 384s + if (setDimnames) dimnames(x) <- dimnames 384s + else dimnames(x) <- NULL 384s + for (rows in index_cases) { 384s + for (cols in index_cases) { 384s + for (na.rm in c(TRUE, FALSE)) { 384s + for (useNames in c(TRUE, FALSE)) { 384s + validateIndicesTestMatrix(x, rows, cols, 384s + ftest = rowLogSumExps, 384s + fsure = rowLogSumExps_R, 384s + na.rm = na.rm, useNames = useNames) 384s + validateIndicesTestMatrix(x, rows, cols, 384s + fcoltest = colLogSumExps, 384s + fsure = rowLogSumExps_R, 384s + na.rm = na.rm, useNames = useNames) 384s + } 384s + } 384s + } 384s + } 384s + } 385s > 385s 385s R version 4.4.3 (2025-02-28) -- "Trophy Case" 385s Copyright (C) 2025 The R Foundation for Statistical Computing 385s Platform: arm-unknown-linux-gnueabihf (32-bit) 385s 385s R is free software and comes with ABSOLUTELY NO WARRANTY. 385s You are welcome to redistribute it under certain conditions. 385s Type 'license()' or 'licence()' for distribution details. 385s 385s R is a collaborative project with many contributors. 385s Type 'contributors()' for more information and 385s 'citation()' on how to cite R or R packages in publications. 385s 385s Type 'demo()' for some demos, 'help()' for on-line help, or 385s 'help.start()' for an HTML browser interface to help. 385s Type 'q()' to quit R. 385s 386s > library("matrixStats") 386s > 386s > ## Always allow testing of the 'center' argument (as long as it's not defunct) 386s > options(matrixStats.center.onUse = "ignore") 386s > 386s > rowMads_R <- function(x, na.rm = FALSE, ..., useNames = TRUE) { 386s + suppressWarnings({ 386s + res <- apply(x, MARGIN = 1L, FUN = mad, na.rm = na.rm) 386s + }) 386s + if (!useNames) names(res) <- NULL 386s + res 386s + } 386s > 386s > colMads_R <- function(x, na.rm = FALSE, ..., useNames = TRUE) { 386s + suppressWarnings({ 386s + res <- apply(x, MARGIN = 2L, FUN = mad, na.rm = na.rm) 386s + }) 386s + if (!useNames) names(res) <- NULL 386s + res 386s + } 386s > 386s > rowMads_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) { 386s + center <- rowMedians(x, cols = cols, na.rm = na.rm, useNames = FALSE) 386s + rowMads(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 386s + } 386s > 386s > colMads_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) { 386s + center <- colMedians(x, rows = rows, na.rm = na.rm, useNames = FALSE) 386s + colMads(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 386s + } 386s > 386s > 386s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 386s > # A 3x3 matrix (no ties) 386s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 386s > for (mode in c("integer", "double")) { 386s + x <- matrix(c(1, 2, 3, 2, 3, 4, 3, 4, 5) + 0.1, nrow = 3, ncol = 3) 386s + cat("mode: ", mode, "\n", sep = "") 386s + storage.mode(x) <- mode 386s + str(x) 386s + 386s + # To check name attribute 386s + dimnames <- list(letters[1:3], LETTERS[1:3]) 386s + 386s + # Test with and without dimnames on x 386s + for (setDimnames in c(TRUE, FALSE)) { 386s + if (setDimnames) dimnames(x) <- dimnames 386s + else dimnames(x) <- NULL 386s + tx <- t(x) 386s + # Check names attribute 386s + for (useNames in c(TRUE, FALSE)) { 386s + cat("rowMads():\n") 386s + center <- rowMedians(x, na.rm = TRUE, useNames = useNames) 386s + r0 <- rowMads_R(x, na.rm = TRUE, useNames = useNames) 386s + r1 <- rowMads(x, na.rm = TRUE, useNames = useNames) 386s + r1b <- rowMads_center(x, na.rm = TRUE, useNames = useNames) 386s + r1c <- rowMads(x, center = center, na.rm = TRUE, useNames = useNames) 386s + r2 <- colMads(tx, na.rm = TRUE, useNames = useNames) 386s + r2b <- colMads_center(tx, na.rm = TRUE, useNames = useNames) 386s + stopifnot(all.equal(r1, r2)) 386s + stopifnot(all.equal(r1, r0)) 386s + stopifnot(all.equal(r1b, r1)) 386s + stopifnot(all.equal(r1c, r1)) 386s + stopifnot(all.equal(r2, r0)) 386s + stopifnot(all.equal(r2b, r2)) 386s + 386s + cat("colMads():\n") 386s + center <- colMedians(x, na.rm = TRUE, useNames = useNames) 386s + r0 <- colMads_R(x, na.rm = TRUE, useNames = useNames) 386s + r1 <- colMads(x, na.rm = TRUE, useNames = useNames) 386s + r1b <- colMads_center(x, na.rm = TRUE, useNames = useNames) 386s + r1c <- colMads(x, center = center, na.rm = TRUE, useNames = useNames) 386s + r2 <- rowMads(tx, na.rm = TRUE, useNames = useNames) 386s + r2b <- rowMads_center(tx, na.rm = TRUE, useNames = useNames) 386s + stopifnot(all.equal(r1, r2)) 386s + stopifnot(all.equal(r1, r0)) 386s + stopifnot(all.equal(r1b, r1)) 386s + stopifnot(all.equal(r1c, r1)) 386s + stopifnot(all.equal(r2, r0)) 386s + stopifnot(all.equal(r2b, r2)) 386s + } 386s + } 386s + } 386s mode: integer 386s int [1:3, 1:3] 1 2 3 2 3 4 3 4 5 386s rowMads(): 386s colMads(): 386s rowMads(): 386s colMads(): 386s rowMads(): 386s colMads(): 386s rowMads(): 386s colMads(): 386s mode: double 386s num [1:3, 1:3] 1.1 2.1 3.1 2.1 3.1 4.1 3.1 4.1 5.1 386s rowMads(): 386s colMads(): 386s rowMads(): 386s colMads(): 386s rowMads(): 386s colMads(): 386s rowMads(): 386s colMads(): 386s > 386s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 386s > # Ties: a 4x4 matrix 386s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 386s > for (mode in c("integer", "double")) { 386s + x <- matrix(c(1:4, 2:5, 3:6, 4:7) + 0.1, nrow = 4, ncol = 4) 386s + cat("mode: ", mode, "\n", sep = "") 386s + storage.mode(x) <- mode 386s + str(x) 386s + tx <- t(x) 386s + 386s + # To check name attribute 386s + dimnames <- list(letters[1:4], LETTERS[1:4]) 386s + 386s + # Test with and without dimnames on x 386s + for (setDimnames in c(TRUE, FALSE)) { 386s + if (setDimnames) dimnames(x) <- dimnames 386s + else dimnames(x) <- NULL 386s + tx <- t(x) 386s + # Check names attribute 386s + for (useNames in c(TRUE, FALSE)) { 386s + cat("rowMads():\n") 386s + r0 <- rowMads_R(x, na.rm = TRUE, useNames = useNames) 386s + r1 <- rowMads(x, na.rm = TRUE, useNames = useNames) 386s + r2 <- colMads(tx, na.rm = TRUE, useNames = useNames) 386s + stopifnot(all.equal(r1, r2)) 386s + stopifnot(all.equal(r1, r0)) 386s + stopifnot(all.equal(r2, r0)) 386s + 386s + cat("colMads():\n") 386s + r0 <- colMads_R(x, na.rm = TRUE, useNames = useNames) 386s + r1 <- colMads(x, na.rm = TRUE, useNames = useNames) 386s + r2 <- rowMads(tx, na.rm = TRUE, useNames = useNames) 386s + stopifnot(all.equal(r1, r2)) 386s + stopifnot(all.equal(r1, r0)) 386s + stopifnot(all.equal(r2, r0)) 386s + } 386s + } 386s + } 386s mode: integer 386s int [1:4, 1:4] 1 2 3 4 2 3 4 5 3 4 ... 386s rowMads(): 386s colMads(): 386s rowMads(): 386s colMads(): 386s rowMads(): 386s colMads(): 386s rowMads(): 386s colMads(): 386s mode: double 386s 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 ... 386s rowMads(): 386s colMads(): 386s rowMads(): 386s colMads(): 386s rowMads(): 386s colMads(): 386s rowMads(): 386s colMads(): 386s > tx <- NULL 386s > 386s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 386s > # No ties: a 3x3 matrix with an NA value 386s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 386s > for (mode in c("integer", "double")) { 386s + x <- matrix(c(1, 2, 3, 2, 3, 4, 3, 4, 5) + 0.1, nrow = 3, ncol = 3) 386s + x[2, 2] <- NA_real_ 386s + 386s + cat("mode: ", mode, "\n", sep = "") 386s + storage.mode(x) <- mode 386s + str(x) 386s + tx <- t(x) 386s + 386s + # To check name attribute 386s + dimnames <- list(letters[1:3], LETTERS[1:3]) 386s + 386s + # Test with and without dimnames on x 386s + for (setDimnames in c(TRUE, FALSE)) { 386s + if (setDimnames) dimnames(x) <- dimnames 386s + else dimnames(x) <- NULL 386s + tx <- t(x) 386s + # Check names attribute 386s + for (useNames in c(TRUE, FALSE)) { 386s + cat("rowMads():\n") 386s + r0 <- rowMads_R(x, na.rm = TRUE, useNames = useNames) 386s + r1 <- rowMads(x, na.rm = TRUE, useNames = useNames) 386s + r2 <- colMads(tx, na.rm = TRUE, useNames = useNames) 386s + stopifnot(all.equal(r1, r2)) 386s + stopifnot(all.equal(r1, r0)) 386s + stopifnot(all.equal(r2, r0)) 386s + 386s + cat("colMads():\n") 386s + r0 <- colMads_R(x, na.rm = TRUE, useNames = useNames) 386s + r1 <- colMads(x, na.rm = TRUE, useNames = useNames) 386s + r2 <- rowMads(tx, na.rm = TRUE, useNames = useNames) 386s + stopifnot(all.equal(r1, r2)) 386s + stopifnot(all.equal(r1, r0)) 386s + stopifnot(all.equal(r2, r0)) 386s + } 386s + } 386s + } 386s mode: integer 386s int [1:3, 1:3] 1 2 3 2 NA 4 3 4 5 386s rowMads(): 386s colMads(): 386s rowMads(): 386s colMads(): 386s rowMads(): 386s colMads(): 386s rowMads(): 386s colMads(): 386s mode: double 386s num [1:3, 1:3] 1.1 2.1 3.1 2.1 NA 4.1 3.1 4.1 5.1 386s rowMads(): 386s colMads(): 386s rowMads(): 386s colMads(): 386s rowMads(): 386s colMads(): 386s rowMads(): 386s colMads(): 386s > tx <- NULL 386s > 386s > 386s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 386s > # With and without some NAs 386s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 386s > for (add_na in c(FALSE, TRUE)) { 386s + cat("add_na = ", add_na, "\n", sep = "") 386s + 386s + x <- matrix(1:50, nrow = 10L, ncol = 5L) 386s + if (add_na) { 386s + x[3:7, c(2, 4)] <- NA_real_ 386s + } 386s + 386s + # To check name attribute 386s + dimnames <- list(letters[1:10], LETTERS[1:5]) 386s + 386s + # Test with and without dimnames on x 386s + for (setDimnames in c(TRUE, FALSE)) { 386s + if (setDimnames) dimnames(x) <- dimnames 386s + else dimnames(x) <- NULL 386s + tx <- t(x) 386s + # Row/column ranges 386s + for (na.rm in c(FALSE, TRUE)) { 386s + # Check names attribute 386s + for (useNames in c(TRUE, FALSE)) { 386s + cat("na.rm = ", na.rm, "\n", sep = "") 386s + cat("rowMads():\n") 386s + center <- rowMedians(x, na.rm = na.rm, useNames = useNames) 386s + r0 <- rowMads_R(x, na.rm = na.rm, useNames = useNames) 386s + r1 <- rowMads(x, na.rm = na.rm, useNames = useNames) 386s + r2 <- rowMads(x, center = center, na.rm = na.rm, useNames = useNames) 386s + r3 <- colMads(tx, na.rm = na.rm, useNames = useNames) 386s + stopifnot(all.equal(r1, r0)) 386s + stopifnot(all.equal(r2, r0)) 386s + stopifnot(all.equal(r2, r1)) 386s + stopifnot(all.equal(r3, r0)) 386s + stopifnot(all.equal(r3, r1)) 386s + stopifnot(all.equal(r3, r2)) 386s + 386s + cat("colMads():\n") 386s + center <- colMedians(x, na.rm = na.rm, useNames = useNames) 386s + r0 <- colMads_R(x, na.rm = na.rm, useNames = useNames) 386s + r1 <- colMads(x, na.rm = na.rm, useNames = useNames) 386s + r2 <- colMads(x, center = center, na.rm = na.rm, useNames = useNames) 386s + r3 <- rowMads(tx, na.rm = na.rm, useNames = useNames) 386s + stopifnot(all.equal(r1, r0)) 386s + stopifnot(all.equal(r2, r0)) 386s + stopifnot(all.equal(r2, r1)) 386s + stopifnot(all.equal(r3, r0)) 386s + stopifnot(all.equal(r3, r1)) 386s + stopifnot(all.equal(r3, r2)) 386s + } 386s + } 386s + } 386s + tx <- NULL 386s + } # for (add_na ...) 386s add_na = FALSE 386s na.rm = FALSE 386s rowMads(): 386s colMads(): 386s na.rm = FALSE 386s rowMads(): 386s colMads(): 386s na.rm = TRUE 386s rowMads(): 386s colMads(): 386s na.rm = TRUE 386s rowMads(): 386s colMads(): 386s na.rm = FALSE 386s rowMads(): 386s colMads(): 386s na.rm = FALSE 386s rowMads(): 386s colMads(): 386s na.rm = TRUE 386s rowMads(): 386s colMads(): 386s na.rm = TRUE 386s rowMads(): 386s colMads(): 386s add_na = TRUE 386s na.rm = FALSE 386s rowMads(): 386s colMads(): 386s na.rm = FALSE 386s rowMads(): 386s colMads(): 386s na.rm = TRUE 386s rowMads(): 386s colMads(): 386s na.rm = TRUE 386s rowMads(): 386s colMads(): 386s na.rm = FALSE 386s rowMads(): 386s colMads(): 386s na.rm = FALSE 386s rowMads(): 386s colMads(): 386s na.rm = TRUE 386s rowMads(): 386s colMads(): 386s na.rm = TRUE 386s rowMads(): 386s colMads(): 386s > 386s > 386s > 386s > 386s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 386s > # All NAs 386s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 386s > x <- matrix(NA_real_, nrow = 10L, ncol = 5L) 386s > # Test with and without dimnames on x 386s > for (setDimnames in c(TRUE, FALSE)) { 386s + if (setDimnames) dimnames(x) <- dimnames 386s + else dimnames(x) <- NULL 386s + tx <- t(x) 386s + # Row/column ranges 386s + for (na.rm in c(FALSE, TRUE)) { 386s + # Check names attribute 386s + for (useNames in c(TRUE, FALSE)) { 386s + cat("na.rm = ", na.rm, "\n", sep = "") 386s + r0 <- rowMads_R(x, na.rm = na.rm, useNames = useNames) 386s + if (na.rm) r0[is.na(r0)] <- NaN 386s + r1 <- rowMads(x, na.rm = na.rm, useNames = useNames) 386s + r2 <- colMads(tx, na.rm = na.rm, useNames = useNames) 386s + stopifnot(all.equal(r1, r0)) 386s + stopifnot(all.equal(r2, r0)) 386s + stopifnot(all.equal(r1, r2)) 386s + } 386s + } 386s + } 386s na.rm = FALSE 386s na.rm = FALSE 386s na.rm = TRUE 386s na.rm = TRUE 386s na.rm = FALSE 386s na.rm = FALSE 386s na.rm = TRUE 386s na.rm = TRUE 386s > tx <- NULL 386s > 386s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 386s > # A 1x1 matrix 386s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 386s > x <- matrix(0, nrow = 1L, ncol = 1L) 386s > dimnames <- list("a", "A") 386s > # Test with and without dimnames on x 386s > for (setDimnames in c(TRUE, FALSE)) { 386s + if (setDimnames) dimnames(x) <- dimnames 386s + else dimnames(x) <- NULL 386s + tx <- t(x) 386s + # Row/column ranges 386s + for (na.rm in c(FALSE, TRUE)) { 386s + # Check names attribute 386s + for (useNames in c(TRUE, FALSE)) { 386s + cat("na.rm = ", na.rm, "\n", sep = "") 386s + r0 <- rowMads_R(x, na.rm = na.rm, useNames = useNames) 386s + r1 <- rowMads(x, na.rm = na.rm, useNames = useNames) 386s + r2 <- colMads(tx, na.rm = na.rm, useNames = useNames) 386s + stopifnot(all.equal(r1, r0)) 386s + stopifnot(all.equal(r2, r0)) 386s + stopifnot(all.equal(r1, r2)) 386s + } 386s + } 386s + } 386s na.rm = FALSE 386s na.rm = FALSE 386s na.rm = TRUE 386s na.rm = TRUE 386s na.rm = FALSE 386s na.rm = FALSE 386s na.rm = TRUE 386s na.rm = TRUE 386s > 386s > 386s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 386s > # A 0x0 matrix 386s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 386s > x <- matrix(double(0), nrow = 0, ncol = 0) 386s > tx <- t(x) 386s > for (na.rm in c(FALSE, TRUE)) { 386s + cat("na.rm = ", na.rm, "\n", sep = "") 386s + r0 <- rowMads_R(x, na.rm = na.rm) 386s + r1 <- rowMads(x, na.rm = na.rm) 386s + r2 <- colMads(tx, na.rm = na.rm) 386s + stopifnot(all.equal(r1, r2)) 386s + stopifnot(all.equal(r1, r0)) 386s + stopifnot(all.equal(r2, r0)) 386s + } 386s na.rm = FALSE 386s na.rm = TRUE 386s > 386s 386s R version 4.4.3 (2025-02-28) -- "Trophy Case" 386s Copyright (C) 2025 The R Foundation for Statistical Computing 386s Platform: arm-unknown-linux-gnueabihf (32-bit) 386s 386s R is free software and comes with ABSOLUTELY NO WARRANTY. 386s You are welcome to redistribute it under certain conditions. 386s Type 'license()' or 'licence()' for distribution details. 386s 386s R is a collaborative project with many contributors. 386s Type 'contributors()' for more information and 386s 'citation()' on how to cite R or R packages in publications. 386s 386s Type 'demo()' for some demos, 'help()' for on-line help, or 386s 'help.start()' for an HTML browser interface to help. 386s Type 'q()' to quit R. 386s 387s > library("matrixStats") 387s > 387s > ## Always allow testing of the 'center' argument (as long as it's not defunct) 387s > options(matrixStats.center.onUse = "ignore") 387s > 387s > rowMads_R <- function(x, na.rm = FALSE, ..., useNames = TRUE) { 387s + suppressWarnings({ 387s + res <- apply(x, MARGIN = 1L, FUN = mad, na.rm = na.rm) 387s + }) 387s + if (!useNames) names(res) <- NULL 387s + res 387s + } 387s > 387s > colMads_R <- function(x, na.rm = FALSE, ..., useNames = TRUE) { 387s + suppressWarnings({ 387s + res <- apply(x, MARGIN = 2L, FUN = mad, na.rm = na.rm) 387s + }) 387s + if (!useNames) names(res) <- NULL 387s + res 387s + } 387s > 387s > rowMads_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) { 387s + center <- rowMedians(x, cols = cols, na.rm = na.rm, useNames = FALSE) 387s + rowMads(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 387s + } 387s > 387s > colMads_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) { 387s + center <- colMedians(x, rows = rows, na.rm = na.rm, useNames = FALSE) 387s + colMads(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 387s + } 387s > 387s > 387s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 387s > # Subsetted tests 387s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 387s > source("utils/validateIndicesFramework.R") 387s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 387s > storage.mode(x) <- "integer" 387s > 387s > # To check names attribute 387s > dimnames <- list(letters[1:6], LETTERS[1:6]) 387s > 387s > # Test with and without dimnames on x 387s > for (setDimnames in c(TRUE, FALSE)) { 387s + if (setDimnames) dimnames(x) <- dimnames 387s + else dimnames(x) <- NULL 387s + 387s + count <- 0L 387s + for (rows in index_cases) { 387s + for (cols in index_cases) { 387s + count <- count + 1L 387s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 387s + useNames <- c(TRUE, FALSE) 387s + useNames <- useNames[count %% length(useNames) + 1] 387s + 387s + validateIndicesTestMatrix(x, rows, cols, 387s + ftest = rowMads, fsure = rowMads_R, 387s + na.rm = na.rm, useNames = useNames) 387s + validateIndicesTestMatrix(x, rows, cols, 387s + ftest = rowMads_center, fsure = rowMads_R, 387s + na.rm = na.rm, useNames = useNames) 387s + 387s + validateIndicesTestMatrix(x, rows, cols, 387s + fcoltest = colMads, fsure = rowMads_R, 387s + na.rm = na.rm, useNames = useNames) 387s + validateIndicesTestMatrix(x, rows, cols, 387s + fcoltest = colMads_center, fsure = rowMads_R, 387s + na.rm = na.rm, useNames = useNames) 387s + } 387s + } 387s + } 388s > 388s 388s R version 4.4.3 (2025-02-28) -- "Trophy Case" 388s Copyright (C) 2025 The R Foundation for Statistical Computing 388s Platform: arm-unknown-linux-gnueabihf (32-bit) 388s 388s R is free software and comes with ABSOLUTELY NO WARRANTY. 388s You are welcome to redistribute it under certain conditions. 388s Type 'license()' or 'licence()' for distribution details. 388s 388s R is a collaborative project with many contributors. 388s Type 'contributors()' for more information and 388s 'citation()' on how to cite R or R packages in publications. 388s 388s Type 'demo()' for some demos, 'help()' for on-line help, or 388s 'help.start()' for an HTML browser interface to help. 388s Type 'q()' to quit R. 388s 388s > library("matrixStats") 388s > 388s > rowMeans_R <- function(x, na.rm = FALSE, ..., useNames = TRUE) { 388s + res <- rowMeans(x, na.rm = na.rm) 388s + if (!useNames) names(res) <- NULL 388s + res 388s + } 388s > 388s > colMeans_R <- function(x, na.rm = FALSE, ..., useNames = TRUE) { 388s + res <- colMeans(x, na.rm = na.rm) 388s + if (!useNames) names(res) <- NULL 388s + res 388s + } 388s > 388s > for (mode in c("integer", "logical", "double")) { 388s + x <- matrix(-4:4, nrow = 3, ncol = 3) 388s + storage.mode(x) <- mode 388s + if (mode == "double") x <- x + 0.1 388s + 388s + # To check names attribute 388s + dimnames <- list(letters[1:3], LETTERS[1:3]) 388s + 388s + # Test with and without dimnames on x 388s + for (setDimnames in c(TRUE, FALSE)) { 388s + if (setDimnames) dimnames(x) <- dimnames 388s + else dimnames(x) <- NULL 388s + # Check names attribute 388s + for (useNames in c(TRUE, FALSE)) { 388s + y0 <- rowMeans_R(x, na.rm = FALSE, useNames = useNames) 388s + y1 <- rowMeans2(x, na.rm = FALSE, useNames = useNames) 388s + stopifnot(all.equal(y1, y0)) 388s + 388s + y0 <- colMeans_R(x, na.rm = FALSE, useNames = useNames) 388s + y1 <- colMeans2(x, na.rm = FALSE, useNames = useNames) 388s + stopifnot(all.equal(y1, y0)) 388s + } 388s + } 388s + } 388s > 388s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 388s > # Special case: Single-element matrix 388s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 388s > cat("Special case: Single-element matrix:\n") 388s Special case: Single-element matrix: 388s > for (mode in c("integer", "logical", "double")) { 388s + x <- matrix(1, nrow = 1, ncol = 1) 388s + storage.mode(x) <- mode 388s + 388s + # To check names attribute 388s + dimnames <- list("a", "A") 388s + 388s + # Test with and without dimnames on x 388s + for (setDimnames in c(TRUE, FALSE)) { 388s + if (setDimnames) dimnames(x) <- dimnames 388s + else dimnames(x) <- NULL 388s + # Check names attribute 388s + for (useNames in c(TRUE, FALSE)) { 388s + y0 <- rowMeans_R(x, na.rm = FALSE, useNames = useNames) 388s + y1 <- rowMeans2(x, na.rm = FALSE, useNames = useNames) 388s + stopifnot(all.equal(y1, y0)) 388s + 388s + y0 <- colMeans_R(x, na.rm = FALSE, useNames = useNames) 388s + y1 <- colMeans2(x, na.rm = FALSE, useNames = useNames) 388s + stopifnot(all.equal(y1, y0)) 388s + } 388s + } 388s + } 388s > 388s > 388s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 388s > # Special case: Empty matrix 388s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 388s > cat("Special case: Empty matrix:\n") 388s Special case: Empty matrix: 388s > for (mode in c("integer", "logical", "double")) { 388s + x <- matrix(integer(0), nrow = 0, ncol = 0) 388s + storage.mode(x) <- mode 388s + 388s + y0 <- rowMeans(x, na.rm = FALSE) 388s + y1 <- rowMeans2(x, na.rm = FALSE) 388s + stopifnot(all.equal(y1, y0)) 388s + 388s + y0 <- colMeans(x, na.rm = FALSE) 388s + y1 <- colMeans2(x, na.rm = FALSE) 388s + stopifnot(all.equal(y1, y0)) 388s + } 388s > 388s > 388s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 388s > # Special case: All NAs 388s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 388s > cat("Special case: All NAs:\n") 388s Special case: All NAs: 388s > for (mode in c("integer", "logical", "double")) { 388s + x <- matrix(NA_integer_, nrow = 3, ncol = 3) 388s + storage.mode(x) <- mode 388s + 388s + # To check names attribute 388s + dimnames <- list(letters[1:3], LETTERS[1:3]) 388s + 388s + # Test with and without dimnames on x 388s + for (setDimnames in c(TRUE, FALSE)) { 388s + if (setDimnames) dimnames(x) <- dimnames 388s + else dimnames(x) <- NULL 388s + # Check names attribute 388s + for (useNames in c(TRUE, FALSE)) { 388s + y0 <- rowMeans_R(x, na.rm = TRUE, useNames = useNames) 388s + y1 <- rowMeans2(x, na.rm = TRUE, useNames = useNames) 388s + stopifnot(all.equal(y1, y0)) 388s + 388s + y0 <- colMeans_R(x, na.rm = TRUE, useNames = useNames) 388s + y1 <- colMeans2(x, na.rm = TRUE, useNames = useNames) 388s + stopifnot(all.equal(y1, y0)) 388s + } 388s + } 388s + } 388s > 388s > 388s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 388s > # Special case: All NaNs 388s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 388s > cat("Special case: All NaNs:\n") 388s Special case: All NaNs: 388s > x <- matrix(NA_real_, nrow = 3, ncol = 3) 388s > 388s > # Test with and without dimnames on x 388s > for (setDimnames in c(TRUE, FALSE)) { 388s + if (setDimnames) dimnames(x) <- dimnames 388s + else dimnames(x) <- NULL 388s + # Check names attribute 388s + for (useNames in c(TRUE, FALSE)) { 388s + y0 <- rowMeans_R(x, na.rm = TRUE, useNames = useNames) 388s + y1 <- rowMeans2(x, na.rm = TRUE, useNames = useNames) 388s + stopifnot(all.equal(y1, y0)) 388s + 388s + y0 <- colMeans_R(x, na.rm = TRUE, useNames = useNames) 388s + y1 <- colMeans2(x, na.rm = TRUE, useNames = useNames) 388s + stopifnot(all.equal(y1, y0)) 388s + } 388s + } 388s > 388s > 388s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 388s > # Special case: All Infs 388s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 388s > cat("Special case: All Infs:\n") 388s Special case: All Infs: 388s > x <- matrix(Inf, nrow = 3, ncol = 3) 388s > 388s > # Test with and without dimnames on x 388s > for (setDimnames in c(TRUE, FALSE)) { 388s + if (setDimnames) dimnames(x) <- dimnames 388s + else dimnames(x) <- NULL 388s + # Check names attribute 388s + for (useNames in c(TRUE, FALSE)) { 388s + y0 <- rowMeans_R(x, na.rm = FALSE, useNames = useNames) 388s + y1 <- rowMeans2(x, na.rm = FALSE, useNames = useNames) 388s + stopifnot(all.equal(y1, y0)) 388s + 388s + y0 <- colMeans_R(x, na.rm = FALSE, useNames = useNames) 388s + y1 <- colMeans2(x, na.rm = FALSE, useNames = useNames) 388s + stopifnot(all.equal(y1, y0)) 388s + } 388s + } 388s > 388s > 388s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 388s > # Special case: All -Infs 388s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 388s > cat("Special case: All -Infs:\n") 388s Special case: All -Infs: 388s > x <- matrix(-Inf, nrow = 3, ncol = 3) 388s > 388s > # Test with and without dimnames on x 388s > for (setDimnames in c(TRUE, FALSE)) { 388s + if (setDimnames) dimnames(x) <- dimnames 388s + else dimnames(x) <- NULL 388s + # Check names attribute 388s + for (useNames in c(TRUE, FALSE)) { 388s + y0 <- rowMeans_R(x, na.rm = FALSE, useNames = useNames) 388s + y1 <- rowMeans2(x, na.rm = FALSE, useNames = useNames) 388s + stopifnot(all.equal(y1, y0)) 388s + 388s + y0 <- colMeans_R(x, na.rm = FALSE, useNames = useNames) 388s + y1 <- colMeans2(x, na.rm = FALSE, useNames = useNames) 388s + stopifnot(all.equal(y1, y0)) 388s + } 388s + } 388s > 388s > 388s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 388s > # Special case: Infs and -Infs 388s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 388s > cat("Special case: Infs and -Infs:\n") 388s Special case: Infs and -Infs: 388s > x <- matrix(c(-Inf, +Inf), nrow = 4, ncol = 4) 388s > 388s > # To check names attribute 388s > dimnames <- list(letters[1:4], LETTERS[1:4]) 388s > 388s > # Test with and without dimnames on x 388s > for (setDimnames in c(TRUE, FALSE)) { 388s + if (setDimnames) dimnames(x) <- dimnames 388s + else dimnames(x) <- NULL 388s + # Check names attribute 388s + for (useNames in c(TRUE, FALSE)) { 388s + y0 <- rowMeans_R(x, na.rm = FALSE, useNames = useNames) 388s + y1 <- rowMeans2(x, na.rm = FALSE, useNames = useNames) 388s + stopifnot(all.equal(y1, y0)) 388s + 388s + y0 <- colMeans_R(x, na.rm = FALSE, useNames = useNames) 388s + y1 <- colMeans2(x, na.rm = FALSE, useNames = useNames) 388s + stopifnot(all.equal(y1, y0)) 388s + } 388s + } 388s > 388s > 388s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 388s > # Special case: NaNs and NAs 388s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 388s > cat("Special case: NaNs and NAs:\n") 388s Special case: NaNs and NAs: 388s > x <- matrix(c(NaN, NA_real_), nrow = 4, ncol = 4) 388s > 388s > # Test with and without dimnames on x 388s > for (setDimnames in c(TRUE, FALSE)) { 388s + if (setDimnames) dimnames(x) <- dimnames 388s + else dimnames(x) <- NULL 388s + # Check names attribute 388s + for (useNames in c(TRUE, FALSE)) { 388s + y0 <- rowMeans_R(x, na.rm = FALSE, useNames = useNames) 388s + str(y0) 388s + stopifnot(all(is.na(y0)), length(unique(y0)) >= 1L) 388s + y1 <- rowMeans2(x, na.rm = FALSE, useNames = useNames) 388s + str(y1) 388s + stopifnot(all(is.na(y1)), length(unique(y1)) >= 1L) 388s + stopifnot(all.equal(y1, y0)) 388s + 388s + y0 <- colMeans_R(x, na.rm = FALSE, useNames = useNames) 388s + stopifnot(all(is.na(y0)), length(unique(y0)) == 1L) 388s + y1 <- colMeans2(x, na.rm = FALSE, useNames = useNames) 388s + stopifnot(all(is.na(y1)), length(unique(y1)) == 1L) 388s + stopifnot(all.equal(y1, y0)) 388s + } 388s + } 388s Named num [1:4] NaN NA NaN NA 388s - attr(*, "names")= chr [1:4] "a" "b" "c" "d" 388s Named num [1:4] NaN NA NaN NA 388s - attr(*, "names")= chr [1:4] "a" "b" "c" "d" 388s num [1:4] NaN NA NaN NA 388s num [1:4] NaN NA NaN NA 388s num [1:4] NaN NA NaN NA 388s num [1:4] NaN NA NaN NA 388s num [1:4] NaN NA NaN NA 388s num [1:4] NaN NA NaN NA 388s > ## NOTE, due to compiler optimization, it is not guaranteed that NA is 388s > ## returned here (as one would expect). NaN might very well be returned, 388s > ## when both NA and NaN are involved. This is an accepted feature in R, 388s > ## which is documented in help("is.nan"). See also 388s > ## https://stat.ethz.ch/pipermail/r-devel/2017-April/074009.html. 388s > ## Thus, we cannot guarantee that y1 is identical to y0. 388s > 388s > 388s > 388s > 388s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 388s > # Special case: Integer overflow with ties 388s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 388s > cat("Special case: Integer overflow with ties:\n") 388s Special case: Integer overflow with ties: 388s > x <- matrix(.Machine$integer.max, nrow = 4, ncol = 4) 388s > 388s > # Test with and without dimnames on x 388s > for (setDimnames in c(TRUE, FALSE)) { 388s + if (setDimnames) dimnames(x) <- dimnames 388s + else dimnames(x) <- NULL 388s + # Check names attribute 388s + for (useNames in c(TRUE, FALSE)) { 388s + y0 <- rowMeans_R(x, na.rm = FALSE, useNames = useNames) 388s + y1 <- rowMeans2(x, na.rm = FALSE, useNames = useNames) 388s + stopifnot(all.equal(y1, y0)) 388s + 388s + y0 <- colMeans_R(x, na.rm = FALSE, useNames = useNames) 388s + y1 <- colMeans2(x, na.rm = FALSE, useNames = useNames) 388s + stopifnot(all.equal(y1, y0)) 388s + } 388s + } 388s > 388s > 388s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 388s > # Consistency checks 388s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 388s > set.seed(1) 388s > 388s > cat("Consistency checks:\n") 388s Consistency checks: 388s > n_sims <- if (Sys.getenv("_R_CHECK_USE_VALGRIND_") != "") 4L else 20L 388s > for (kk in seq_len(n_sims)) { 388s + cat("Random test #", kk, "\n", sep = "") 388s + 388s + # Simulate data in a matrix of any shape 388s + dim <- sample(50:200, size = 2) 388s + n <- prod(dim) 388s + x <- rnorm(n, sd = 100) 388s + dim(x) <- dim 388s + 388s + # Add NAs? 388s + if ((kk %% 4) %in% c(3, 0)) { 388s + cat("Adding NAs\n") 388s + nna <- sample(n, size = 1) 388s + na_values <- c(NA_real_, NaN) 388s + t <- sample(na_values, size = nna, replace = TRUE) 388s + x[sample(length(x), size = nna)] <- t 388s + } 388s + 388s + # Mode? 388s + modes <- "double" 388s + if ((kk %% 4) %in% c(2, 0)) { 388s + modes <- c("integer", "logical") 388s + } 388s + 388s + for (mode in modes) { 388s + if (mode != "double") { 388s + cat(sprintf("Coercing from %s to %s\n", storage.mode(x), mode)) 388s + storage.mode(x) <- mode 388s + } 388s + 388s + na.rm <- sample(c(TRUE, FALSE), size = 1) 388s + 388s + # rowMeans2(): 388s + y0 <- rowMeans(x, na.rm = na.rm) 388s + y1 <- rowMeans2(x, na.rm = na.rm) 388s + stopifnot(all.equal(y1, y0)) 388s + y2 <- colMeans2(t(x), na.rm = na.rm) 388s + stopifnot(all.equal(y2, y0)) 388s + 388s + # colMeans2(): 388s + y0 <- colMeans(x, na.rm = na.rm) 388s + y1 <- colMeans2(x, na.rm = na.rm) 388s + stopifnot(all.equal(y1, y0)) 388s + y2 <- rowMeans2(t(x), na.rm = na.rm) 388s + stopifnot(all.equal(y2, y0)) 388s + } 388s + } # for (kk ...) 388s Random test #1 388s Random test #2 388s Coercing from double to integer 388s Coercing from integer to logical 388s Random test #3 388s Adding NAs 388s Random test #4 388s Adding NAs 388s Coercing from double to integer 388s Coercing from integer to logical 388s Random test #5 388s Random test #6 388s Coercing from double to integer 388s Coercing from integer to logical 388s Random test #7 388s Adding NAs 388s Random test #8 388s Adding NAs 388s Coercing from double to integer 388s Coercing from integer to logical 388s Random test #9 388s Random test #10 388s Coercing from double to integer 388s Coercing from integer to logical 388s Random test #11 388s Adding NAs 388s Random test #12 388s Adding NAs 388s Coercing from double to integer 388s Coercing from integer to logical 388s Random test #13 388s Random test #14 388s Coercing from double to integer 388s Coercing from integer to logical 388s Random test #15 388s Adding NAs 388s Random test #16 388s Adding NAs 388s Coercing from double to integer 388s Coercing from integer to logical 388s Random test #17 388s Random test #18 388s Coercing from double to integer 388s Coercing from integer to logical 388s Random test #19 388s Adding NAs 388s Random test #20 388s Adding NAs 388s Coercing from double to integer 388s Coercing from integer to logical 388s > 388s 388s R version 4.4.3 (2025-02-28) -- "Trophy Case" 388s Copyright (C) 2025 The R Foundation for Statistical Computing 388s Platform: arm-unknown-linux-gnueabihf (32-bit) 388s 388s R is free software and comes with ABSOLUTELY NO WARRANTY. 388s You are welcome to redistribute it under certain conditions. 388s Type 'license()' or 'licence()' for distribution details. 388s 388s R is a collaborative project with many contributors. 388s Type 'contributors()' for more information and 388s 'citation()' on how to cite R or R packages in publications. 388s 388s Type 'demo()' for some demos, 'help()' for on-line help, or 388s 'help.start()' for an HTML browser interface to help. 388s Type 'q()' to quit R. 388s 389s > library("matrixStats") 389s > 389s > rowMeans_R <- function(x, na.rm = FALSE, ..., useNames = TRUE) { 389s + res <- rowMeans(x, na.rm = na.rm) 389s + if (!useNames) names(res) <- NULL 389s + res 389s + } 389s > 389s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 389s > # Subsetted tests 389s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 389s > source("utils/validateIndicesFramework.R") 389s > x <- matrix(runif(6 * 6, min = -3, max = 3), nrow = 6, ncol = 6) 389s > storage.mode(x) <- "integer" 389s > 389s > # To check names attribute 389s > dimnames <- list(letters[1:6], LETTERS[1:6]) 389s > 389s > # Test with and without dimnames on x 389s > for (setDimnames in c(TRUE, FALSE)) { 389s + if (setDimnames) dimnames(x) <- dimnames 389s + else dimnames(x) <- NULL 389s + 389s + count <- 0L 389s + for (rows in index_cases) { 389s + for (cols in index_cases) { 389s + count <- count + 1L 389s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 389s + useNames <- c(TRUE, FALSE) 389s + useNames <- useNames[count %% length(useNames) + 1] 389s + 389s + validateIndicesTestMatrix(x, rows, cols, 389s + ftest = rowMeans2, fsure = rowMeans_R, 389s + na.rm = na.rm, useNames = useNames) 389s + validateIndicesTestMatrix(x, rows, cols, 389s + fcoltest = colMeans2, fsure = rowMeans_R, 389s + na.rm = na.rm, useNames = useNames) 389s + } 389s + } 389s + } 389s > 389s 389s R version 4.4.3 (2025-02-28) -- "Trophy Case" 389s Copyright (C) 2025 The R Foundation for Statistical Computing 389s Platform: arm-unknown-linux-gnueabihf (32-bit) 389s 389s R is free software and comes with ABSOLUTELY NO WARRANTY. 389s You are welcome to redistribute it under certain conditions. 389s Type 'license()' or 'licence()' for distribution details. 389s 389s R is a collaborative project with many contributors. 389s Type 'contributors()' for more information and 389s 'citation()' on how to cite R or R packages in publications. 389s 389s Type 'demo()' for some demos, 'help()' for on-line help, or 389s 'help.start()' for an HTML browser interface to help. 389s Type 'q()' to quit R. 389s 389s > library("matrixStats") 389s > 389s > rowMedians_R <- function(x, na.rm = FALSE, ..., useNames = TRUE) { 389s + res <- apply(x, MARGIN = 1L, FUN = median, na.rm = na.rm) 389s + if (!useNames) names(res) <- NULL 389s + res 389s + } 389s > 389s > colMedians_R <- function(x, na.rm = FALSE, ..., useNames = TRUE) { 389s + res <- apply(x, MARGIN = 2L, FUN = median, na.rm = na.rm) 389s + if (!useNames) names(res) <- NULL 389s + res 389s + } 389s > 389s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 389s > # Special case: Non-ties 389s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 389s > cat("Special case: Non-ties:\n") 389s Special case: Non-ties: 389s > for (mode in c("integer", "double")) { 389s + x <- matrix(1:9 + 0.1, nrow = 3, ncol = 3) 389s + storage.mode(x) <- mode 389s + 389s + # To check names attribute 389s + dimnames <- list(letters[1:3], LETTERS[1:3]) 389s + 389s + # Test with and without dimnames on x 389s + for (setDimnames in c(TRUE, FALSE)) { 389s + if (setDimnames) dimnames(x) <- dimnames 389s + else dimnames(x) <- NULL 389s + # Check names attribute 389s + for (useNames in c(TRUE, FALSE)) { 389s + y0 <- rowMedians_R(x, na.rm = FALSE, useNames = useNames) 389s + y1 <- rowMedians(x, na.rm = FALSE, useNames = useNames) 389s + stopifnot(all.equal(y1, y0)) 389s + 389s + y0 <- colMedians_R(x, na.rm = FALSE, useNames = useNames) 389s + y1 <- colMedians(x, na.rm = FALSE, useNames = useNames) 389s + stopifnot(all.equal(y1, y0)) 389s + } 389s + } 389s + } 389s > 389s > 389s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 389s > # Special case: Ties 389s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 389s > cat("Special case: Ties:\n") 389s Special case: Ties: 389s > for (mode in c("integer", "double")) { 389s + x <- matrix(1:16 + 0.1, nrow = 4, ncol = 4) 389s + storage.mode(x) <- mode 389s + 389s + # To check names attribute 389s + dimnames <- list(letters[1:4], LETTERS[1:4]) 389s + 389s + # Test with and without dimnames on x 389s + for (setDimnames in c(TRUE, FALSE)) { 389s + if (setDimnames) dimnames(x) <- dimnames 389s + else dimnames(x) <- NULL 389s + # Check names attribute 389s + for (useNames in c(TRUE, FALSE)) { 389s + y0 <- rowMedians_R(x, na.rm = FALSE, useNames = useNames) 389s + y1 <- rowMedians(x, na.rm = FALSE, useNames = useNames) 389s + stopifnot(all.equal(y1, y0)) 389s + 389s + y0 <- colMedians_R(x, na.rm = FALSE, useNames = useNames) 389s + y1 <- colMedians(x, na.rm = FALSE, useNames = useNames) 389s + stopifnot(all.equal(y1, y0)) 389s + } 389s + } 389s + } 389s > 389s > 389s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 389s > # Special case: Single-element matrix 389s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 389s > cat("Special case: Single-element matrix:\n") 389s Special case: Single-element matrix: 389s > for (mode in c("integer", "double")) { 389s + x <- matrix(1, nrow = 1, ncol = 1) 389s + storage.mode(x) <- mode 389s + 389s + # To check names attribute 389s + dimnames <- list("a", "A") 389s + 389s + # Test with and without dimnames on x 389s + for (setDimnames in c(TRUE, FALSE)) { 389s + if (setDimnames) dimnames(x) <- dimnames 389s + else dimnames(x) <- NULL 389s + # Check names attribute 389s + for (useNames in c(TRUE, FALSE)) { 389s + y0 <- rowMedians_R(x, na.rm = FALSE, useNames = useNames) 389s + y1 <- rowMedians(x, na.rm = FALSE, useNames = useNames) 389s + stopifnot(all.equal(y1, y0)) 389s + 389s + y0 <- colMedians_R(x, na.rm = FALSE, useNames = useNames) 389s + y1 <- colMedians(x, na.rm = FALSE, useNames = useNames) 389s + stopifnot(all.equal(y1, y0)) 389s + } 389s + } 389s + } 389s > 389s > 389s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 389s > # Special case: Empty matrix 389s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 389s > cat("Special case: Empty matrix:\n") 389s Special case: Empty matrix: 389s > for (mode in c("integer", "double")) { 389s + x <- matrix(integer(0), nrow = 0, ncol = 0) 389s + storage.mode(x) <- mode 389s + 389s + y0 <- rowMedians_R(x, na.rm = FALSE) 389s + y1 <- rowMedians(x, na.rm = FALSE) 389s + stopifnot(all.equal(y1, y0)) 389s + 389s + y0 <- colMedians_R(x, na.rm = FALSE) 389s + y1 <- colMedians(x, na.rm = FALSE) 389s + stopifnot(all.equal(y1, y0)) 389s + } 390s > 390s > 390s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 390s > # Special case: All NAs 390s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 390s > cat("Special case: All NAs:\n") 390s Special case: All NAs: 390s > for (mode in c("integer", "double")) { 390s + x <- matrix(NA_integer_, nrow = 3, ncol = 3) 390s + storage.mode(x) <- mode 390s + 390s + # To check names attribute 390s + dimnames <- list(letters[1:3], LETTERS[1:3]) 390s + 390s + # Test with and without dimnames on x 390s + for (setDimnames in c(TRUE, FALSE)) { 390s + if (setDimnames) dimnames(x) <- dimnames 390s + else dimnames(x) <- NULL 390s + # Check names attribute 390s + for (useNames in c(TRUE, FALSE)) { 390s + y0 <- rowMedians_R(x, na.rm = TRUE, useNames = useNames) 390s + y1 <- rowMedians(x, na.rm = TRUE, useNames = useNames) 390s + stopifnot(all.equal(y1, y0)) 390s + 390s + y0 <- colMedians_R(x, na.rm = TRUE, useNames = useNames) 390s + y1 <- colMedians(x, na.rm = TRUE, useNames = useNames) 390s + stopifnot(all.equal(y1, y0)) 390s + } 390s + } 390s + } 390s > 390s > 390s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 390s > # Special case: All NaNs 390s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 390s > cat("Special case: All NaNs:\n") 390s Special case: All NaNs: 390s > x <- matrix(NA_real_, nrow = 3, ncol = 3) 390s > 390s > # Test with and without dimnames on x 390s > for (setDimnames in c(TRUE, FALSE)) { 390s + if (setDimnames) dimnames(x) <- dimnames 390s + else dimnames(x) <- NULL 390s + # Check names attribute 390s + for (useNames in c(TRUE, FALSE)) { 390s + y0 <- rowMedians_R(x, na.rm = TRUE, useNames = useNames) 390s + y1 <- rowMedians(x, na.rm = TRUE, useNames = useNames) 390s + stopifnot(all.equal(y1, y0)) 390s + 390s + y0 <- colMedians_R(x, na.rm = TRUE, useNames = useNames) 390s + y1 <- colMedians(x, na.rm = TRUE, useNames = useNames) 390s + stopifnot(all.equal(y1, y0)) 390s + } 390s + } 390s > 390s > 390s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 390s > # Special case: All Infs 390s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 390s > cat("Special case: All Infs:\n") 390s Special case: All Infs: 390s > x <- matrix(Inf, nrow = 3, ncol = 3) 390s > 390s > # Test with and without dimnames on x 390s > for (setDimnames in c(TRUE, FALSE)) { 390s + if (setDimnames) dimnames(x) <- dimnames 390s + else dimnames(x) <- NULL 390s + # Check names attribute 390s + for (useNames in c(TRUE, FALSE)) { 390s + y0 <- rowMedians_R(x, na.rm = FALSE, useNames = useNames) 390s + y1 <- rowMedians(x, na.rm = FALSE, useNames = useNames) 390s + stopifnot(all.equal(y1, y0)) 390s + 390s + y0 <- colMedians_R(x, na.rm = FALSE, useNames = useNames) 390s + y1 <- colMedians(x, na.rm = FALSE, useNames = useNames) 390s + stopifnot(all.equal(y1, y0)) 390s + } 390s + } 390s > 390s > 390s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 390s > # Special case: All -Infs 390s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 390s > cat("Special case: All -Infs:\n") 390s Special case: All -Infs: 390s > x <- matrix(-Inf, nrow = 3, ncol = 3) 390s > 390s > # Test with and without dimnames on x 390s > for (setDimnames in c(TRUE, FALSE)) { 390s + if (setDimnames) dimnames(x) <- dimnames 390s + else dimnames(x) <- NULL 390s + # Check names attribute 390s + for (useNames in c(TRUE, FALSE)) { 390s + y0 <- rowMedians_R(x, na.rm = FALSE, useNames = useNames) 390s + y1 <- rowMedians(x, na.rm = FALSE, useNames = useNames) 390s + stopifnot(all.equal(y1, y0)) 390s + 390s + y0 <- colMedians_R(x, na.rm = FALSE, useNames = useNames) 390s + y1 <- colMedians(x, na.rm = FALSE, useNames = useNames) 390s + stopifnot(all.equal(y1, y0)) 390s + } 390s + } 390s > 390s > 390s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 390s > # Special case: Infs and -Infs 390s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 390s > cat("Special case: Infs and -Infs:\n") 390s Special case: Infs and -Infs: 390s > x <- matrix(c(-Inf, +Inf), nrow = 4, ncol = 4) 390s > 390s > # To check names attribute 390s > dimnames <- list(letters[1:4], LETTERS[1:4]) 390s > 390s > # Test with and without dimnames on x 390s > for (setDimnames in c(TRUE, FALSE)) { 390s + if (setDimnames) dimnames(x) <- dimnames 390s + else dimnames(x) <- NULL 390s + # Check names attribute 390s + for (useNames in c(TRUE, FALSE)) { 390s + y0 <- rowMedians_R(x, na.rm = FALSE, useNames = useNames) 390s + y1 <- rowMedians(x, na.rm = FALSE, useNames = useNames) 390s + stopifnot(all.equal(y1, y0)) 390s + 390s + y0 <- colMedians_R(x, na.rm = FALSE, useNames = useNames) 390s + y1 <- colMedians(x, na.rm = FALSE, useNames = useNames) 390s + stopifnot(all.equal(y1, y0)) 390s + } 390s + } 390s > 390s > 390s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 390s > # Special case: Integer overflow with ties 390s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 390s > cat("Special case: Integer overflow with ties:\n") 390s Special case: Integer overflow with ties: 390s > x <- matrix(.Machine$integer.max, nrow = 4, ncol = 4) 390s > 390s > # Test with and without dimnames on x 390s > for (setDimnames in c(TRUE, FALSE)) { 390s + if (setDimnames) dimnames(x) <- dimnames 390s + else dimnames(x) <- NULL 390s + # Check names attribute 390s + for (useNames in c(TRUE, FALSE)) { 390s + y0 <- rowMedians_R(x, na.rm = FALSE, useNames = useNames) 390s + y1 <- rowMedians(x, na.rm = FALSE, useNames = useNames) 390s + stopifnot(all.equal(y1, y0)) 390s + 390s + y0 <- colMedians_R(x, na.rm = FALSE, useNames = useNames) 390s + y1 <- colMedians(x, na.rm = FALSE, useNames = useNames) 390s + stopifnot(all.equal(y1, y0)) 390s + } 390s + } 390s > 390s > 390s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 390s > # Consistency checks 390s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 390s > set.seed(1) 390s > 390s > cat("Consistency checks:\n") 390s Consistency checks: 390s > n_sims <- if (Sys.getenv("_R_CHECK_USE_VALGRIND_") != "") 4L else 20L 390s > for (kk in seq_len(n_sims)) { 390s + cat("Random test #", kk, "\n", sep = "") 390s + 390s + # Simulate data in a matrix of any shape 390s + dim <- sample(50:200, size = 2) 390s + n <- prod(dim) 390s + x <- rnorm(n, sd = 100) 390s + dim(x) <- dim 390s + 390s + # Add NAs? 390s + if ((kk %% 4) %in% c(3, 0)) { 390s + cat("Adding NAs\n") 390s + nna <- sample(n, size = 1) 390s + na_values <- c(NA_real_, NaN) 390s + t <- sample(na_values, size = nna, replace = TRUE) 390s + x[sample(length(x), size = nna)] <- t 390s + } 390s + 390s + # Integer or double? 390s + if ((kk %% 4) %in% c(2, 0)) { 390s + cat("Coercing to integers\n") 390s + storage.mode(x) <- "integer" 390s + } 390s + 390s + na.rm <- sample(c(TRUE, FALSE), size = 1) 390s + 390s + # rowMedians(): 390s + y0 <- rowMedians_R(x, na.rm = na.rm) 390s + y1 <- rowMedians(x, na.rm = na.rm) 390s + stopifnot(all.equal(y1, y0)) 390s + y2 <- colMedians(t(x), na.rm = na.rm) 390s + stopifnot(all.equal(y2, y0)) 390s + 390s + # colMedians(): 390s + y0 <- colMedians_R(x, na.rm = na.rm) 390s + y1 <- colMedians(x, na.rm = na.rm) 390s + stopifnot(all.equal(y1, y0)) 390s + y2 <- rowMedians(t(x), na.rm = na.rm) 390s + stopifnot(all.equal(y2, y0)) 390s + } # for (kk ...) 390s Random test #1 390s Random test #2 390s Coercing to integers 390s Random test #3 390s Adding NAs 390s Random test #4 390s Adding NAs 390s Coercing to integers 390s Random test #5 390s Random test #6 390s Coercing to integers 390s Random test #7 390s Adding NAs 390s Random test #8 390s Adding NAs 390s Coercing to integers 390s Random test #9 390s Random test #10 390s Coercing to integers 390s Random test #11 390s Adding NAs 390s Random test #12 390s Adding NAs 390s Coercing to integers 390s Random test #13 390s Random test #14 390s Coercing to integers 390s Random test #15 390s Adding NAs 390s Random test #16 390s Adding NAs 390s Coercing to integers 390s Random test #17 390s Random test #18 390s Coercing to integers 390s Random test #19 390s Adding NAs 390s Random test #20 390s Adding NAs 390s Coercing to integers 390s > 390s 390s R version 4.4.3 (2025-02-28) -- "Trophy Case" 390s Copyright (C) 2025 The R Foundation for Statistical Computing 390s Platform: arm-unknown-linux-gnueabihf (32-bit) 390s 390s R is free software and comes with ABSOLUTELY NO WARRANTY. 390s You are welcome to redistribute it under certain conditions. 390s Type 'license()' or 'licence()' for distribution details. 390s 390s R is a collaborative project with many contributors. 390s Type 'contributors()' for more information and 390s 'citation()' on how to cite R or R packages in publications. 390s 390s Type 'demo()' for some demos, 'help()' for on-line help, or 390s 'help.start()' for an HTML browser interface to help. 390s Type 'q()' to quit R. 390s 390s > library("matrixStats") 390s > 390s > rowMedians_R <- function(x, na.rm = FALSE, ..., useNames = TRUE) { 390s + res <- apply(x, MARGIN = 1L, FUN = median, na.rm = na.rm) 390s + if (!useNames) names(res) <- NULL 390s + res 390s + } 390s > 390s > colMedians_R <- function(x, na.rm = FALSE, ..., useNames = TRUE) { 390s + res <- apply(x, MARGIN = 2L, FUN = median, na.rm = na.rm) 390s + if (!useNames) names(res) <- NULL 390s + res 390s + } 390s > 390s > 390s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 390s > # Subsetted tests 390s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 390s > source("utils/validateIndicesFramework.R") 390s > x <- matrix(runif(6 * 6, min = -3, max = 3), nrow = 6, ncol = 6) 390s > storage.mode(x) <- "integer" 390s > 390s > # To check names attribute 390s > dimnames <- list(letters[1:6], LETTERS[1:6]) 390s > 390s > # Test with and without dimnames on x 390s > for (setDimnames in c(TRUE, FALSE)) { 390s + if (setDimnames) dimnames(x) <- dimnames 390s + else dimnames(x) <- NULL 390s + 390s + count <- 0L 390s + for (rows in index_cases) { 390s + for (cols in index_cases) { 390s + count <- count + 1L 390s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 390s + useNames <- c(TRUE, FALSE) 390s + useNames <- useNames[count %% length(useNames) + 1] 390s + 390s + validateIndicesTestMatrix(x, rows, cols, 390s + ftest = rowMedians, fsure = rowMedians_R, 390s + na.rm = na.rm, useNames = useNames) 390s + validateIndicesTestMatrix(x, rows, cols, 390s + fcoltest = colMedians, fsure = rowMedians_R, 390s + na.rm = na.rm, useNames = useNames) 390s + } 390s + } 390s + } 391s > 391s 391s R version 4.4.3 (2025-02-28) -- "Trophy Case" 391s Copyright (C) 2025 The R Foundation for Statistical Computing 391s Platform: arm-unknown-linux-gnueabihf (32-bit) 391s 391s R is free software and comes with ABSOLUTELY NO WARRANTY. 391s You are welcome to redistribute it under certain conditions. 391s Type 'license()' or 'licence()' for distribution details. 391s 391s R is a collaborative project with many contributors. 391s Type 'contributors()' for more information and 391s 'citation()' on how to cite R or R packages in publications. 391s 391s Type 'demo()' for some demos, 'help()' for on-line help, or 391s 'help.start()' for an HTML browser interface to help. 391s Type 'q()' to quit R. 391s 391s > library("matrixStats") 391s > library("stats") 391s > 391s > asWhich <- function(probs, max) { 391s + idx <- as.integer(round(probs * max)) 391s + if (idx < 1L) { 391s + idx <- 1L 391s + } else if (idx > max) { 391s + idx <- max 391s + } 391s + idx 391s + } # asWhich() 391s > 391s > rowOrderStats_R <- function(x, probs, ..., useNames = TRUE) { 391s + ans <- apply(x, MARGIN = 1L, FUN = quantile, probs = probs, type = 3L) 391s + 391s + # Remove Attributes 391s + if (!useNames || length(ans) == 0L) attributes(ans) <- NULL 391s + ans 391s + } # rowOrderStats_R() 391s > 391s > 391s > set.seed(1) 391s > 391s > 391s > # Simulate data in a matrix of any shape 391s > nrow <- 60L 391s > ncol <- 30L 391s > x <- rnorm(nrow * ncol) 391s > dim(x) <- c(nrow, ncol) 391s > probs <- 0.3 391s > which <- asWhich(probs, max = ncol) 391s > 391s > y0 <- rowOrderStats_R(x, probs = probs) 391s > y1 <- rowOrderStats(x, which = which) 391s > stopifnot(all.equal(y1, y0)) 391s > y2 <- colOrderStats(t(x), which = which) 391s > stopifnot(all.equal(y2, y0)) 391s > 391s > 391s > 391s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 391s > # Consistency checks 391s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 391s > for (mode in c("integer", "double")) { 391s + cat("Consistency checks without NAs:\n") 391s + for (kk in 1:3) { 391s + cat("Random test #", kk, "\n", sep = "") 391s + 391s + # Simulate data in a matrix of any shape 391s + nrow <- sample(20L, size = 1L) 391s + ncol <- sample(20L, size = 1L) 391s + x <- rnorm(nrow * ncol) 391s + dim(x) <- c(nrow, ncol) 391s + 391s + cat("mode: ", mode, "\n", sep = "") 391s + storage.mode(x) <- mode 391s + str(x) 391s + 391s + probs <- runif(1) 391s + which <- asWhich(probs, max = ncol) 391s + 391s + y0 <- rowOrderStats_R(x, probs = probs) 391s + y1 <- rowOrderStats(x, which = which) 391s + stopifnot(all.equal(y1, y0)) 391s + y2 <- colOrderStats(t(x), which = which) 391s + stopifnot(all.equal(y2, y0)) 391s + } # for (kk in ...) 391s + } # for (mode ...) 391s Consistency checks without NAs: 391s Random test #1 391s mode: integer 391s int [1:14, 1:6] 0 0 1 0 2 -1 1 0 0 0 ... 391s Random test #2 391s mode: integer 391s int [1:8, 1:13] 0 0 1 -2 0 0 0 0 1 0 ... 391s Random test #3 391s mode: integer 391s int [1:20, 1:17] 0 0 0 0 1 0 1 0 0 -1 ... 391s Consistency checks without NAs: 391s Random test #1 391s mode: double 391s num [1:9, 1:5] -1.4286 -0.00386 -0.70456 -0.29242 -0.49607 ... 391s Random test #2 391s mode: double 391s num [1:11, 1:20] -0.796 0.482 -0.952 0.5 1.242 ... 391s Random test #3 391s mode: double 391s num [1:7, 1:18] 1.553 -2.405 0.167 -0.403 -1.746 ... 391s > 391s > 391s > # Check names attribute 391s > x <- matrix(1:9 + 0.1, nrow = 3L, ncol = 3L) 391s > 391s > probs <- runif(1) 391s > which <- asWhich(probs, max = ncol(x)) 391s > 391s > dimnames <- list(letters[1:3], LETTERS[1:3]) 391s > 391s > # Test with and without dimnames on x 391s > for (setDimnames in c(TRUE, FALSE)) { 391s + if (setDimnames) dimnames(x) <- dimnames 391s + else dimnames(x) <- NULL 391s + # Check names attribute 391s + for (useNames in c(TRUE, FALSE)) { 391s + y0 <- rowOrderStats_R(x, probs = probs, useNames = useNames) 391s + y1 <- rowOrderStats(x, which = which, useNames = useNames) 391s + stopifnot(all.equal(y1, y0)) 391s + y2 <- colOrderStats(t(x), which = which, useNames = useNames) 391s + stopifnot(all.equal(y2, y0)) 391s + } 391s + } 391s > 391s 391s R version 4.4.3 (2025-02-28) -- "Trophy Case" 391s Copyright (C) 2025 The R Foundation for Statistical Computing 391s Platform: arm-unknown-linux-gnueabihf (32-bit) 391s 391s R is free software and comes with ABSOLUTELY NO WARRANTY. 391s You are welcome to redistribute it under certain conditions. 391s Type 'license()' or 'licence()' for distribution details. 391s 391s R is a collaborative project with many contributors. 391s Type 'contributors()' for more information and 391s 'citation()' on how to cite R or R packages in publications. 391s 391s Type 'demo()' for some demos, 'help()' for on-line help, or 391s 'help.start()' for an HTML browser interface to help. 391s Type 'q()' to quit R. 391s 392s > library("matrixStats") 392s > 392s > rowOrderStats_R <- function(x, probs, ..., useNames = TRUE) { 392s + ans <- apply(x, MARGIN = 1L, FUN = quantile, probs = probs, type = 3L) 392s + 392s + # Remove Attributes 392s + if (!useNames || length(ans) == 0L) attributes(ans) <- NULL 392s + ans 392s + } # rowOrderStats_R() 392s > 392s > 392s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 392s > # Subsetted tests 392s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 392s > source("utils/validateIndicesFramework.R") 392s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 392s > storage.mode(x) <- "integer" 392s > 392s > # To check names attribute 392s > dimnames <- list(letters[1:6], LETTERS[1:6]) 392s > 392s > probs <- 0.3 392s > # Test with and without dimnames on x 392s > for (setDimnames in c(TRUE, FALSE)) { 392s + if (setDimnames) dimnames(x) <- dimnames 392s + else dimnames(x) <- NULL 392s + for (rows in index_cases) { 392s + for (cols in index_cases) { 392s + # Check names attribute 392s + for (useNames in c(TRUE, FALSE)) { 392s + if (is.null(cols)) which <- round(probs * ncol(x)) 392s + else { 392s + xxrows <- rows 392s + suppressWarnings({ 392s + xx <- tryCatch(x[, cols, drop = FALSE], error = function(c) "error") 392s + if (identical(xx, "error")) which <- 0L 392s + else which <- round(probs * ncol(xx)) 392s + }) 392s + } 392s + if (which == 0L) next 392s + 392s + validateIndicesTestMatrix(x, rows, cols, 392s + ftest = rowOrderStats, fsure = rowOrderStats_R, 392s + which = which, probs = probs, useNames = useNames) 392s + validateIndicesTestMatrix(x, rows, cols, 392s + fcoltest = colOrderStats, fsure = rowOrderStats_R, 392s + which = which, probs = probs, useNames = useNames) 392s + } 392s + } 392s + } 392s + } 394s > 394s 394s R version 4.4.3 (2025-02-28) -- "Trophy Case" 394s Copyright (C) 2025 The R Foundation for Statistical Computing 394s Platform: arm-unknown-linux-gnueabihf (32-bit) 394s 394s R is free software and comes with ABSOLUTELY NO WARRANTY. 394s You are welcome to redistribute it under certain conditions. 394s Type 'license()' or 'licence()' for distribution details. 394s 394s R is a collaborative project with many contributors. 394s Type 'contributors()' for more information and 394s 'citation()' on how to cite R or R packages in publications. 394s 394s Type 'demo()' for some demos, 'help()' for on-line help, or 394s 'help.start()' for an HTML browser interface to help. 394s Type 'q()' to quit R. 394s 394s > library("matrixStats") 394s > 394s > rowProds_R <- function(x, FUN = prod, na.rm = FALSE, ..., useNames = TRUE) { 394s + res <- apply(x, MARGIN = 1L, FUN = FUN, na.rm = na.rm) 394s + if (!useNames) names(res) <- NULL 394s + res 394s + } 394s > 394s > all.equal.na <- function(target, current, ...) { 394s + # Computations involving NaN may return NaN or NA, cf. ?is.nan 394s + current[is.nan(current)] <- NA_real_ 394s + target[is.nan(target)] <- NA_real_ 394s + all.equal(target, current, ...) 394s + } 394s > 394s > for (mode in c("integer", "double")) { 394s + # Missing values 394s + x <- matrix(c(1, NA, NaN, 1, 1, 0, 1, 0), nrow = 4, ncol = 2) 394s + cat("mode: ", mode, "\n", sep = "") 394s + storage.mode(x) <- mode 394s + str(x) 394s + 394s + # To check names attribute 394s + dimnames <- list(letters[1:4], LETTERS[1:2]) 394s + 394s + # Test with and without dimnames on x 394s + for (setDimnames in c(TRUE, FALSE)) { 394s + if (setDimnames) dimnames(x) <- dimnames 394s + else dimnames(x) <- NULL 394s + # Check names attribute 394s + for (useNames in c(TRUE, FALSE)) { 394s + y0 <- rowProds_R(x, na.rm = TRUE, useNames = useNames) 394s + print(y0) 394s + y1 <- rowProds(x, na.rm = TRUE, useNames = useNames) 394s + print(y1) 394s + y2 <- colProds(t(x), na.rm = TRUE, useNames = useNames) 394s + print(y2) 394s + stopifnot(all.equal(y1, y0)) 394s + stopifnot(all.equal(y2, y1)) 394s + 394s + # Missing values 394s + y0 <- rowProds_R(x, na.rm = FALSE, useNames = useNames) 394s + print(y0) 394s + y1 <- rowProds(x, na.rm = FALSE, useNames = useNames) 394s + print(y1) 394s + y2 <- colProds(t(x), na.rm = FALSE, useNames = useNames) 394s + print(y2) 394s + stopifnot(all.equal(y1, y0)) 394s + stopifnot(all.equal(y2, y1)) 394s + 394s + # "Empty" rows 394s + y0 <- rowProds_R(x[integer(0), , drop = FALSE], na.rm = FALSE, useNames = useNames) 394s + print(y0) 394s + y1 <- rowProds(x[integer(0), , drop = FALSE], na.rm = FALSE, useNames = useNames) 394s + print(y1) 394s + y2 <- colProds(t(x[integer(0), , drop = FALSE]), na.rm = FALSE, useNames = useNames) 394s + print(y2) 394s + stopifnot(all.equal.na(y1, y0)) 394s + stopifnot(all.equal(y2, y1)) 394s + stopifnot(length(y1) == 0L) 394s + 394s + # Using product() 394s + y1 <- rowProds(x, method = "expSumLog", na.rm = FALSE, useNames = useNames) 394s + print(y1) 394s + y2 <- colProds(t(x), method = "expSumLog", na.rm = FALSE, useNames = useNames) 394s + print(y2) 394s + stopifnot(all.equal(y2, y1)) 394s + } 394s + } 394s + } # for (mode ...) 394s mode: integer 394s int [1:4, 1:2] 1 NA NA 1 1 0 1 0 394s a b c d 394s 1 0 1 0 394s a b c d 394s 1 0 1 0 394s a b c d 394s 1 0 1 0 394s a b c d 394s 1 NA NA 0 394s a b c d 394s 1 NA NA 0 394s a b c d 394s 1 NA NA 0 394s numeric(0) 394s numeric(0) 394s numeric(0) 394s a b c d 394s 1 NA NA 0 394s a b c d 394s 1 NA NA 0 394s [1] 1 0 1 0 394s [1] 1 0 1 0 394s [1] 1 0 1 0 394s [1] 1 NA NA 0 394s [1] 1 NA NA 0 394s [1] 1 NA NA 0 394s numeric(0) 394s numeric(0) 394s numeric(0) 394s [1] 1 NA NA 0 394s [1] 1 NA NA 0 394s [1] 1 0 1 0 394s [1] 1 0 1 0 394s [1] 1 0 1 0 394s [1] 1 NA NA 0 394s [1] 1 NA NA 0 394s [1] 1 NA NA 0 394s numeric(0) 394s numeric(0) 394s numeric(0) 394s [1] 1 NA NA 0 394s [1] 1 NA NA 0 394s [1] 1 0 1 0 394s [1] 1 0 1 0 394s [1] 1 0 1 0 394s [1] 1 NA NA 0 394s [1] 1 NA NA 0 394s [1] 1 NA NA 0 394s numeric(0) 394s numeric(0) 394s numeric(0) 394s [1] 1 NA NA 0 394s [1] 1 NA NA 0 394s mode: double 394s num [1:4, 1:2] 1 NA NaN 1 1 0 1 0 394s a b c d 394s 1 0 1 0 394s a b c d 394s 1 0 1 0 394s a b c d 394s 1 0 1 0 394s a b c d 394s 1 NA NaN 0 394s a b c d 394s 1 NA NaN 0 394s a b c d 394s 1 NA NaN 0 394s numeric(0) 394s numeric(0) 394s numeric(0) 394s a b c d 394s 1 NA NA 0 394s a b c d 394s 1 NA NA 0 394s [1] 1 0 1 0 394s [1] 1 0 1 0 394s [1] 1 0 1 0 394s [1] 1 NA NaN 0 394s [1] 1 NA NaN 0 394s [1] 1 NA NaN 0 394s numeric(0) 394s numeric(0) 394s numeric(0) 394s [1] 1 NA NA 0 394s [1] 1 NA NA 0 394s [1] 1 0 1 0 394s [1] 1 0 1 0 394s [1] 1 0 1 0 394s [1] 1 NA NaN 0 394s [1] 1 NA NaN 0 394s [1] 1 NA NaN 0 394s numeric(0) 394s numeric(0) 394s numeric(0) 394s [1] 1 NA NA 0 394s [1] 1 NA NA 0 394s [1] 1 0 1 0 394s [1] 1 0 1 0 394s [1] 1 0 1 0 394s [1] 1 NA NaN 0 394s [1] 1 NA NaN 0 394s [1] 1 NA NaN 0 394s numeric(0) 394s numeric(0) 394s numeric(0) 394s [1] 1 NA NA 0 394s [1] 1 NA NA 0 394s > 394s > 394s > # Bug report 2012-06-25 394s > x <- matrix(c(1, 1, 1, 1, 1, 0, 1, 0), nrow = 4, ncol = 2) 394s > y0 <- rowProds_R(x) 394s > print(y0) 394s [1] 1 0 1 0 394s > y1 <- rowProds(x) 394s > print(y1) 394s [1] 1 0 1 0 394s > y2 <- colProds(t(x)) 394s > print(y2) 394s [1] 1 0 1 0 394s > stopifnot(all.equal.na(y1, y0)) 394s > stopifnot(all.equal.na(y1, x[, 1] * x[, 2])) 394s > stopifnot(all.equal.na(y2, y1)) 394s > # Check names attribute 394s > dimnames(x) <- dimnames 394s > y0 <- rowProds_R(x, useNames = TRUE) 394s > print(y0) 394s a b c d 394s 1 0 1 0 394s > y1 <- rowProds(x, useNames = TRUE) 394s > print(y1) 394s a b c d 394s 1 0 1 0 394s > y2 <- colProds(t(x), useNames = TRUE) 394s > print(y2) 394s a b c d 394s 1 0 1 0 394s > stopifnot(all.equal.na(y1, y0)) 394s > stopifnot(all.equal.na(y1, x[, 1] * x[, 2])) 394s > stopifnot(all.equal.na(y2, y1)) 394s > 394s > # Bug report 2014-03-25 ("all rows contains a zero") 394s > x <- matrix(c(0, 1, 1, 0), nrow = 2, ncol = 2) 394s > # To check names attribute 394s > dimnames <- list(letters[1:2], LETTERS[1:2]) 394s > y0 <- rowProds_R(x) 394s > print(y0) 394s [1] 0 0 394s > y1 <- rowProds(x) 394s > print(y1) 394s [1] 0 0 394s > y2 <- colProds(t(x)) 394s > print(y2) 394s [1] 0 0 394s > stopifnot(all.equal.na(y1, y0)) 394s > stopifnot(all.equal.na(y1, c(0, 0))) 394s > stopifnot(all.equal.na(y2, y1)) 394s > # Check names attribute 394s > dimnames(x) <- dimnames 394s > y0 <- rowProds_R(x, useNames = TRUE) 394s > print(y0) 394s a b 394s 0 0 394s > y1 <- rowProds(x, useNames = TRUE) 394s > print(y1) 394s a b 394s 0 0 394s > y2 <- colProds(t(x), useNames = TRUE) 394s > print(y2) 394s a b 394s 0 0 394s > stopifnot(all.equal.na(y1, y0)) 394s > stopifnot(all.equal.na(y2, y1)) 394s > 394s 394s R version 4.4.3 (2025-02-28) -- "Trophy Case" 394s Copyright (C) 2025 The R Foundation for Statistical Computing 394s Platform: arm-unknown-linux-gnueabihf (32-bit) 394s 394s R is free software and comes with ABSOLUTELY NO WARRANTY. 394s You are welcome to redistribute it under certain conditions. 394s Type 'license()' or 'licence()' for distribution details. 394s 394s R is a collaborative project with many contributors. 394s Type 'contributors()' for more information and 394s 'citation()' on how to cite R or R packages in publications. 394s 394s Type 'demo()' for some demos, 'help()' for on-line help, or 394s 'help.start()' for an HTML browser interface to help. 394s Type 'q()' to quit R. 394s 394s > library("matrixStats") 395s > 395s > rowProds_R <- function(x, FUN = prod, na.rm = FALSE, ..., useNames = TRUE) { 395s + res <- apply(x, MARGIN = 1L, FUN = FUN, na.rm = na.rm) 395s + if (!useNames) names(res) <- NULL 395s + res 395s + } 395s > 395s > 395s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 395s > # Subsetted tests 395s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 395s > source("utils/validateIndicesFramework.R") 395s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 395s > storage.mode(x) <- "integer" 395s > 395s > # To check names attribute 395s > dimnames <- list(letters[1:6], LETTERS[1:6]) 395s > 395s > # Test with and without dimnames on x 395s > for (setDimnames in c(TRUE, FALSE)) { 395s + if (setDimnames) dimnames(x) <- dimnames 395s + else dimnames(x) <- NULL 395s + for (rows in index_cases) { 395s + for (cols in index_cases) { 395s + for (na.rm in c(TRUE, FALSE)) { 395s + for (useNames in c(TRUE, FALSE)) { 395s + validateIndicesTestMatrix(x, rows, cols, 395s + ftest = rowProds, fsure = rowProds_R, 395s + method = "expSumLog", 395s + FUN = product, na.rm = na.rm, useNames = useNames) 395s + validateIndicesTestMatrix(x, rows, cols, 395s + fcoltest = colProds, fsure = rowProds_R, 395s + method = "expSumLog", 395s + FUN = product, na.rm = na.rm, useNames = useNames) 395s + } 395s + } 395s + } 395s + } 395s + } 396s > 396s 396s R version 4.4.3 (2025-02-28) -- "Trophy Case" 396s Copyright (C) 2025 The R Foundation for Statistical Computing 396s Platform: arm-unknown-linux-gnueabihf (32-bit) 396s 396s R is free software and comes with ABSOLUTELY NO WARRANTY. 396s You are welcome to redistribute it under certain conditions. 396s Type 'license()' or 'licence()' for distribution details. 396s 396s R is a collaborative project with many contributors. 396s Type 'contributors()' for more information and 396s 'citation()' on how to cite R or R packages in publications. 396s 396s Type 'demo()' for some demos, 'help()' for on-line help, or 396s 'help.start()' for an HTML browser interface to help. 396s Type 'q()' to quit R. 396s 396s > library("matrixStats") 396s > 396s > ## Create isFALSE() if running on an old version of R 396s > if (!exists("isFALSE", mode="function")) { 396s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 396s + } 396s > 396s > rowQuantiles_R <- function(x, probs = c(0, 0.25, 0.50, 0.75, 1), na.rm = FALSE, drop = TRUE, type = 7L, ..., useNames = TRUE) { 396s + q <- apply(x, MARGIN = 1L, FUN = function(x, probs, na.rm) { 396s + if (!na.rm && any(is.na(x))) { 396s + na_value <- NA_real_ 396s + if (type != 7L) storage.mode(na_value) <- storage.mode(x) 396s + rep(na_value, times = length(probs)) 396s + } else { 396s + as.vector(quantile(x, probs = probs, na.rm = na.rm, type = type, names = FALSE, ...)) 396s + } 396s + }, probs = probs, na.rm = na.rm) 396s + 396s + if (!is.null(dim(q))) q <- t(q) 396s + else dim(q) <- c(nrow(x), length(probs)) 396s + 396s + colnames(q) <- matrixStats:::quantile_probs_names(probs) 396s + rownames(q) <- rownames(x) 396s + if (isFALSE(useNames)) dimnames(q) <- NULL 396s + 396s + if (drop) q <- drop(q) 396s + q 396s + } 396s > 396s > 396s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 396s > # Test with multiple quantiles 396s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 396s > for (mode in c("logical", "integer", "double")) { 396s + cat("mode: ", mode, "\n", sep = "") 396s + x <- matrix(1:40 + 0.1, nrow = 8, ncol = 5) 396s + storage.mode(x) <- mode 396s + dimnames <- lapply(dim(x), FUN = function(n) letters[seq_len(n)]) 396s + str(x) 396s + 396s + probs <- c(0, 0.5, 1) 396s + # Test with and without dimnames on x 396s + for (setDimnames in c(TRUE, FALSE)) { 396s + if (setDimnames) dimnames(x) <- dimnames 396s + else dimnames(x) <- NULL 396s + # Check names attribute 396s + for (useNames in c(TRUE, FALSE)) { 396s + q0 <- rowQuantiles_R(x, probs = probs, useNames = useNames) 396s + print(q0) 396s + q1 <- rowQuantiles(x, probs = probs, useNames = useNames) 396s + print(q1) 396s + stopifnot(all.equal(q1, q0)) 396s + q2 <- colQuantiles(t(x), probs = probs, useNames = useNames) 396s + stopifnot(all.equal(q2, q0)) 396s + } 396s + } 396s + } # for (mode ...) 396s mode: logical 396s logi [1:8, 1:5] TRUE TRUE TRUE TRUE TRUE TRUE ... 396s 0% 50% 100% 396s a 1 1 1 396s b 1 1 1 396s c 1 1 1 396s d 1 1 1 396s e 1 1 1 396s f 1 1 1 396s g 1 1 1 396s h 1 1 1 396s 0% 50% 100% 396s a 1 1 1 396s b 1 1 1 396s c 1 1 1 396s d 1 1 1 396s e 1 1 1 396s f 1 1 1 396s g 1 1 1 396s h 1 1 1 396s [,1] [,2] [,3] 396s [1,] 1 1 1 396s [2,] 1 1 1 396s [3,] 1 1 1 396s [4,] 1 1 1 396s [5,] 1 1 1 396s [6,] 1 1 1 396s [7,] 1 1 1 396s [8,] 1 1 1 396s [,1] [,2] [,3] 396s [1,] 1 1 1 396s [2,] 1 1 1 396s [3,] 1 1 1 396s [4,] 1 1 1 396s [5,] 1 1 1 396s [6,] 1 1 1 396s [7,] 1 1 1 396s [8,] 1 1 1 396s 0% 50% 100% 396s [1,] 1 1 1 396s [2,] 1 1 1 396s [3,] 1 1 1 396s [4,] 1 1 1 396s [5,] 1 1 1 396s [6,] 1 1 1 396s [7,] 1 1 1 396s [8,] 1 1 1 396s 0% 50% 100% 396s [1,] 1 1 1 396s [2,] 1 1 1 396s [3,] 1 1 1 396s [4,] 1 1 1 396s [5,] 1 1 1 396s [6,] 1 1 1 396s [7,] 1 1 1 396s [8,] 1 1 1 396s [,1] [,2] [,3] 396s [1,] 1 1 1 396s [2,] 1 1 1 396s [3,] 1 1 1 396s [4,] 1 1 1 396s [5,] 1 1 1 396s [6,] 1 1 1 396s [7,] 1 1 1 396s [8,] 1 1 1 396s [,1] [,2] [,3] 396s [1,] 1 1 1 396s [2,] 1 1 1 396s [3,] 1 1 1 396s [4,] 1 1 1 396s [5,] 1 1 1 396s [6,] 1 1 1 396s [7,] 1 1 1 396s [8,] 1 1 1 396s mode: integer 396s int [1:8, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 396s 0% 50% 100% 396s a 1 17 33 396s b 2 18 34 396s c 3 19 35 396s d 4 20 36 396s e 5 21 37 396s f 6 22 38 396s g 7 23 39 396s h 8 24 40 396s 0% 50% 100% 396s a 1 17 33 396s b 2 18 34 396s c 3 19 35 396s d 4 20 36 396s e 5 21 37 396s f 6 22 38 396s g 7 23 39 396s h 8 24 40 396s [,1] [,2] [,3] 396s [1,] 1 17 33 396s [2,] 2 18 34 396s [3,] 3 19 35 396s [4,] 4 20 36 396s [5,] 5 21 37 396s [6,] 6 22 38 396s [7,] 7 23 39 396s [8,] 8 24 40 396s [,1] [,2] [,3] 396s [1,] 1 17 33 396s [2,] 2 18 34 396s [3,] 3 19 35 396s [4,] 4 20 36 396s [5,] 5 21 37 396s [6,] 6 22 38 396s [7,] 7 23 39 396s [8,] 8 24 40 396s 0% 50% 100% 396s [1,] 1 17 33 396s [2,] 2 18 34 396s [3,] 3 19 35 396s [4,] 4 20 36 396s [5,] 5 21 37 396s [6,] 6 22 38 396s [7,] 7 23 39 396s [8,] 8 24 40 396s 0% 50% 100% 396s [1,] 1 17 33 396s [2,] 2 18 34 396s [3,] 3 19 35 396s [4,] 4 20 36 396s [5,] 5 21 37 396s [6,] 6 22 38 396s [7,] 7 23 39 396s [8,] 8 24 40 396s [,1] [,2] [,3] 396s [1,] 1 17 33 396s [2,] 2 18 34 396s [3,] 3 19 35 396s [4,] 4 20 36 396s [5,] 5 21 37 396s [6,] 6 22 38 396s [7,] 7 23 39 396s [8,] 8 24 40 396s [,1] [,2] [,3] 396s [1,] 1 17 33 396s [2,] 2 18 34 396s [3,] 3 19 35 396s [4,] 4 20 36 396s [5,] 5 21 37 396s [6,] 6 22 38 396s [7,] 7 23 39 396s [8,] 8 24 40 396s mode: double 396s 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 ... 396s 0% 50% 100% 396s a 1.1 17.1 33.1 396s b 2.1 18.1 34.1 396s c 3.1 19.1 35.1 396s d 4.1 20.1 36.1 396s e 5.1 21.1 37.1 396s f 6.1 22.1 38.1 396s g 7.1 23.1 39.1 396s h 8.1 24.1 40.1 396s 0% 50% 100% 396s a 1.1 17.1 33.1 396s b 2.1 18.1 34.1 396s c 3.1 19.1 35.1 396s d 4.1 20.1 36.1 396s e 5.1 21.1 37.1 396s f 6.1 22.1 38.1 396s g 7.1 23.1 39.1 396s h 8.1 24.1 40.1 396s [,1] [,2] [,3] 396s [1,] 1.1 17.1 33.1 396s [2,] 2.1 18.1 34.1 396s [3,] 3.1 19.1 35.1 396s [4,] 4.1 20.1 36.1 396s [5,] 5.1 21.1 37.1 396s [6,] 6.1 22.1 38.1 396s [7,] 7.1 23.1 39.1 396s [8,] 8.1 24.1 40.1 396s [,1] [,2] [,3] 396s [1,] 1.1 17.1 33.1 396s [2,] 2.1 18.1 34.1 396s [3,] 3.1 19.1 35.1 396s [4,] 4.1 20.1 36.1 396s [5,] 5.1 21.1 37.1 396s [6,] 6.1 22.1 38.1 396s [7,] 7.1 23.1 39.1 396s [8,] 8.1 24.1 40.1 396s 0% 50% 100% 396s [1,] 1.1 17.1 33.1 396s [2,] 2.1 18.1 34.1 396s [3,] 3.1 19.1 35.1 396s [4,] 4.1 20.1 36.1 396s [5,] 5.1 21.1 37.1 396s [6,] 6.1 22.1 38.1 396s [7,] 7.1 23.1 39.1 396s [8,] 8.1 24.1 40.1 396s 0% 50% 100% 396s [1,] 1.1 17.1 33.1 396s [2,] 2.1 18.1 34.1 396s [3,] 3.1 19.1 35.1 396s [4,] 4.1 20.1 36.1 396s [5,] 5.1 21.1 37.1 396s [6,] 6.1 22.1 38.1 396s [7,] 7.1 23.1 39.1 396s [8,] 8.1 24.1 40.1 396s [,1] [,2] [,3] 396s [1,] 1.1 17.1 33.1 396s [2,] 2.1 18.1 34.1 396s [3,] 3.1 19.1 35.1 396s [4,] 4.1 20.1 36.1 396s [5,] 5.1 21.1 37.1 396s [6,] 6.1 22.1 38.1 396s [7,] 7.1 23.1 39.1 396s [8,] 8.1 24.1 40.1 396s [,1] [,2] [,3] 396s [1,] 1.1 17.1 33.1 396s [2,] 2.1 18.1 34.1 396s [3,] 3.1 19.1 35.1 396s [4,] 4.1 20.1 36.1 396s [5,] 5.1 21.1 37.1 396s [6,] 6.1 22.1 38.1 396s [7,] 7.1 23.1 39.1 396s [8,] 8.1 24.1 40.1 396s > 396s > 396s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 396s > # Test with a single quantile 396s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 396s > for (mode in c("logical", "integer", "double")) { 396s + cat("mode: ", mode, "\n", sep = "") 396s + x <- matrix(1:40, nrow = 8, ncol = 5) 396s + storage.mode(x) <- mode 396s + dimnames <- lapply(dim(x), FUN = function(n) letters[seq_len(n)]) 396s + str(x) 396s + 396s + probs <- c(0.5) 396s + # Test with and without dimnames on x 396s + for (setDimnames in c(TRUE, FALSE)) { 396s + if (setDimnames) dimnames(x) <- dimnames 396s + else dimnames(x) <- NULL 396s + # Check names attribute 396s + for (useNames in c(TRUE, FALSE)) { 396s + q0 <- rowQuantiles_R(x, probs = probs, useNames = useNames) 396s + print(q0) 396s + q1 <- rowQuantiles(x, probs = probs, useNames = useNames) 396s + print(q1) 396s + stopifnot(all.equal(q1, q0)) 396s + q2 <- colQuantiles(t(x), probs = probs, useNames = useNames) 396s + stopifnot(all.equal(q2, q0)) 396s + } 396s + } 396s + } # for (mode ...) 396s mode: logical 396s logi [1:8, 1:5] TRUE TRUE TRUE TRUE TRUE TRUE ... 396s a b c d e f g h 396s 1 1 1 1 1 1 1 1 396s a b c d e f g h 396s 1 1 1 1 1 1 1 1 396s [1] 1 1 1 1 1 1 1 1 396s [1] 1 1 1 1 1 1 1 1 396s [1] 1 1 1 1 1 1 1 1 396s [1] 1 1 1 1 1 1 1 1 396s [1] 1 1 1 1 1 1 1 1 396s [1] 1 1 1 1 1 1 1 1 396s mode: integer 396s int [1:8, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 396s a b c d e f g h 396s 17 18 19 20 21 22 23 24 396s a b c d e f g h 396s 17 18 19 20 21 22 23 24 396s [1] 17 18 19 20 21 22 23 24 396s [1] 17 18 19 20 21 22 23 24 396s [1] 17 18 19 20 21 22 23 24 396s [1] 17 18 19 20 21 22 23 24 396s [1] 17 18 19 20 21 22 23 24 396s [1] 17 18 19 20 21 22 23 24 396s mode: double 396s num [1:8, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 396s a b c d e f g h 396s 17 18 19 20 21 22 23 24 396s a b c d e f g h 396s 17 18 19 20 21 22 23 24 396s [1] 17 18 19 20 21 22 23 24 396s [1] 17 18 19 20 21 22 23 24 396s [1] 17 18 19 20 21 22 23 24 396s [1] 17 18 19 20 21 22 23 24 396s [1] 17 18 19 20 21 22 23 24 396s [1] 17 18 19 20 21 22 23 24 396s > 396s > 396s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 396s > # Consistency checks 396s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 396s > set.seed(1) 396s > 396s > probs <- seq(from = 0, to = 1, by = 0.25) 396s > 396s > cat("Consistency checks:\n") 396s Consistency checks: 396s > n_sims <- if (Sys.getenv("_R_CHECK_USE_VALGRIND_") != "") 6L else 24L 396s > for (kk in seq_len(n_sims)) { 396s + cat("Random test #", kk, "\n", sep = "") 396s + 396s + # Simulate data in a matrix of any shape 396s + dim <- sample(20:60, size = 2L) 396s + n <- prod(dim) 396s + x <- rnorm(n, sd = 100) 396s + dim(x) <- dim 396s + dimnames <- lapply(dim(x), FUN = function(n) rep(letters, length.out = n)) 396s + 396s + # Add NAs? 396s + has_na <- ((kk %% 2) == 0L) 396s + if (has_na) { 396s + cat("Adding NAs\n") 396s + nna <- sample(n, size = 1) 396s + na_values <- c(NA_real_, NaN) 396s + t <- sample(na_values, size = nna, replace = TRUE) 396s + x[sample(length(x), size = nna)] <- t 396s + } 396s + 396s + # Logical, integer, or double? 396s + mode <- "numeric" 396s + if ((kk %% 6) %in% 1:2) { 396s + cat("Coercing to logical\n") 396s + mode <- "logical" 396s + } else if ((kk %% 6) %in% 3:4) { 396s + cat("Coercing to integers\n") 396s + mode <- "integer" 396s + } 396s + storage.mode(x) <- mode 396s + 396s + str(x) 396s + 396s + # rowQuantiles(): 396s + for (type in 1:9) { 396s + cat(sprintf("type=%d, has_na=%s:\n", type, has_na)) 396s + # Test with and without dimnames on x 396s + for (setDimnames in c(TRUE, FALSE)) { 396s + if (setDimnames) dimnames(x) <- dimnames 396s + else dimnames(x) <- NULL 396s + # Check names attribute 396s + for (useNames in c(TRUE, FALSE)) { 396s + q0 <- rowQuantiles_R(x, probs = probs, na.rm = has_na, type = type, useNames = useNames) 396s + q1 <- rowQuantiles(x, probs = probs, na.rm = has_na, type = type, useNames = useNames) 396s + stopifnot(all.equal(q1, q0)) 396s + q2 <- colQuantiles(t(x), probs = probs, na.rm = has_na, type = type, useNames = useNames) 396s + stopifnot(all.equal(q2, q0)) 396s + } 396s + } 396s + } 396s + } # for (kk ...) 396s Random test #1 396s Coercing to logical 396s logi [1:23, 1:58] TRUE TRUE TRUE TRUE TRUE TRUE ... 396s type=1, has_na=FALSE: 396s type=2, has_na=FALSE: 396s type=3, has_na=FALSE: 396s type=4, has_na=FALSE: 396s type=5, has_na=FALSE: 396s type=6, has_na=FALSE: 396s type=7, has_na=FALSE: 396s type=8, has_na=FALSE: 396s type=9, has_na=FALSE: 396s Random test #2 396s Adding NAs 396s Coercing to logical 396s logi [1:58, 1:33] TRUE TRUE TRUE TRUE TRUE NA ... 396s type=1, has_na=TRUE: 397s type=2, has_na=TRUE: 397s type=3, has_na=TRUE: 397s type=4, has_na=TRUE: 397s type=5, has_na=TRUE: 397s type=6, has_na=TRUE: 397s type=7, has_na=TRUE: 397s type=8, has_na=TRUE: 397s type=9, has_na=TRUE: 397s Random test #3 397s Coercing to integers 397s int [1:28, 1:60] 119 -164 115 -129 209 -175 2 -32 120 -28 ... 397s type=1, has_na=FALSE: 397s type=2, has_na=FALSE: 397s type=3, has_na=FALSE: 397s type=4, has_na=FALSE: 397s type=5, has_na=FALSE: 397s type=6, has_na=FALSE: 397s type=7, has_na=FALSE: 397s type=8, has_na=FALSE: 397s type=9, has_na=FALSE: 398s Random test #4 398s Adding NAs 398s Coercing to integers 398s int [1:54, 1:35] 147 11 116 -50 NA -69 132 NA 114 NA ... 398s type=1, has_na=TRUE: 398s type=2, has_na=TRUE: 398s type=3, has_na=TRUE: 398s type=4, has_na=TRUE: 398s type=5, has_na=TRUE: 398s type=6, has_na=TRUE: 398s type=7, has_na=TRUE: 398s type=8, has_na=TRUE: 398s type=9, has_na=TRUE: 398s Random test #5 398s num [1:39, 1:53] 5.94 -27.16 -30.78 173 126.05 ... 398s type=1, has_na=FALSE: 398s type=2, has_na=FALSE: 398s type=3, has_na=FALSE: 398s type=4, has_na=FALSE: 398s type=5, has_na=FALSE: 398s type=6, has_na=FALSE: 398s type=7, has_na=FALSE: 399s type=8, has_na=FALSE: 399s type=9, has_na=FALSE: 399s Random test #6 399s Adding NAs 399s num [1:46, 1:22] 197 -107 15 148 -110 ... 399s type=1, has_na=TRUE: 399s type=2, has_na=TRUE: 399s type=3, has_na=TRUE: 399s type=4, has_na=TRUE: 399s type=5, has_na=TRUE: 399s type=6, has_na=TRUE: 399s type=7, has_na=TRUE: 399s type=8, has_na=TRUE: 399s type=9, has_na=TRUE: 399s Random test #7 399s Coercing to logical 399s logi [1:21, 1:51] TRUE TRUE TRUE TRUE TRUE TRUE ... 399s type=1, has_na=FALSE: 399s type=2, has_na=FALSE: 399s type=3, has_na=FALSE: 399s type=4, has_na=FALSE: 399s type=5, has_na=FALSE: 399s type=6, has_na=FALSE: 399s type=7, has_na=FALSE: 399s type=8, has_na=FALSE: 399s type=9, has_na=FALSE: 399s Random test #8 399s Adding NAs 399s Coercing to logical 399s logi [1:33, 1:53] NA NA TRUE TRUE TRUE TRUE ... 399s type=1, has_na=TRUE: 399s type=2, has_na=TRUE: 400s type=3, has_na=TRUE: 400s type=4, has_na=TRUE: 400s type=5, has_na=TRUE: 400s type=6, has_na=TRUE: 400s type=7, has_na=TRUE: 400s type=8, has_na=TRUE: 400s type=9, has_na=TRUE: 400s Random test #9 400s Coercing to integers 400s int [1:53, 1:24] -73 10 -73 -5 44 -107 -100 95 58 -50 ... 400s type=1, has_na=FALSE: 400s type=2, has_na=FALSE: 400s type=3, has_na=FALSE: 400s type=4, has_na=FALSE: 400s type=5, has_na=FALSE: 400s type=6, has_na=FALSE: 400s type=7, has_na=FALSE: 400s type=8, has_na=FALSE: 400s type=9, has_na=FALSE: 400s Random test #10 400s Adding NAs 400s Coercing to integers 400s int [1:44, 1:20] NA -140 NA -57 -252 NA NA 20 NA NA ... 400s type=1, has_na=TRUE: 400s type=2, has_na=TRUE: 401s type=3, has_na=TRUE: 401s type=4, has_na=TRUE: 401s type=5, has_na=TRUE: 401s type=6, has_na=TRUE: 401s type=7, has_na=TRUE: 401s type=8, has_na=TRUE: 401s type=9, has_na=TRUE: 401s Random test #11 401s num [1:54, 1:23] -160.87 74.13 196.08 7.27 4.92 ... 401s type=1, has_na=FALSE: 401s type=2, has_na=FALSE: 401s type=3, has_na=FALSE: 401s type=4, has_na=FALSE: 401s type=5, has_na=FALSE: 401s type=6, has_na=FALSE: 401s type=7, has_na=FALSE: 401s type=8, has_na=FALSE: 401s type=9, has_na=FALSE: 402s Random test #12 402s Adding NAs 402s num [1:59, 1:27] -139.2 -86.3 NA -40.7 NA ... 402s type=1, has_na=TRUE: 402s type=2, has_na=TRUE: 402s type=3, has_na=TRUE: 402s type=4, has_na=TRUE: 402s type=5, has_na=TRUE: 402s type=6, has_na=TRUE: 402s type=7, has_na=TRUE: 402s type=8, has_na=TRUE: 402s type=9, has_na=TRUE: 402s Random test #13 402s Coercing to logical 402s logi [1:53, 1:60] TRUE TRUE TRUE TRUE TRUE TRUE ... 402s type=1, has_na=FALSE: 402s type=2, has_na=FALSE: 402s type=3, has_na=FALSE: 402s type=4, has_na=FALSE: 403s type=5, has_na=FALSE: 403s type=6, has_na=FALSE: 403s type=7, has_na=FALSE: 403s type=8, has_na=FALSE: 403s type=9, has_na=FALSE: 403s Random test #14 403s Adding NAs 403s Coercing to logical 403s logi [1:22, 1:57] TRUE TRUE TRUE TRUE TRUE TRUE ... 403s type=1, has_na=TRUE: 403s type=2, has_na=TRUE: 403s type=3, has_na=TRUE: 403s type=4, has_na=TRUE: 403s type=5, has_na=TRUE: 403s type=6, has_na=TRUE: 403s type=7, has_na=TRUE: 403s type=8, has_na=TRUE: 403s type=9, has_na=TRUE: 403s Random test #15 403s Coercing to integers 403s int [1:20, 1:34] 78 -41 183 190 -71 37 0 -4 -86 27 ... 403s type=1, has_na=FALSE: 403s type=2, has_na=FALSE: 403s type=3, has_na=FALSE: 403s type=4, has_na=FALSE: 403s type=5, has_na=FALSE: 403s type=6, has_na=FALSE: 403s type=7, has_na=FALSE: 403s type=8, has_na=FALSE: 403s type=9, has_na=FALSE: 403s Random test #16 403s Adding NAs 403s Coercing to integers 403s int [1:42, 1:37] NA 12 -15 41 -28 17 NA -74 NA NA ... 403s type=1, has_na=TRUE: 403s type=2, has_na=TRUE: 404s type=3, has_na=TRUE: 404s type=4, has_na=TRUE: 404s type=5, has_na=TRUE: 404s type=6, has_na=TRUE: 404s type=7, has_na=TRUE: 404s type=8, has_na=TRUE: 404s type=9, has_na=TRUE: 404s Random test #17 404s num [1:42, 1:29] -50.51 -6.51 -117.59 135.58 226.87 ... 404s type=1, has_na=FALSE: 404s type=2, has_na=FALSE: 404s type=3, has_na=FALSE: 404s type=4, has_na=FALSE: 404s type=5, has_na=FALSE: 404s type=6, has_na=FALSE: 404s type=7, has_na=FALSE: 404s type=8, has_na=FALSE: 404s type=9, has_na=FALSE: 404s Random test #18 404s Adding NAs 404s num [1:57, 1:39] 223 156.8 -44.6 -127.5 -147.7 ... 404s type=1, has_na=TRUE: 404s type=2, has_na=TRUE: 405s type=3, has_na=TRUE: 405s type=4, has_na=TRUE: 405s type=5, has_na=TRUE: 405s type=6, has_na=TRUE: 405s type=7, has_na=TRUE: 405s type=8, has_na=TRUE: 405s type=9, has_na=TRUE: 405s Random test #19 405s Coercing to logical 405s logi [1:52, 1:57] TRUE TRUE TRUE TRUE TRUE TRUE ... 405s type=1, has_na=FALSE: 405s type=2, has_na=FALSE: 405s type=3, has_na=FALSE: 405s type=4, has_na=FALSE: 405s type=5, has_na=FALSE: 405s type=6, has_na=FALSE: 405s type=7, has_na=FALSE: 406s type=8, has_na=FALSE: 406s type=9, has_na=FALSE: 406s Random test #20 406s Adding NAs 406s Coercing to logical 406s logi [1:25, 1:48] NA TRUE NA NA NA NA ... 406s type=1, has_na=TRUE: 406s type=2, has_na=TRUE: 406s type=3, has_na=TRUE: 406s type=4, has_na=TRUE: 406s type=5, has_na=TRUE: 406s type=6, has_na=TRUE: 406s type=7, has_na=TRUE: 406s type=8, has_na=TRUE: 406s type=9, has_na=TRUE: 406s Random test #21 406s Coercing to integers 406s int [1:53, 1:27] 3 -30 203 -49 19 -45 -138 28 46 -44 ... 406s type=1, has_na=FALSE: 406s type=2, has_na=FALSE: 406s type=3, has_na=FALSE: 406s type=4, has_na=FALSE: 406s type=5, has_na=FALSE: 406s type=6, has_na=FALSE: 406s type=7, has_na=FALSE: 406s type=8, has_na=FALSE: 406s type=9, has_na=FALSE: 407s Random test #22 407s Adding NAs 407s Coercing to integers 407s int [1:48, 1:36] -131 NA NA -201 45 -17 NA 57 NA NA ... 407s type=1, has_na=TRUE: 407s type=2, has_na=TRUE: 407s type=3, has_na=TRUE: 407s type=4, has_na=TRUE: 407s type=5, has_na=TRUE: 407s type=6, has_na=TRUE: 407s type=7, has_na=TRUE: 407s type=8, has_na=TRUE: 407s type=9, has_na=TRUE: 407s Random test #23 407s num [1:23, 1:43] -99.2 -68.8 -86.7 -104.2 48 ... 407s type=1, has_na=FALSE: 407s type=2, has_na=FALSE: 407s type=3, has_na=FALSE: 407s type=4, has_na=FALSE: 407s type=5, has_na=FALSE: 407s type=6, has_na=FALSE: 407s type=7, has_na=FALSE: 407s type=8, has_na=FALSE: 407s type=9, has_na=FALSE: 407s Random test #24 407s Adding NAs 407s num [1:53, 1:29] NaN -67.6 10.8 -88.4 130.1 ... 407s type=1, has_na=TRUE: 407s type=2, has_na=TRUE: 408s type=3, has_na=TRUE: 408s type=4, has_na=TRUE: 408s type=5, has_na=TRUE: 408s type=6, has_na=TRUE: 408s type=7, has_na=TRUE: 408s type=8, has_na=TRUE: 408s type=9, has_na=TRUE: 408s > 408s > 408s > 408s > for (mode in c("logical", "integer", "double")) { 408s + naValue <- NA_real_ 408s + storage.mode(naValue) <- mode 408s + 408s + someValue <- 1 408s + storage.mode(someValue) <- mode 408s + 408s + for (type in 1:9) { 408s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 408s + # All NA 408s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 408s + x <- matrix(naValue, nrow = 3L, ncol = 4L) 408s + dimnames <- lapply(dim(x), FUN = function(n) letters[seq_len(n)]) 408s + # Test with and without dimnames on x 408s + for (setDimnames in c(TRUE, FALSE)) { 408s + if (setDimnames) dimnames(x) <- dimnames 408s + else dimnames(x) <- NULL 408s + # Check names attribute 408s + for (useNames in c(TRUE, FALSE)) { 408s + qr0 <- rowQuantiles_R(x, type = type, useNames = useNames) 408s + 408s + qr <- rowQuantiles(x, type = type, useNames = useNames) 408s + stopifnot(identical(qr, qr0)) 408s + 408s + # x <- matrix(naValue, nrow = 4L, ncol = 3L) 408s + qc <- colQuantiles(t(x), type = type, useNames = useNames) 408s + 408s + stopifnot(identical(qc, qr)) 408s + } 408s + } 408s + 408s + 408s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 408s + # Empty matrices 408s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 408s + probs <- c(0, 0.25, 0.75, 1) 408s + x <- matrix(naValue, nrow = 0L, ncol = 0L) 408s + dimnames(x) <- lapply(dim(x), FUN = function(n) letters[seq_len(n)]) 408s + q <- rowQuantiles(x, probs = probs, type = type, useNames = TRUE) 408s + stopifnot(identical(dim(q), c(nrow(x), length(probs)))) 408s + q <- colQuantiles(x, probs = probs, type = type, useNames = TRUE) 408s + stopifnot(identical(dim(q), c(ncol(x), length(probs)))) 408s + 408s + x <- matrix(naValue, nrow = 2L, ncol = 0L) 408s + dimnames(x) <- lapply(dim(x), FUN = function(n) letters[seq_len(n)]) 408s + q <- rowQuantiles(x, probs = probs, type = type, useNames = TRUE) 408s + stopifnot(identical(dim(q), c(nrow(x), length(probs)))) 408s + 408s + x <- matrix(naValue, nrow = 0L, ncol = 2L) 408s + dimnames(x) <- lapply(dim(x), FUN = function(n) letters[seq_len(n)]) 408s + q <- colQuantiles(x, probs = probs, type = type, useNames = TRUE) 408s + stopifnot(identical(dim(q), c(ncol(x), length(probs)))) 408s + 408s + 408s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 408s + # Single column matrices 408s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 408s + probs <- c(0, 0.25, 0.75, 1) 408s + x <- matrix(someValue, nrow = 2L, ncol = 1L) 408s + dimnames(x) <- lapply(dim(x), FUN = function(n) letters[seq_len(n)]) 408s + qr <- rowQuantiles(x, probs = probs, type = type, useNames = TRUE) 408s + print(qr) 408s + 408s + x <- matrix(someValue, nrow = 1L, ncol = 2L) 408s + dimnames(x) <- lapply(dim(x), FUN = function(n) letters[seq_len(n)]) 408s + qc <- colQuantiles(x, probs = probs, type = type, useNames = TRUE) 408s + print(qc) 408s + 408s + stopifnot(identical(qc, qr)) 408s + } 408s + } 408s 0% 25% 75% 100% 408s a 1 1 1 1 408s b 1 1 1 1 408s 0% 25% 75% 100% 408s a 1 1 1 1 408s b 1 1 1 1 408s 0% 25% 75% 100% 408s a 1 1 1 1 408s b 1 1 1 1 408s 0% 25% 75% 100% 408s a 1 1 1 1 408s b 1 1 1 1 408s 0% 25% 75% 100% 408s a 1 1 1 1 408s b 1 1 1 1 408s 0% 25% 75% 100% 408s a 1 1 1 1 408s b 1 1 1 1 408s 0% 25% 75% 100% 408s a 1 1 1 1 408s b 1 1 1 1 408s 0% 25% 75% 100% 408s a 1 1 1 1 408s b 1 1 1 1 408s 0% 25% 75% 100% 408s a 1 1 1 1 408s b 1 1 1 1 408s 0% 25% 75% 100% 408s a 1 1 1 1 408s b 1 1 1 1 408s 0% 25% 75% 100% 408s a 1 1 1 1 408s b 1 1 1 1 408s 0% 25% 75% 100% 408s a 1 1 1 1 408s b 1 1 1 1 408s 0% 25% 75% 100% 408s a 1 1 1 1 408s b 1 1 1 1 408s 0% 25% 75% 100% 408s a 1 1 1 1 408s b 1 1 1 1 408s 0% 25% 75% 100% 408s a 1 1 1 1 408s b 1 1 1 1 408s 0% 25% 75% 100% 408s a 1 1 1 1 408s b 1 1 1 1 408s 0% 25% 75% 100% 408s a 1 1 1 1 408s b 1 1 1 1 408s 0% 25% 75% 100% 408s a 1 1 1 1 408s b 1 1 1 1 408s 0% 25% 75% 100% 408s a 1 1 1 1 408s b 1 1 1 1 408s 0% 25% 75% 100% 408s a 1 1 1 1 408s b 1 1 1 1 408s 0% 25% 75% 100% 408s a 1 1 1 1 408s b 1 1 1 1 408s 0% 25% 75% 100% 408s a 1 1 1 1 408s b 1 1 1 1 408s 0% 25% 75% 100% 408s a 1 1 1 1 408s b 1 1 1 1 408s 0% 25% 75% 100% 408s a 1 1 1 1 408s b 1 1 1 1 408s 0% 25% 75% 100% 408s a 1 1 1 1 408s b 1 1 1 1 408s 0% 25% 75% 100% 408s a 1 1 1 1 408s b 1 1 1 1 408s 0% 25% 75% 100% 408s a 1 1 1 1 408s b 1 1 1 1 408s 0% 25% 75% 100% 408s a 1 1 1 1 408s b 1 1 1 1 408s 0% 25% 75% 100% 408s a 1 1 1 1 408s b 1 1 1 1 408s 0% 25% 75% 100% 408s a 1 1 1 1 408s b 1 1 1 1 408s 0% 25% 75% 100% 408s a 1 1 1 1 408s b 1 1 1 1 408s 0% 25% 75% 100% 408s a 1 1 1 1 408s b 1 1 1 1 408s 0% 25% 75% 100% 408s a 1 1 1 1 408s b 1 1 1 1 408s 0% 25% 75% 100% 408s a 1 1 1 1 408s b 1 1 1 1 408s 0% 25% 75% 100% 408s a 1 1 1 1 408s b 1 1 1 1 408s 0% 25% 75% 100% 408s a 1 1 1 1 408s b 1 1 1 1 408s 0% 25% 75% 100% 408s a 1 1 1 1 408s b 1 1 1 1 408s 0% 25% 75% 100% 408s a 1 1 1 1 408s b 1 1 1 1 408s 0% 25% 75% 100% 408s a 1 1 1 1 408s b 1 1 1 1 408s 0% 25% 75% 100% 408s a 1 1 1 1 408s b 1 1 1 1 408s 0% 25% 75% 100% 408s a 1 1 1 1 408s b 1 1 1 1 408s 0% 25% 75% 100% 408s a 1 1 1 1 408s b 1 1 1 1 408s 0% 25% 75% 100% 408s a 1 1 1 1 408s b 1 1 1 1 408s 0% 25% 75% 100% 408s a 1 1 1 1 408s b 1 1 1 1 408s 0% 25% 75% 100% 408s a 1 1 1 1 408s b 1 1 1 1 408s 0% 25% 75% 100% 408s a 1 1 1 1 408s b 1 1 1 1 408s 0% 25% 75% 100% 408s a 1 1 1 1 408s b 1 1 1 1 408s 0% 25% 75% 100% 408s a 1 1 1 1 408s b 1 1 1 1 408s 0% 25% 75% 100% 408s a 1 1 1 1 408s b 1 1 1 1 408s 0% 25% 75% 100% 408s a 1 1 1 1 408s b 1 1 1 1 408s 0% 25% 75% 100% 408s a 1 1 1 1 408s b 1 1 1 1 408s 0% 25% 75% 100% 408s a 1 1 1 1 408s b 1 1 1 1 408s 0% 25% 75% 100% 408s a 1 1 1 1 408s b 1 1 1 1 408s 0% 25% 75% 100% 408s a 1 1 1 1 408s b 1 1 1 1 408s > 408s 408s R version 4.4.3 (2025-02-28) -- "Trophy Case" 408s Copyright (C) 2025 The R Foundation for Statistical Computing 408s Platform: arm-unknown-linux-gnueabihf (32-bit) 408s 408s R is free software and comes with ABSOLUTELY NO WARRANTY. 408s You are welcome to redistribute it under certain conditions. 408s Type 'license()' or 'licence()' for distribution details. 408s 408s R is a collaborative project with many contributors. 408s Type 'contributors()' for more information and 408s 'citation()' on how to cite R or R packages in publications. 408s 408s Type 'demo()' for some demos, 'help()' for on-line help, or 408s 'help.start()' for an HTML browser interface to help. 408s Type 'q()' to quit R. 408s 409s > library("matrixStats") 409s > 409s > ## Create isFALSE() if running on an old version of R 409s > if (!exists("isFALSE", mode="function")) { 409s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 409s + } 409s > 409s > rowQuantiles_R <- function(x, probs, na.rm = FALSE, drop = TRUE, ..., useNames = TRUE) { 409s + q <- apply(x, MARGIN = 1L, FUN = function(x, probs, na.rm) { 409s + if (!na.rm && any(is.na(x))) { 409s + na_value <- NA_real_ 409s + storage.mode(na_value) <- storage.mode(x) 409s + rep(na_value, times = length(probs)) 409s + 409s + } else { 409s + as.vector(quantile(x, probs = probs, na.rm = na.rm, names = FALSE, ...)) 409s + } 409s + }, probs = probs, na.rm = na.rm) 409s + 409s + if (!is.null(dim(q))) q <- t(q) 409s + else dim(q) <- c(nrow(x), length(probs)) 409s + 409s + colnames(q) <- matrixStats:::quantile_probs_names(probs) 409s + rownames(q) <- rownames(x) 409s + if (isFALSE(useNames)) dimnames(q) <- NULL 409s + 409s + if (drop) q <- drop(q) 409s + q 409s + } 409s > 409s > 409s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 409s > # Subsetted tests 409s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 409s > source("utils/validateIndicesFramework.R") 409s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 409s > dimnames <- lapply(dim(x), FUN = function(n) letters[seq_len(n)]) 409s > probs <- c(0, 0.25, 0.75, 1) 409s > # Test with and without dimnames on x 409s > for (setDimnames in c(TRUE, FALSE)) { 409s + if (setDimnames) dimnames(x) <- dimnames 409s + else dimnames(x) <- NULL 409s + 409s + count <- 0L 409s + for (rows in index_cases) { 409s + for (cols in index_cases) { 409s + count <- count + 1L 409s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 409s + useNames <- c(TRUE, FALSE) 409s + useNames <- useNames[count %% length(useNames) + 1] 409s + 409s + validateIndicesTestMatrix(x, rows, cols, 409s + ftest = rowQuantiles, fsure = rowQuantiles_R, 409s + probs = probs, na.rm = na.rm, drop = FALSE, useNames = useNames) 409s + validateIndicesTestMatrix(x, rows, cols, 409s + fcoltest = colQuantiles, fsure = rowQuantiles_R, 409s + probs = probs, na.rm = na.rm, drop = FALSE, useNames = useNames) 409s + } 409s + } 409s + } 410s > 410s > 410s 410s R version 4.4.3 (2025-02-28) -- "Trophy Case" 410s Copyright (C) 2025 The R Foundation for Statistical Computing 410s Platform: arm-unknown-linux-gnueabihf (32-bit) 410s 410s R is free software and comes with ABSOLUTELY NO WARRANTY. 410s You are welcome to redistribute it under certain conditions. 410s Type 'license()' or 'licence()' for distribution details. 410s 410s R is a collaborative project with many contributors. 410s Type 'contributors()' for more information and 410s 'citation()' on how to cite R or R packages in publications. 410s 410s Type 'demo()' for some demos, 'help()' for on-line help, or 410s 'help.start()' for an HTML browser interface to help. 410s Type 'q()' to quit R. 410s 411s > library("matrixStats") 411s > 411s > rowMins_R <- function(x, ..., useNames = TRUE) { 411s + suppressWarnings({ 411s + res <- apply(x, MARGIN = 1L, FUN = min, ...) 411s + }) 411s + if (!useNames) names(res) <- NULL 411s + res 411s + } # rowMins_R() 411s > 411s > rowMaxs_R <- function(x, ..., useNames = TRUE) { 411s + suppressWarnings({ 411s + res <- apply(x, MARGIN = 1L, FUN = max, ...) 411s + }) 411s + if (!useNames) names(res) <- NULL 411s + res 411s + } # rowMaxs_R() 411s > 411s > rowRanges_R <- function(x, ..., useNames = TRUE) { 411s + suppressWarnings({ 411s + ans <- t(apply(x, MARGIN = 1L, FUN = range, ...)) 411s + }) 411s + 411s + # Preserve rownames attribute 411s + dim <- c(dim(x)[1], 2L) 411s + if (!isTRUE(all.equal(dim(ans), dim))) { 411s + dim(ans) <- dim 411s + rownames <- rownames(x) 411s + if (!is.null(dimnames)) rownames(ans) <- rownames 411s + } 411s + if (!useNames) dimnames(ans) <- NULL 411s + ans 411s + } # rowRanges_R() 411s > 411s > 411s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 411s > # With and without some NAs 411s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 411s > for (mode in c("integer", "double")) { 411s + cat("mode: ", mode, "\n", sep = "") 411s + 411s + for (add_na in c(FALSE, TRUE)) { 411s + cat("add_na = ", add_na, "\n", sep = "") 411s + 411s + x <- matrix(1:50 + 0.1, nrow = 10L, ncol = 5L) 411s + if (add_na) { 411s + x[3:7, c(2, 4)] <- NA_real_ 411s + } 411s + storage.mode(x) <- mode 411s + str(x) 411s + 411s + # To check names attribute 411s + dimnames <- list(letters[1:10], LETTERS[1:5]) 411s + 411s + # Test with and without dimnames on x 411s + for (setDimnames in c(TRUE, FALSE)) { 411s + if (setDimnames) dimnames(x) <- dimnames 411s + else dimnames(x) <- NULL 411s + # Row/column extremes 411s + for (na.rm in c(FALSE, TRUE)) { 411s + # Check names attribute 411s + for (useNames in c(TRUE, FALSE)) { 411s + cat("na.rm = ", na.rm, "\n", sep = "") 411s + 411s + # Ranges 411s + cat("range:\n") 411s + r0 <- rowRanges_R(x, na.rm = na.rm, useNames = useNames) 411s + r1 <- rowRanges(x, na.rm = na.rm, useNames = useNames) 411s + r2 <- colRanges(t(x), na.rm = na.rm, useNames = useNames) 411s + stopifnot(all.equal(r1, r2)) 411s + stopifnot(all.equal(r1, r0)) 411s + 411s + # Min 411s + cat("min:\n") 411s + m0 <- rowMins_R(x, na.rm = na.rm, useNames = useNames) 411s + m1 <- rowMins(x, na.rm = na.rm, useNames = useNames) 411s + m2 <- colMins(t(x), na.rm = na.rm, useNames = useNames) 411s + stopifnot(all.equal(m1, m2)) 411s + stopifnot(all.equal(m1, m0)) 411s + 411s + # Max 411s + cat("max:\n") 411s + m0 <- rowMaxs_R(x, na.rm = na.rm, useNames = useNames) 411s + m1 <- rowMaxs(x, na.rm = na.rm, useNames = useNames) 411s + m2 <- colMaxs(t(x), na.rm = na.rm, useNames = useNames) 411s + stopifnot(all.equal(m1, m2)) 411s + stopifnot(all.equal(m1, m0)) 411s + } 411s + } 411s + } 411s + } # for (add_na ...) 411s + } # for (mode ...) 411s mode: integer 411s add_na = FALSE 411s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 411s na.rm = FALSE 411s range: 411s min: 411s max: 411s na.rm = FALSE 411s range: 411s min: 411s max: 411s na.rm = TRUE 411s range: 411s min: 411s max: 411s na.rm = TRUE 411s range: 411s min: 411s max: 411s na.rm = FALSE 411s range: 411s min: 411s max: 411s na.rm = FALSE 411s range: 411s min: 411s max: 411s na.rm = TRUE 411s range: 411s min: 411s max: 411s na.rm = TRUE 411s range: 411s min: 411s max: 411s add_na = TRUE 411s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 411s na.rm = FALSE 411s range: 411s min: 411s max: 411s na.rm = FALSE 411s range: 411s min: 411s max: 411s na.rm = TRUE 411s range: 411s min: 411s max: 411s na.rm = TRUE 411s range: 411s min: 411s max: 411s na.rm = FALSE 411s range: 411s min: 411s max: 411s na.rm = FALSE 411s range: 411s min: 411s max: 411s na.rm = TRUE 411s range: 411s min: 411s max: 411s na.rm = TRUE 411s range: 411s min: 411s max: 411s mode: double 411s add_na = FALSE 411s 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 ... 411s na.rm = FALSE 411s range: 411s min: 411s max: 411s na.rm = FALSE 411s range: 411s min: 411s max: 411s na.rm = TRUE 411s range: 411s min: 411s max: 411s na.rm = TRUE 411s range: 411s min: 411s max: 411s na.rm = FALSE 411s range: 411s min: 411s max: 411s na.rm = FALSE 411s range: 411s min: 411s max: 411s na.rm = TRUE 411s range: 411s min: 411s max: 411s na.rm = TRUE 411s range: 411s min: 411s max: 411s add_na = TRUE 411s 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 ... 411s na.rm = FALSE 411s range: 411s min: 411s max: 411s na.rm = FALSE 411s range: 411s min: 411s max: 411s na.rm = TRUE 411s range: 411s min: 411s max: 411s na.rm = TRUE 411s range: 411s min: 411s max: 411s na.rm = FALSE 411s range: 411s min: 411s max: 411s na.rm = FALSE 411s range: 411s min: 411s max: 411s na.rm = TRUE 411s range: 411s min: 411s max: 411s na.rm = TRUE 411s range: 411s min: 411s max: 411s > 411s > 411s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 411s > # All NAs 411s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 411s > for (mode in c("integer", "double")) { 411s + cat("mode: ", mode, "\n", sep = "") 411s + x <- matrix(NA_real_, nrow = 10L, ncol = 5L) 411s + storage.mode(x) <- mode 411s + str(x) 411s + 411s + # Test with and without dimnames on x 411s + for (setDimnames in c(TRUE, FALSE)) { 411s + if (setDimnames) dimnames(x) <- dimnames 411s + else dimnames(x) <- NULL 411s + for (na.rm in c(FALSE, TRUE)) { 411s + # Check names attribute 411s + for (useNames in c(TRUE, FALSE)) { 411s + cat("na.rm = ", na.rm, "\n", sep = "") 411s + r0 <- rowRanges_R(x, na.rm = na.rm, useNames = useNames) 411s + r1 <- rowRanges(x, na.rm = na.rm, useNames = useNames) 411s + r2 <- colRanges(t(x), na.rm = na.rm, useNames = useNames) 411s + stopifnot(all.equal(r1, r2)) 411s + stopifnot(all.equal(r1, r0)) 411s + } 411s + } 411s + } 411s + } # for (mode ...) 411s mode: integer 411s int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 411s na.rm = FALSE 411s na.rm = FALSE 411s na.rm = TRUE 411s na.rm = TRUE 411s na.rm = FALSE 411s na.rm = FALSE 411s na.rm = TRUE 411s na.rm = TRUE 411s mode: double 411s num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 411s na.rm = FALSE 411s na.rm = FALSE 411s na.rm = TRUE 411s na.rm = TRUE 411s na.rm = FALSE 411s na.rm = FALSE 411s na.rm = TRUE 411s na.rm = TRUE 411s > 411s > 411s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 411s > # Special cases 411s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 411s > # Nx0 matrix 411s > x <- matrix(double(0L), nrow = 5L, ncol = 0L) 411s > r0 <- rowRanges_R(x) 411s > #r1 <- rowRanges(x) 411s > #r_truth <- matrix(c(Inf, -Inf), nrow = nrow(x), ncol = 2L, byrow = TRUE) 411s > #stopifnot(all.equal(r1, r_truth)) 411s > 411s > # 0xN matrix 411s > x <- t(x) 411s > #r1 <- colRanges(x) 411s > #stopifnot(all.equal(r1, r_truth)) 411s > 411s > # Nx1 matrix 411s > x <- matrix(1:5, nrow = 5L, ncol = 1L) 411s > # To check names attribute 411s > dimnames <- list(letters[1:5], "A") 411s > r1 <- rowRanges(x) 411s > r_truth <- matrix(1:5, nrow = nrow(x), ncol = 2L, byrow = FALSE) 411s > stopifnot(all.equal(r1, r_truth)) 411s > # Check names attribute 411s > dimnames(x) <- dimnames 411s > r0 <- rowRanges_R(x, useNames = TRUE) 411s > r1 <- rowRanges(x, useNames = TRUE) 411s > stopifnot(all.equal(r1, r0)) 411s > dimnames(x) <- NULL 411s > 411s > # 1xN matrix 411s > x <- t(x) 411s > r1 <- colRanges(x) 411s > stopifnot(all.equal(r1, r_truth)) 411s > # Check names attribute 411s > dimnames(x) <- list("a", LETTERS[1:5]) 411s > r1 <- colRanges(x, useNames = TRUE) 411s > stopifnot(identical(rownames(r1), colnames(x))) 411s > 411s > 411s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 411s > # Additional tests with NA_integer_, NA_real, NaN, -Inf, +Inf 411s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 411s > x <- matrix(1:12, nrow = 4L, ncol = 3L) 411s > 411s > na_list <- list( 411s + "integer" = matrix(1:12, nrow = 4L, ncol = 3L), 411s + "integer w/ NA" = matrix(NA_integer_, nrow = 4L, ncol = 3L), 411s + "real" = matrix(as.double(1:12), nrow = 4L, ncol = 3L), 411s + "real w/ NA" = matrix(NA_real_, nrow = 4L, ncol = 3L) 411s + ) 411s > 411s > na <- na_list[["real"]] 411s > na[2, 2] <- NA 411s > na_list[["real + NA cell"]] <- na 411s > 411s > na <- na_list[["real"]] 411s > na[2, ] <- NA 411s > na_list[["real + NA row"]] <- na 411s > 411s > na <- na_list[["real"]] 411s > na[2, ] <- NaN 411s > na_list[["real + NaN row"]] <- na 411s > 411s > na <- na_list[["real"]] 411s > na[2, 2] <- Inf 411s > na_list[["real + Inf cell"]] <- na 411s > 411s > na <- na_list[["real"]] 411s > na[2, ] <- Inf 411s > na_list[["real + Inf row"]] <- na 411s > 411s > na <- na_list[["real"]] 411s > na[2, 2] <- NaN 411s > na_list[["real + NaN cell"]] <- na 411s > 411s > na <- na_list[["real w/ NA"]] 411s > na[2, 2] <- NaN 411s > na_list[["real w/ NA + NaN cell"]] <- na 411s > 411s > na <- na_list[["real w/ NA"]] 411s > na[2, ] <- NaN 411s > na_list[["real w/ NA + NaN row"]] <- na 411s > 411s > # To check names attribute 411s > dimnames <- list(letters[1:4], LETTERS[1:3]) 411s > 411s > # Test with and without dimnames on x 411s > for (setDimnames in c(TRUE, FALSE)) { 411s + if (setDimnames) dimnames(x) <- dimnames 411s + else dimnames(x) <- NULL 411s + for (na.rm in c(FALSE, TRUE)) { 411s + for (name in names(na_list)) { 411s + # Check names attribute 411s + for (useNames in c(TRUE, FALSE)) { 411s + na <- na_list[[name]] 411s + cat(sprintf("%s (%s) w/ na.rm = %s:\n", name, typeof(na), na.rm)) 411s + print(na) 411s + 411s + cat(" min:\n") 411s + y0 <- rowMins_R(na, na.rm = na.rm, useNames = useNames) 411s + str(y0) 411s + y1 <- rowMins(na, na.rm = na.rm, useNames = useNames) 411s + str(y1) 411s + stopifnot(all.equal(y1, y0)) 411s + y1c <- colMins(t(na), na.rm = na.rm, useNames = useNames) 411s + str(y1c) 411s + stopifnot(all.equal(y1c, y1)) 411s + 411s + cat(" max:\n") 411s + y0 <- rowMaxs_R(na, na.rm = na.rm, useNames = useNames) 411s + str(y0) 411s + y1 <- rowMaxs(na, na.rm = na.rm, useNames = useNames) 411s + str(y1) 411s + stopifnot(all.equal(y1, y0)) 411s + y1c <- colMaxs(t(na), na.rm = na.rm, useNames = useNames) 411s + str(y1c) 411s + stopifnot(all.equal(y1c, y1)) 411s + 411s + cat(" range:\n") 411s + y0 <- rowRanges_R(na, na.rm = na.rm, useNames = useNames) 411s + str(y0) 411s + y1 <- rowRanges(na, na.rm = na.rm, useNames = useNames) 411s + str(y1) 411s + stopifnot(all.equal(y1, y0)) 411s + y1c <- colRanges(t(na), na.rm = na.rm, useNames = useNames) 411s + str(y1c) 411s + stopifnot(all.equal(y1c, y1)) 411s + } 411s + } # for (name ...) 411s + } # for (na.rm ...) 411s + } 411s integer (integer) w/ na.rm = FALSE: 411s [,1] [,2] [,3] 411s [1,] 1 5 9 411s [2,] 2 6 10 411s [3,] 3 7 11 411s [4,] 4 8 12 411s min: 411s int [1:4] 1 2 3 4 411s int [1:4] 1 2 3 4 411s int [1:4] 1 2 3 4 411s max: 411s int [1:4] 9 10 11 12 411s int [1:4] 9 10 11 12 411s int [1:4] 9 10 11 12 411s range: 411s int [1:4, 1:2] 1 2 3 4 9 10 11 12 411s int [1:4, 1:2] 1 2 3 4 9 10 11 12 411s int [1:4, 1:2] 1 2 3 4 9 10 11 12 411s integer (integer) w/ na.rm = FALSE: 411s [,1] [,2] [,3] 411s [1,] 1 5 9 411s [2,] 2 6 10 411s [3,] 3 7 11 411s [4,] 4 8 12 411s min: 411s int [1:4] 1 2 3 4 411s int [1:4] 1 2 3 4 411s int [1:4] 1 2 3 4 411s max: 411s int [1:4] 9 10 11 12 411s int [1:4] 9 10 11 12 411s int [1:4] 9 10 11 12 411s range: 411s int [1:4, 1:2] 1 2 3 4 9 10 11 12 411s int [1:4, 1:2] 1 2 3 4 9 10 11 12 411s int [1:4, 1:2] 1 2 3 4 9 10 11 12 411s integer w/ NA (integer) w/ na.rm = FALSE: 411s [,1] [,2] [,3] 411s [1,] NA NA NA 411s [2,] NA NA NA 411s [3,] NA NA NA 411s [4,] NA NA NA 411s min: 411s int [1:4] NA NA NA NA 411s int [1:4] NA NA NA NA 411s int [1:4] NA NA NA NA 411s max: 411s int [1:4] NA NA NA NA 411s int [1:4] NA NA NA NA 411s int [1:4] NA NA NA NA 411s range: 411s int [1:4, 1:2] NA NA NA NA NA NA NA NA 411s int [1:4, 1:2] NA NA NA NA NA NA NA NA 411s int [1:4, 1:2] NA NA NA NA NA NA NA NA 411s integer w/ NA (integer) w/ na.rm = FALSE: 411s [,1] [,2] [,3] 411s [1,] NA NA NA 411s [2,] NA NA NA 411s [3,] NA NA NA 411s [4,] NA NA NA 411s min: 411s int [1:4] NA NA NA NA 411s int [1:4] NA NA NA NA 411s int [1:4] NA NA NA NA 411s max: 411s int [1:4] NA NA NA NA 411s int [1:4] NA NA NA NA 411s int [1:4] NA NA NA NA 411s range: 411s int [1:4, 1:2] NA NA NA NA NA NA NA NA 411s int [1:4, 1:2] NA NA NA NA NA NA NA NA 411s int [1:4, 1:2] NA NA NA NA NA NA NA NA 411s real (double) w/ na.rm = FALSE: 411s [,1] [,2] [,3] 411s [1,] 1 5 9 411s [2,] 2 6 10 411s [3,] 3 7 11 411s [4,] 4 8 12 411s min: 411s num [1:4] 1 2 3 4 411s num [1:4] 1 2 3 4 411s num [1:4] 1 2 3 4 411s max: 411s num [1:4] 9 10 11 12 411s num [1:4] 9 10 11 12 411s num [1:4] 9 10 11 12 411s range: 411s num [1:4, 1:2] 1 2 3 4 9 10 11 12 411s num [1:4, 1:2] 1 2 3 4 9 10 11 12 411s num [1:4, 1:2] 1 2 3 4 9 10 11 12 411s real (double) w/ na.rm = FALSE: 411s [,1] [,2] [,3] 411s [1,] 1 5 9 411s [2,] 2 6 10 411s [3,] 3 7 11 411s [4,] 4 8 12 411s min: 411s num [1:4] 1 2 3 4 411s num [1:4] 1 2 3 4 411s num [1:4] 1 2 3 4 411s max: 411s num [1:4] 9 10 11 12 411s num [1:4] 9 10 11 12 411s num [1:4] 9 10 11 12 411s range: 411s num [1:4, 1:2] 1 2 3 4 9 10 11 12 411s num [1:4, 1:2] 1 2 3 4 9 10 11 12 411s num [1:4, 1:2] 1 2 3 4 9 10 11 12 411s real w/ NA (double) w/ na.rm = FALSE: 411s [,1] [,2] [,3] 411s [1,] NA NA NA 411s [2,] NA NA NA 411s [3,] NA NA NA 411s [4,] NA NA NA 411s min: 411s num [1:4] NA NA NA NA 411s num [1:4] NA NA NA NA 411s num [1:4] NA NA NA NA 411s max: 411s num [1:4] NA NA NA NA 411s num [1:4] NA NA NA NA 411s num [1:4] NA NA NA NA 411s range: 411s num [1:4, 1:2] NA NA NA NA NA NA NA NA 411s num [1:4, 1:2] NA NA NA NA NA NA NA NA 411s num [1:4, 1:2] NA NA NA NA NA NA NA NA 411s real w/ NA (double) w/ na.rm = FALSE: 411s [,1] [,2] [,3] 411s [1,] NA NA NA 411s [2,] NA NA NA 411s [3,] NA NA NA 411s [4,] NA NA NA 411s min: 411s num [1:4] NA NA NA NA 411s num [1:4] NA NA NA NA 411s num [1:4] NA NA NA NA 411s max: 411s num [1:4] NA NA NA NA 411s num [1:4] NA NA NA NA 411s num [1:4] NA NA NA NA 411s range: 411s num [1:4, 1:2] NA NA NA NA NA NA NA NA 411s num [1:4, 1:2] NA NA NA NA NA NA NA NA 411s num [1:4, 1:2] NA NA NA NA NA NA NA NA 411s real + NA cell (double) w/ na.rm = FALSE: 411s [,1] [,2] [,3] 411s [1,] 1 5 9 411s [2,] 2 NA 10 411s [3,] 3 7 11 411s [4,] 4 8 12 411s min: 411s num [1:4] 1 NA 3 4 411s num [1:4] 1 NA 3 4 411s num [1:4] 1 NA 3 4 411s max: 411s num [1:4] 9 NA 11 12 411s num [1:4] 9 NA 11 12 411s num [1:4] 9 NA 11 12 411s range: 411s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 411s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 411s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 411s real + NA cell (double) w/ na.rm = FALSE: 411s [,1] [,2] [,3] 411s [1,] 1 5 9 411s [2,] 2 NA 10 411s [3,] 3 7 11 411s [4,] 4 8 12 411s min: 411s num [1:4] 1 NA 3 4 411s num [1:4] 1 NA 3 4 411s num [1:4] 1 NA 3 4 411s max: 411s num [1:4] 9 NA 11 12 411s num [1:4] 9 NA 11 12 411s num [1:4] 9 NA 11 12 411s range: 411s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 411s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 411s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 411s real + NA row (double) w/ na.rm = FALSE: 411s [,1] [,2] [,3] 411s [1,] 1 5 9 411s [2,] NA NA NA 411s [3,] 3 7 11 411s [4,] 4 8 12 411s min: 411s num [1:4] 1 NA 3 4 411s num [1:4] 1 NA 3 4 411s num [1:4] 1 NA 3 4 411s max: 411s num [1:4] 9 NA 11 12 411s num [1:4] 9 NA 11 12 411s num [1:4] 9 NA 11 12 411s range: 411s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 411s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 411s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 411s real + NA row (double) w/ na.rm = FALSE: 411s [,1] [,2] [,3] 411s [1,] 1 5 9 411s [2,] NA NA NA 411s [3,] 3 7 11 411s [4,] 4 8 12 411s min: 411s num [1:4] 1 NA 3 4 411s num [1:4] 1 NA 3 4 411s num [1:4] 1 NA 3 4 411s max: 411s num [1:4] 9 NA 11 12 411s num [1:4] 9 NA 11 12 411s num [1:4] 9 NA 11 12 411s range: 411s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 411s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 411s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 411s real + NaN row (double) w/ na.rm = FALSE: 411s [,1] [,2] [,3] 411s [1,] 1 5 9 411s [2,] NaN NaN NaN 411s [3,] 3 7 11 411s [4,] 4 8 12 411s min: 411s num [1:4] 1 NaN 3 4 411s num [1:4] 1 NaN 3 4 411s num [1:4] 1 NaN 3 4 411s max: 411s num [1:4] 9 NaN 11 12 411s num [1:4] 9 NaN 11 12 411s num [1:4] 9 NaN 11 12 411s range: 411s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 411s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 411s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 411s real + NaN row (double) w/ na.rm = FALSE: 411s [,1] [,2] [,3] 411s [1,] 1 5 9 411s [2,] NaN NaN NaN 411s [3,] 3 7 11 411s [4,] 4 8 12 411s min: 411s num [1:4] 1 NaN 3 4 411s num [1:4] 1 NaN 3 4 411s num [1:4] 1 NaN 3 4 411s max: 411s num [1:4] 9 NaN 11 12 411s num [1:4] 9 NaN 11 12 411s num [1:4] 9 NaN 11 12 411s range: 411s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 411s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 411s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 411s real + Inf cell (double) w/ na.rm = FALSE: 411s [,1] [,2] [,3] 411s [1,] 1 5 9 411s [2,] 2 Inf 10 411s [3,] 3 7 11 411s [4,] 4 8 12 411s min: 411s num [1:4] 1 2 3 4 411s num [1:4] 1 2 3 4 411s num [1:4] 1 2 3 4 411s max: 411s num [1:4] 9 Inf 11 12 411s num [1:4] 9 Inf 11 12 411s num [1:4] 9 Inf 11 12 411s range: 411s num [1:4, 1:2] 1 2 3 4 9 ... 411s num [1:4, 1:2] 1 2 3 4 9 ... 411s num [1:4, 1:2] 1 2 3 4 9 ... 411s real + Inf cell (double) w/ na.rm = FALSE: 411s [,1] [,2] [,3] 411s [1,] 1 5 9 411s [2,] 2 Inf 10 411s [3,] 3 7 11 411s [4,] 4 8 12 411s min: 411s num [1:4] 1 2 3 4 411s num [1:4] 1 2 3 4 411s num [1:4] 1 2 3 4 411s max: 411s num [1:4] 9 Inf 11 12 411s num [1:4] 9 Inf 11 12 411s num [1:4] 9 Inf 11 12 411s range: 411s num [1:4, 1:2] 1 2 3 4 9 ... 411s num [1:4, 1:2] 1 2 3 4 9 ... 411s num [1:4, 1:2] 1 2 3 4 9 ... 411s real + Inf row (double) w/ na.rm = FALSE: 411s [,1] [,2] [,3] 411s [1,] 1 5 9 411s [2,] Inf Inf Inf 411s [3,] 3 7 11 411s [4,] 4 8 12 411s min: 411s num [1:4] 1 Inf 3 4 411s num [1:4] 1 Inf 3 4 411s num [1:4] 1 Inf 3 4 411s max: 411s num [1:4] 9 Inf 11 12 411s num [1:4] 9 Inf 11 12 411s num [1:4] 9 Inf 11 12 411s range: 411s num [1:4, 1:2] 1 Inf 3 4 9 ... 411s num [1:4, 1:2] 1 Inf 3 4 9 ... 411s num [1:4, 1:2] 1 Inf 3 4 9 ... 411s real + Inf row (double) w/ na.rm = FALSE: 411s [,1] [,2] [,3] 411s [1,] 1 5 9 411s [2,] Inf Inf Inf 411s [3,] 3 7 11 411s [4,] 4 8 12 411s min: 411s num [1:4] 1 Inf 3 4 411s num [1:4] 1 Inf 3 4 411s num [1:4] 1 Inf 3 4 411s max: 411s num [1:4] 9 Inf 11 12 411s num [1:4] 9 Inf 11 12 411s num [1:4] 9 Inf 11 12 411s range: 411s num [1:4, 1:2] 1 Inf 3 4 9 ... 411s num [1:4, 1:2] 1 Inf 3 4 9 ... 411s num [1:4, 1:2] 1 Inf 3 4 9 ... 411s real + NaN cell (double) w/ na.rm = FALSE: 411s [,1] [,2] [,3] 411s [1,] 1 5 9 411s [2,] 2 NaN 10 411s [3,] 3 7 11 411s [4,] 4 8 12 411s min: 411s num [1:4] 1 NaN 3 4 411s num [1:4] 1 NaN 3 4 411s num [1:4] 1 NaN 3 4 411s max: 411s num [1:4] 9 NaN 11 12 411s num [1:4] 9 NaN 11 12 411s num [1:4] 9 NaN 11 12 411s range: 411s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 411s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 411s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 411s real + NaN cell (double) w/ na.rm = FALSE: 411s [,1] [,2] [,3] 411s [1,] 1 5 9 411s [2,] 2 NaN 10 411s [3,] 3 7 11 411s [4,] 4 8 12 411s min: 411s num [1:4] 1 NaN 3 4 411s num [1:4] 1 NaN 3 4 411s num [1:4] 1 NaN 3 4 411s max: 411s num [1:4] 9 NaN 11 12 411s num [1:4] 9 NaN 11 12 411s num [1:4] 9 NaN 11 12 411s range: 411s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 411s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 411s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 411s real w/ NA + NaN cell (double) w/ na.rm = FALSE: 411s [,1] [,2] [,3] 411s [1,] NA NA NA 411s [2,] NA NaN NA 411s [3,] NA NA NA 411s [4,] NA NA NA 411s min: 411s num [1:4] NA NA NA NA 411s num [1:4] NA NA NA NA 411s num [1:4] NA NA NA NA 411s max: 411s num [1:4] NA NA NA NA 411s num [1:4] NA NA NA NA 411s num [1:4] NA NA NA NA 411s range: 411s num [1:4, 1:2] NA NA NA NA NA NA NA NA 411s num [1:4, 1:2] NA NA NA NA NA NA NA NA 411s num [1:4, 1:2] NA NA NA NA NA NA NA NA 411s real w/ NA + NaN cell (double) w/ na.rm = FALSE: 411s [,1] [,2] [,3] 411s [1,] NA NA NA 411s [2,] NA NaN NA 411s [3,] NA NA NA 411s [4,] NA NA NA 411s min: 411s num [1:4] NA NA NA NA 411s num [1:4] NA NA NA NA 411s num [1:4] NA NA NA NA 411s max: 411s num [1:4] NA NA NA NA 411s num [1:4] NA NA NA NA 411s num [1:4] NA NA NA NA 411s range: 411s num [1:4, 1:2] NA NA NA NA NA NA NA NA 411s num [1:4, 1:2] NA NA NA NA NA NA NA NA 411s num [1:4, 1:2] NA NA NA NA NA NA NA NA 411s real w/ NA + NaN row (double) w/ na.rm = FALSE: 411s [,1] [,2] [,3] 411s [1,] NA NA NA 411s [2,] NaN NaN NaN 411s [3,] NA NA NA 411s [4,] NA NA NA 411s min: 411s num [1:4] NA NaN NA NA 411s num [1:4] NA NaN NA NA 411s num [1:4] NA NaN NA NA 411s max: 411s num [1:4] NA NaN NA NA 411s num [1:4] NA NaN NA NA 411s num [1:4] NA NaN NA NA 411s range: 411s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 411s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 411s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 411s real w/ NA + NaN row (double) w/ na.rm = FALSE: 411s [,1] [,2] [,3] 411s [1,] NA NA NA 411s [2,] NaN NaN NaN 411s [3,] NA NA NA 411s [4,] NA NA NA 411s min: 411s num [1:4] NA NaN NA NA 411s num [1:4] NA NaN NA NA 411s num [1:4] NA NaN NA NA 411s max: 411s num [1:4] NA NaN NA NA 411s num [1:4] NA NaN NA NA 411s num [1:4] NA NaN NA NA 411s range: 411s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 411s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 411s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 411s integer (integer) w/ na.rm = TRUE: 411s [,1] [,2] [,3] 411s [1,] 1 5 9 411s [2,] 2 6 10 411s [3,] 3 7 11 411s [4,] 4 8 12 411s min: 411s int [1:4] 1 2 3 4 411s int [1:4] 1 2 3 4 411s int [1:4] 1 2 3 4 411s max: 411s int [1:4] 9 10 11 12 411s int [1:4] 9 10 11 12 411s int [1:4] 9 10 11 12 411s range: 411s int [1:4, 1:2] 1 2 3 4 9 10 11 12 411s int [1:4, 1:2] 1 2 3 4 9 10 11 12 411s int [1:4, 1:2] 1 2 3 4 9 10 11 12 411s integer (integer) w/ na.rm = TRUE: 411s [,1] [,2] [,3] 411s [1,] 1 5 9 411s [2,] 2 6 10 411s [3,] 3 7 11 411s [4,] 4 8 12 411s min: 411s int [1:4] 1 2 3 4 411s int [1:4] 1 2 3 4 411s int [1:4] 1 2 3 4 411s max: 411s int [1:4] 9 10 11 12 411s int [1:4] 9 10 11 12 411s int [1:4] 9 10 11 12 411s range: 411s int [1:4, 1:2] 1 2 3 4 9 10 11 12 411s int [1:4, 1:2] 1 2 3 4 9 10 11 12 411s int [1:4, 1:2] 1 2 3 4 9 10 11 12 411s integer w/ NA (integer) w/ na.rm = TRUE: 411s [,1] [,2] [,3] 411s [1,] NA NA NA 411s [2,] NA NA NA 411s [3,] NA NA NA 411s [4,] NA NA NA 411s min: 411s num [1:4] Inf Inf Inf Inf 411s num [1:4] Inf Inf Inf Inf 411s num [1:4] Inf Inf Inf Inf 411s max: 411s num [1:4] -Inf -Inf -Inf -Inf 411s num [1:4] -Inf -Inf -Inf -Inf 411s num [1:4] -Inf -Inf -Inf -Inf 411s range: 411s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 411s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 411s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 411s integer w/ NA (integer) w/ na.rm = TRUE: 411s [,1] [,2] [,3] 411s [1,] NA NA NA 411s [2,] NA NA NA 411s [3,] NA NA NA 411s [4,] NA NA NA 411s min: 411s num [1:4] Inf Inf Inf Inf 411s num [1:4] Inf Inf Inf Inf 411s num [1:4] Inf Inf Inf Inf 411s max: 411s num [1:4] -Inf -Inf -Inf -Inf 411s num [1:4] -Inf -Inf -Inf -Inf 411s num [1:4] -Inf -Inf -Inf -Inf 411s range: 411s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 411s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 411s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 411s real (double) w/ na.rm = TRUE: 411s [,1] [,2] [,3] 411s [1,] 1 5 9 411s [2,] 2 6 10 411s [3,] 3 7 11 411s [4,] 4 8 12 411s min: 411s num [1:4] 1 2 3 4 411s num [1:4] 1 2 3 4 411s num [1:4] 1 2 3 4 411s max: 411s num [1:4] 9 10 11 12 411s num [1:4] 9 10 11 12 411s num [1:4] 9 10 11 12 411s range: 411s num [1:4, 1:2] 1 2 3 4 9 10 11 12 411s num [1:4, 1:2] 1 2 3 4 9 10 11 12 411s num [1:4, 1:2] 1 2 3 4 9 10 11 12 411s real (double) w/ na.rm = TRUE: 411s [,1] [,2] [,3] 411s [1,] 1 5 9 411s [2,] 2 6 10 411s [3,] 3 7 11 411s [4,] 4 8 12 411s min: 411s num [1:4] 1 2 3 4 411s num [1:4] 1 2 3 4 411s num [1:4] 1 2 3 4 411s max: 411s num [1:4] 9 10 11 12 411s num [1:4] 9 10 11 12 411s num [1:4] 9 10 11 12 411s range: 411s num [1:4, 1:2] 1 2 3 4 9 10 11 12 411s num [1:4, 1:2] 1 2 3 4 9 10 11 12 411s num [1:4, 1:2] 1 2 3 4 9 10 11 12 411s real w/ NA (double) w/ na.rm = TRUE: 411s [,1] [,2] [,3] 411s [1,] NA NA NA 411s [2,] NA NA NA 411s [3,] NA NA NA 411s [4,] NA NA NA 411s min: 411s num [1:4] Inf Inf Inf Inf 411s num [1:4] Inf Inf Inf Inf 411s num [1:4] Inf Inf Inf Inf 411s max: 411s num [1:4] -Inf -Inf -Inf -Inf 411s num [1:4] -Inf -Inf -Inf -Inf 411s num [1:4] -Inf -Inf -Inf -Inf 411s range: 411s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 411s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 411s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 411s real w/ NA (double) w/ na.rm = TRUE: 411s [,1] [,2] [,3] 411s [1,] NA NA NA 411s [2,] NA NA NA 411s [3,] NA NA NA 411s [4,] NA NA NA 411s min: 411s num [1:4] Inf Inf Inf Inf 411s num [1:4] Inf Inf Inf Inf 411s num [1:4] Inf Inf Inf Inf 411s max: 411s num [1:4] -Inf -Inf -Inf -Inf 411s num [1:4] -Inf -Inf -Inf -Inf 411s num [1:4] -Inf -Inf -Inf -Inf 411s range: 411s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 411s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 411s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 411s real + NA cell (double) w/ na.rm = TRUE: 411s [,1] [,2] [,3] 411s [1,] 1 5 9 411s [2,] 2 NA 10 411s [3,] 3 7 11 411s [4,] 4 8 12 411s min: 411s num [1:4] 1 2 3 4 411s num [1:4] 1 2 3 4 411s num [1:4] 1 2 3 4 411s max: 411s num [1:4] 9 10 11 12 411s num [1:4] 9 10 11 12 411s num [1:4] 9 10 11 12 411s range: 411s num [1:4, 1:2] 1 2 3 4 9 10 11 12 411s num [1:4, 1:2] 1 2 3 4 9 10 11 12 411s num [1:4, 1:2] 1 2 3 4 9 10 11 12 411s real + NA cell (double) w/ na.rm = TRUE: 411s [,1] [,2] [,3] 411s [1,] 1 5 9 411s [2,] 2 NA 10 411s [3,] 3 7 11 411s [4,] 4 8 12 411s min: 411s num [1:4] 1 2 3 4 411s num [1:4] 1 2 3 4 411s num [1:4] 1 2 3 4 411s max: 411s num [1:4] 9 10 11 12 411s num [1:4] 9 10 11 12 411s num [1:4] 9 10 11 12 411s range: 411s num [1:4, 1:2] 1 2 3 4 9 10 11 12 411s num [1:4, 1:2] 1 2 3 4 9 10 11 12 411s num [1:4, 1:2] 1 2 3 4 9 10 11 12 411s real + NA row (double) w/ na.rm = TRUE: 411s [,1] [,2] [,3] 411s [1,] 1 5 9 411s [2,] NA NA NA 411s [3,] 3 7 11 411s [4,] 4 8 12 411s min: 411s num [1:4] 1 Inf 3 4 411s num [1:4] 1 Inf 3 4 411s num [1:4] 1 Inf 3 4 411s max: 411s num [1:4] 9 -Inf 11 12 411s num [1:4] 9 -Inf 11 12 411s num [1:4] 9 -Inf 11 12 411s range: 411s num [1:4, 1:2] 1 Inf 3 4 9 ... 411s num [1:4, 1:2] 1 Inf 3 4 9 ... 411s num [1:4, 1:2] 1 Inf 3 4 9 ... 411s real + NA row (double) w/ na.rm = TRUE: 411s [,1] [,2] [,3] 411s [1,] 1 5 9 411s [2,] NA NA NA 411s [3,] 3 7 11 411s [4,] 4 8 12 411s min: 411s num [1:4] 1 Inf 3 4 411s num [1:4] 1 Inf 3 4 411s num [1:4] 1 Inf 3 4 411s max: 411s num [1:4] 9 -Inf 11 12 411s num [1:4] 9 -Inf 11 12 411s num [1:4] 9 -Inf 11 12 411s range: 411s num [1:4, 1:2] 1 Inf 3 4 9 ... 411s num [1:4, 1:2] 1 Inf 3 4 9 ... 411s num [1:4, 1:2] 1 Inf 3 4 9 ... 411s real + NaN row (double) w/ na.rm = TRUE: 411s [,1] [,2] [,3] 411s [1,] 1 5 9 411s [2,] NaN NaN NaN 411s [3,] 3 7 11 411s [4,] 4 8 12 411s min: 411s num [1:4] 1 Inf 3 4 411s num [1:4] 1 Inf 3 4 411s num [1:4] 1 Inf 3 4 411s max: 411s num [1:4] 9 -Inf 11 12 411s num [1:4] 9 -Inf 11 12 411s num [1:4] 9 -Inf 11 12 411s range: 411s num [1:4, 1:2] 1 Inf 3 4 9 ... 411s num [1:4, 1:2] 1 Inf 3 4 9 ... 411s num [1:4, 1:2] 1 Inf 3 4 9 ... 411s real + NaN row (double) w/ na.rm = TRUE: 411s [,1] [,2] [,3] 411s [1,] 1 5 9 411s [2,] NaN NaN NaN 411s [3,] 3 7 11 411s [4,] 4 8 12 411s min: 411s num [1:4] 1 Inf 3 4 411s num [1:4] 1 Inf 3 4 411s num [1:4] 1 Inf 3 4 411s max: 411s num [1:4] 9 -Inf 11 12 411s num [1:4] 9 -Inf 11 12 411s num [1:4] 9 -Inf 11 12 411s range: 411s num [1:4, 1:2] 1 Inf 3 4 9 ... 411s num [1:4, 1:2] 1 Inf 3 4 9 ... 411s num [1:4, 1:2] 1 Inf 3 4 9 ... 411s real + Inf cell (double) w/ na.rm = TRUE: 411s [,1] [,2] [,3] 411s [1,] 1 5 9 411s [2,] 2 Inf 10 411s [3,] 3 7 11 411s [4,] 4 8 12 411s min: 411s num [1:4] 1 2 3 4 411s num [1:4] 1 2 3 4 411s num [1:4] 1 2 3 4 411s max: 411s num [1:4] 9 Inf 11 12 411s num [1:4] 9 Inf 11 12 411s num [1:4] 9 Inf 11 12 411s range: 411s num [1:4, 1:2] 1 2 3 4 9 ... 411s num [1:4, 1:2] 1 2 3 4 9 ... 411s num [1:4, 1:2] 1 2 3 4 9 ... 411s real + Inf cell (double) w/ na.rm = TRUE: 411s [,1] [,2] [,3] 411s [1,] 1 5 9 411s [2,] 2 Inf 10 411s [3,] 3 7 11 411s [4,] 4 8 12 411s min: 411s num [1:4] 1 2 3 4 411s num [1:4] 1 2 3 4 411s num [1:4] 1 2 3 4 411s max: 411s num [1:4] 9 Inf 11 12 411s num [1:4] 9 Inf 11 12 411s num [1:4] 9 Inf 11 12 411s range: 411s num [1:4, 1:2] 1 2 3 4 9 ... 411s num [1:4, 1:2] 1 2 3 4 9 ... 411s num [1:4, 1:2] 1 2 3 4 9 ... 411s real + Inf row (double) w/ na.rm = TRUE: 411s [,1] [,2] [,3] 411s [1,] 1 5 9 411s [2,] Inf Inf Inf 411s [3,] 3 7 11 411s [4,] 4 8 12 411s min: 411s num [1:4] 1 Inf 3 4 411s num [1:4] 1 Inf 3 4 411s num [1:4] 1 Inf 3 4 411s max: 411s num [1:4] 9 Inf 11 12 411s num [1:4] 9 Inf 11 12 411s num [1:4] 9 Inf 11 12 411s range: 411s num [1:4, 1:2] 1 Inf 3 4 9 ... 411s num [1:4, 1:2] 1 Inf 3 4 9 ... 411s num [1:4, 1:2] 1 Inf 3 4 9 ... 411s real + Inf row (double) w/ na.rm = TRUE: 412s [,1] [,2] [,3] 412s [1,] 1 5 9 412s [2,] Inf Inf Inf 412s [3,] 3 7 11 412s [4,] 4 8 12 412s min: 412s num [1:4] 1 Inf 3 4 412s num [1:4] 1 Inf 3 4 412s num [1:4] 1 Inf 3 4 412s max: 412s num [1:4] 9 Inf 11 12 412s num [1:4] 9 Inf 11 12 412s num [1:4] 9 Inf 11 12 412s range: 412s num [1:4, 1:2] 1 Inf 3 4 9 ... 412s num [1:4, 1:2] 1 Inf 3 4 9 ... 412s num [1:4, 1:2] 1 Inf 3 4 9 ... 412s real + NaN cell (double) w/ na.rm = TRUE: 412s [,1] [,2] [,3] 412s [1,] 1 5 9 412s [2,] 2 NaN 10 412s [3,] 3 7 11 412s [4,] 4 8 12 412s min: 412s num [1:4] 1 2 3 4 412s num [1:4] 1 2 3 4 412s num [1:4] 1 2 3 4 412s max: 412s num [1:4] 9 10 11 12 412s num [1:4] 9 10 11 12 412s num [1:4] 9 10 11 12 412s range: 412s num [1:4, 1:2] 1 2 3 4 9 10 11 12 412s num [1:4, 1:2] 1 2 3 4 9 10 11 12 412s num [1:4, 1:2] 1 2 3 4 9 10 11 12 412s real + NaN cell (double) w/ na.rm = TRUE: 412s [,1] [,2] [,3] 412s [1,] 1 5 9 412s [2,] 2 NaN 10 412s [3,] 3 7 11 412s [4,] 4 8 12 412s min: 412s num [1:4] 1 2 3 4 412s num [1:4] 1 2 3 4 412s num [1:4] 1 2 3 4 412s max: 412s num [1:4] 9 10 11 12 412s num [1:4] 9 10 11 12 412s num [1:4] 9 10 11 12 412s range: 412s num [1:4, 1:2] 1 2 3 4 9 10 11 12 412s num [1:4, 1:2] 1 2 3 4 9 10 11 12 412s num [1:4, 1:2] 1 2 3 4 9 10 11 12 412s real w/ NA + NaN cell (double) w/ na.rm = TRUE: 412s [,1] [,2] [,3] 412s [1,] NA NA NA 412s [2,] NA NaN NA 412s [3,] NA NA NA 412s [4,] NA NA NA 412s min: 412s num [1:4] Inf Inf Inf Inf 412s num [1:4] Inf Inf Inf Inf 412s num [1:4] Inf Inf Inf Inf 412s max: 412s num [1:4] -Inf -Inf -Inf -Inf 412s num [1:4] -Inf -Inf -Inf -Inf 412s num [1:4] -Inf -Inf -Inf -Inf 412s range: 412s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 412s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 412s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 412s real w/ NA + NaN cell (double) w/ na.rm = TRUE: 412s [,1] [,2] [,3] 412s [1,] NA NA NA 412s [2,] NA NaN NA 412s [3,] NA NA NA 412s [4,] NA NA NA 412s min: 412s num [1:4] Inf Inf Inf Inf 412s num [1:4] Inf Inf Inf Inf 412s num [1:4] Inf Inf Inf Inf 412s max: 412s num [1:4] -Inf -Inf -Inf -Inf 412s num [1:4] -Inf -Inf -Inf -Inf 412s num [1:4] -Inf -Inf -Inf -Inf 412s range: 412s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 412s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 412s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 412s real w/ NA + NaN row (double) w/ na.rm = TRUE: 412s [,1] [,2] [,3] 412s [1,] NA NA NA 412s [2,] NaN NaN NaN 412s [3,] NA NA NA 412s [4,] NA NA NA 412s min: 412s num [1:4] Inf Inf Inf Inf 412s num [1:4] Inf Inf Inf Inf 412s num [1:4] Inf Inf Inf Inf 412s max: 412s num [1:4] -Inf -Inf -Inf -Inf 412s num [1:4] -Inf -Inf -Inf -Inf 412s num [1:4] -Inf -Inf -Inf -Inf 412s range: 412s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 412s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 412s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 412s real w/ NA + NaN row (double) w/ na.rm = TRUE: 412s [,1] [,2] [,3] 412s [1,] NA NA NA 412s [2,] NaN NaN NaN 412s [3,] NA NA NA 412s [4,] NA NA NA 412s min: 412s num [1:4] Inf Inf Inf Inf 412s num [1:4] Inf Inf Inf Inf 412s num [1:4] Inf Inf Inf Inf 412s max: 412s num [1:4] -Inf -Inf -Inf -Inf 412s num [1:4] -Inf -Inf -Inf -Inf 412s num [1:4] -Inf -Inf -Inf -Inf 412s range: 412s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 412s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 412s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 412s integer (integer) w/ na.rm = FALSE: 412s [,1] [,2] [,3] 412s [1,] 1 5 9 412s [2,] 2 6 10 412s [3,] 3 7 11 412s [4,] 4 8 12 412s min: 412s int [1:4] 1 2 3 4 412s int [1:4] 1 2 3 4 412s int [1:4] 1 2 3 4 412s max: 412s int [1:4] 9 10 11 12 412s int [1:4] 9 10 11 12 412s int [1:4] 9 10 11 12 412s range: 412s int [1:4, 1:2] 1 2 3 4 9 10 11 12 412s int [1:4, 1:2] 1 2 3 4 9 10 11 12 412s int [1:4, 1:2] 1 2 3 4 9 10 11 12 412s integer (integer) w/ na.rm = FALSE: 412s [,1] [,2] [,3] 412s [1,] 1 5 9 412s [2,] 2 6 10 412s [3,] 3 7 11 412s [4,] 4 8 12 412s min: 412s int [1:4] 1 2 3 4 412s int [1:4] 1 2 3 4 412s int [1:4] 1 2 3 4 412s max: 412s int [1:4] 9 10 11 12 412s int [1:4] 9 10 11 12 412s int [1:4] 9 10 11 12 412s range: 412s int [1:4, 1:2] 1 2 3 4 9 10 11 12 412s int [1:4, 1:2] 1 2 3 4 9 10 11 12 412s int [1:4, 1:2] 1 2 3 4 9 10 11 12 412s integer w/ NA (integer) w/ na.rm = FALSE: 412s [,1] [,2] [,3] 412s [1,] NA NA NA 412s [2,] NA NA NA 412s [3,] NA NA NA 412s [4,] NA NA NA 412s min: 412s int [1:4] NA NA NA NA 412s int [1:4] NA NA NA NA 412s int [1:4] NA NA NA NA 412s max: 412s int [1:4] NA NA NA NA 412s int [1:4] NA NA NA NA 412s int [1:4] NA NA NA NA 412s range: 412s int [1:4, 1:2] NA NA NA NA NA NA NA NA 412s int [1:4, 1:2] NA NA NA NA NA NA NA NA 412s int [1:4, 1:2] NA NA NA NA NA NA NA NA 412s integer w/ NA (integer) w/ na.rm = FALSE: 412s [,1] [,2] [,3] 412s [1,] NA NA NA 412s [2,] NA NA NA 412s [3,] NA NA NA 412s [4,] NA NA NA 412s min: 412s int [1:4] NA NA NA NA 412s int [1:4] NA NA NA NA 412s int [1:4] NA NA NA NA 412s max: 412s int [1:4] NA NA NA NA 412s int [1:4] NA NA NA NA 412s int [1:4] NA NA NA NA 412s range: 412s int [1:4, 1:2] NA NA NA NA NA NA NA NA 412s int [1:4, 1:2] NA NA NA NA NA NA NA NA 412s int [1:4, 1:2] NA NA NA NA NA NA NA NA 412s real (double) w/ na.rm = FALSE: 412s [,1] [,2] [,3] 412s [1,] 1 5 9 412s [2,] 2 6 10 412s [3,] 3 7 11 412s [4,] 4 8 12 412s min: 412s num [1:4] 1 2 3 4 412s num [1:4] 1 2 3 4 412s num [1:4] 1 2 3 4 412s max: 412s num [1:4] 9 10 11 12 412s num [1:4] 9 10 11 12 412s num [1:4] 9 10 11 12 412s range: 412s num [1:4, 1:2] 1 2 3 4 9 10 11 12 412s num [1:4, 1:2] 1 2 3 4 9 10 11 12 412s num [1:4, 1:2] 1 2 3 4 9 10 11 12 412s real (double) w/ na.rm = FALSE: 412s [,1] [,2] [,3] 412s [1,] 1 5 9 412s [2,] 2 6 10 412s [3,] 3 7 11 412s [4,] 4 8 12 412s min: 412s num [1:4] 1 2 3 4 412s num [1:4] 1 2 3 4 412s num [1:4] 1 2 3 4 412s max: 412s num [1:4] 9 10 11 12 412s num [1:4] 9 10 11 12 412s num [1:4] 9 10 11 12 412s range: 412s num [1:4, 1:2] 1 2 3 4 9 10 11 12 412s num [1:4, 1:2] 1 2 3 4 9 10 11 12 412s num [1:4, 1:2] 1 2 3 4 9 10 11 12 412s real w/ NA (double) w/ na.rm = FALSE: 412s [,1] [,2] [,3] 412s [1,] NA NA NA 412s [2,] NA NA NA 412s [3,] NA NA NA 412s [4,] NA NA NA 412s min: 412s num [1:4] NA NA NA NA 412s num [1:4] NA NA NA NA 412s num [1:4] NA NA NA NA 412s max: 412s num [1:4] NA NA NA NA 412s num [1:4] NA NA NA NA 412s num [1:4] NA NA NA NA 412s range: 412s num [1:4, 1:2] NA NA NA NA NA NA NA NA 412s num [1:4, 1:2] NA NA NA NA NA NA NA NA 412s num [1:4, 1:2] NA NA NA NA NA NA NA NA 412s real w/ NA (double) w/ na.rm = FALSE: 412s [,1] [,2] [,3] 412s [1,] NA NA NA 412s [2,] NA NA NA 412s [3,] NA NA NA 412s [4,] NA NA NA 412s min: 412s num [1:4] NA NA NA NA 412s num [1:4] NA NA NA NA 412s num [1:4] NA NA NA NA 412s max: 412s num [1:4] NA NA NA NA 412s num [1:4] NA NA NA NA 412s num [1:4] NA NA NA NA 412s range: 412s num [1:4, 1:2] NA NA NA NA NA NA NA NA 412s num [1:4, 1:2] NA NA NA NA NA NA NA NA 412s num [1:4, 1:2] NA NA NA NA NA NA NA NA 412s real + NA cell (double) w/ na.rm = FALSE: 412s [,1] [,2] [,3] 412s [1,] 1 5 9 412s [2,] 2 NA 10 412s [3,] 3 7 11 412s [4,] 4 8 12 412s min: 412s num [1:4] 1 NA 3 4 412s num [1:4] 1 NA 3 4 412s num [1:4] 1 NA 3 4 412s max: 412s num [1:4] 9 NA 11 12 412s num [1:4] 9 NA 11 12 412s num [1:4] 9 NA 11 12 412s range: 412s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 412s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 412s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 412s real + NA cell (double) w/ na.rm = FALSE: 412s [,1] [,2] [,3] 412s [1,] 1 5 9 412s [2,] 2 NA 10 412s [3,] 3 7 11 412s [4,] 4 8 12 412s min: 412s num [1:4] 1 NA 3 4 412s num [1:4] 1 NA 3 4 412s num [1:4] 1 NA 3 4 412s max: 412s num [1:4] 9 NA 11 12 412s num [1:4] 9 NA 11 12 412s num [1:4] 9 NA 11 12 412s range: 412s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 412s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 412s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 412s real + NA row (double) w/ na.rm = FALSE: 412s [,1] [,2] [,3] 412s [1,] 1 5 9 412s [2,] NA NA NA 412s [3,] 3 7 11 412s [4,] 4 8 12 412s min: 412s num [1:4] 1 NA 3 4 412s num [1:4] 1 NA 3 4 412s num [1:4] 1 NA 3 4 412s max: 412s num [1:4] 9 NA 11 12 412s num [1:4] 9 NA 11 12 412s num [1:4] 9 NA 11 12 412s range: 412s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 412s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 412s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 412s real + NA row (double) w/ na.rm = FALSE: 412s [,1] [,2] [,3] 412s [1,] 1 5 9 412s [2,] NA NA NA 412s [3,] 3 7 11 412s [4,] 4 8 12 412s min: 412s num [1:4] 1 NA 3 4 412s num [1:4] 1 NA 3 4 412s num [1:4] 1 NA 3 4 412s max: 412s num [1:4] 9 NA 11 12 412s num [1:4] 9 NA 11 12 412s num [1:4] 9 NA 11 12 412s range: 412s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 412s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 412s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 412s real + NaN row (double) w/ na.rm = FALSE: 412s [,1] [,2] [,3] 412s [1,] 1 5 9 412s [2,] NaN NaN NaN 412s [3,] 3 7 11 412s [4,] 4 8 12 412s min: 412s num [1:4] 1 NaN 3 4 412s num [1:4] 1 NaN 3 4 412s num [1:4] 1 NaN 3 4 412s max: 412s num [1:4] 9 NaN 11 12 412s num [1:4] 9 NaN 11 12 412s num [1:4] 9 NaN 11 12 412s range: 412s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 412s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 412s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 412s real + NaN row (double) w/ na.rm = FALSE: 412s [,1] [,2] [,3] 412s [1,] 1 5 9 412s [2,] NaN NaN NaN 412s [3,] 3 7 11 412s [4,] 4 8 12 412s min: 412s num [1:4] 1 NaN 3 4 412s num [1:4] 1 NaN 3 4 412s num [1:4] 1 NaN 3 4 412s max: 412s num [1:4] 9 NaN 11 12 412s num [1:4] 9 NaN 11 12 412s num [1:4] 9 NaN 11 12 412s range: 412s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 412s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 412s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 412s real + Inf cell (double) w/ na.rm = FALSE: 412s [,1] [,2] [,3] 412s [1,] 1 5 9 412s [2,] 2 Inf 10 412s [3,] 3 7 11 412s [4,] 4 8 12 412s min: 412s num [1:4] 1 2 3 4 412s num [1:4] 1 2 3 4 412s num [1:4] 1 2 3 4 412s max: 412s num [1:4] 9 Inf 11 12 412s num [1:4] 9 Inf 11 12 412s num [1:4] 9 Inf 11 12 412s range: 412s num [1:4, 1:2] 1 2 3 4 9 ... 412s num [1:4, 1:2] 1 2 3 4 9 ... 412s num [1:4, 1:2] 1 2 3 4 9 ... 412s real + Inf cell (double) w/ na.rm = FALSE: 412s [,1] [,2] [,3] 412s [1,] 1 5 9 412s [2,] 2 Inf 10 412s [3,] 3 7 11 412s [4,] 4 8 12 412s min: 412s num [1:4] 1 2 3 4 412s num [1:4] 1 2 3 4 412s num [1:4] 1 2 3 4 412s max: 412s num [1:4] 9 Inf 11 12 412s num [1:4] 9 Inf 11 12 412s num [1:4] 9 Inf 11 12 412s range: 412s num [1:4, 1:2] 1 2 3 4 9 ... 412s num [1:4, 1:2] 1 2 3 4 9 ... 412s num [1:4, 1:2] 1 2 3 4 9 ... 412s real + Inf row (double) w/ na.rm = FALSE: 412s [,1] [,2] [,3] 412s [1,] 1 5 9 412s [2,] Inf Inf Inf 412s [3,] 3 7 11 412s [4,] 4 8 12 412s min: 412s num [1:4] 1 Inf 3 4 412s num [1:4] 1 Inf 3 4 412s num [1:4] 1 Inf 3 4 412s max: 412s num [1:4] 9 Inf 11 12 412s num [1:4] 9 Inf 11 12 412s num [1:4] 9 Inf 11 12 412s range: 412s num [1:4, 1:2] 1 Inf 3 4 9 ... 412s num [1:4, 1:2] 1 Inf 3 4 9 ... 412s num [1:4, 1:2] 1 Inf 3 4 9 ... 412s real + Inf row (double) w/ na.rm = FALSE: 412s [,1] [,2] [,3] 412s [1,] 1 5 9 412s [2,] Inf Inf Inf 412s [3,] 3 7 11 412s [4,] 4 8 12 412s min: 412s num [1:4] 1 Inf 3 4 412s num [1:4] 1 Inf 3 4 412s num [1:4] 1 Inf 3 4 412s max: 412s num [1:4] 9 Inf 11 12 412s num [1:4] 9 Inf 11 12 412s num [1:4] 9 Inf 11 12 412s range: 412s num [1:4, 1:2] 1 Inf 3 4 9 ... 412s num [1:4, 1:2] 1 Inf 3 4 9 ... 412s num [1:4, 1:2] 1 Inf 3 4 9 ... 412s real + NaN cell (double) w/ na.rm = FALSE: 412s [,1] [,2] [,3] 412s [1,] 1 5 9 412s [2,] 2 NaN 10 412s [3,] 3 7 11 412s [4,] 4 8 12 412s min: 412s num [1:4] 1 NaN 3 4 412s num [1:4] 1 NaN 3 4 412s num [1:4] 1 NaN 3 4 412s max: 412s num [1:4] 9 NaN 11 12 412s num [1:4] 9 NaN 11 12 412s num [1:4] 9 NaN 11 12 412s range: 412s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 412s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 412s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 412s real + NaN cell (double) w/ na.rm = FALSE: 412s [,1] [,2] [,3] 412s [1,] 1 5 9 412s [2,] 2 NaN 10 412s [3,] 3 7 11 412s [4,] 4 8 12 412s min: 412s num [1:4] 1 NaN 3 4 412s num [1:4] 1 NaN 3 4 412s num [1:4] 1 NaN 3 4 412s max: 412s num [1:4] 9 NaN 11 12 412s num [1:4] 9 NaN 11 12 412s num [1:4] 9 NaN 11 12 412s range: 412s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 412s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 412s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 412s real w/ NA + NaN cell (double) w/ na.rm = FALSE: 412s [,1] [,2] [,3] 412s [1,] NA NA NA 412s [2,] NA NaN NA 412s [3,] NA NA NA 412s [4,] NA NA NA 412s min: 412s num [1:4] NA NA NA NA 412s num [1:4] NA NA NA NA 412s num [1:4] NA NA NA NA 412s max: 412s num [1:4] NA NA NA NA 412s num [1:4] NA NA NA NA 412s num [1:4] NA NA NA NA 412s range: 412s num [1:4, 1:2] NA NA NA NA NA NA NA NA 412s num [1:4, 1:2] NA NA NA NA NA NA NA NA 412s num [1:4, 1:2] NA NA NA NA NA NA NA NA 412s real w/ NA + NaN cell (double) w/ na.rm = FALSE: 412s [,1] [,2] [,3] 412s [1,] NA NA NA 412s [2,] NA NaN NA 412s [3,] NA NA NA 412s [4,] NA NA NA 412s min: 412s num [1:4] NA NA NA NA 412s num [1:4] NA NA NA NA 412s num [1:4] NA NA NA NA 412s max: 412s num [1:4] NA NA NA NA 412s num [1:4] NA NA NA NA 412s num [1:4] NA NA NA NA 412s range: 412s num [1:4, 1:2] NA NA NA NA NA NA NA NA 412s num [1:4, 1:2] NA NA NA NA NA NA NA NA 412s num [1:4, 1:2] NA NA NA NA NA NA NA NA 412s real w/ NA + NaN row (double) w/ na.rm = FALSE: 412s [,1] [,2] [,3] 412s [1,] NA NA NA 412s [2,] NaN NaN NaN 412s [3,] NA NA NA 412s [4,] NA NA NA 412s min: 412s num [1:4] NA NaN NA NA 412s num [1:4] NA NaN NA NA 412s num [1:4] NA NaN NA NA 412s max: 412s num [1:4] NA NaN NA NA 412s num [1:4] NA NaN NA NA 412s num [1:4] NA NaN NA NA 412s range: 412s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 412s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 412s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 412s real w/ NA + NaN row (double) w/ na.rm = FALSE: 412s [,1] [,2] [,3] 412s [1,] NA NA NA 412s [2,] NaN NaN NaN 412s [3,] NA NA NA 412s [4,] NA NA NA 412s min: 412s num [1:4] NA NaN NA NA 412s num [1:4] NA NaN NA NA 412s num [1:4] NA NaN NA NA 412s max: 412s num [1:4] NA NaN NA NA 412s num [1:4] NA NaN NA NA 412s num [1:4] NA NaN NA NA 412s range: 412s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 412s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 412s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 412s integer (integer) w/ na.rm = TRUE: 412s [,1] [,2] [,3] 412s [1,] 1 5 9 412s [2,] 2 6 10 412s [3,] 3 7 11 412s [4,] 4 8 12 412s min: 412s int [1:4] 1 2 3 4 412s int [1:4] 1 2 3 4 412s int [1:4] 1 2 3 4 412s max: 412s int [1:4] 9 10 11 12 412s int [1:4] 9 10 11 12 412s int [1:4] 9 10 11 12 412s range: 412s int [1:4, 1:2] 1 2 3 4 9 10 11 12 412s int [1:4, 1:2] 1 2 3 4 9 10 11 12 412s int [1:4, 1:2] 1 2 3 4 9 10 11 12 412s integer (integer) w/ na.rm = TRUE: 412s [,1] [,2] [,3] 412s [1,] 1 5 9 412s [2,] 2 6 10 412s [3,] 3 7 11 412s [4,] 4 8 12 412s min: 412s int [1:4] 1 2 3 4 412s int [1:4] 1 2 3 4 412s int [1:4] 1 2 3 4 412s max: 412s int [1:4] 9 10 11 12 412s int [1:4] 9 10 11 12 412s int [1:4] 9 10 11 12 412s range: 412s int [1:4, 1:2] 1 2 3 4 9 10 11 12 412s int [1:4, 1:2] 1 2 3 4 9 10 11 12 412s int [1:4, 1:2] 1 2 3 4 9 10 11 12 412s integer w/ NA (integer) w/ na.rm = TRUE: 412s [,1] [,2] [,3] 412s [1,] NA NA NA 412s [2,] NA NA NA 412s [3,] NA NA NA 412s [4,] NA NA NA 412s min: 412s num [1:4] Inf Inf Inf Inf 412s num [1:4] Inf Inf Inf Inf 412s num [1:4] Inf Inf Inf Inf 412s max: 412s num [1:4] -Inf -Inf -Inf -Inf 412s num [1:4] -Inf -Inf -Inf -Inf 412s num [1:4] -Inf -Inf -Inf -Inf 412s range: 412s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 412s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 412s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 412s integer w/ NA (integer) w/ na.rm = TRUE: 412s [,1] [,2] [,3] 412s [1,] NA NA NA 412s [2,] NA NA NA 412s [3,] NA NA NA 412s [4,] NA NA NA 412s min: 412s num [1:4] Inf Inf Inf Inf 412s num [1:4] Inf Inf Inf Inf 412s num [1:4] Inf Inf Inf Inf 412s max: 412s num [1:4] -Inf -Inf -Inf -Inf 412s num [1:4] -Inf -Inf -Inf -Inf 412s num [1:4] -Inf -Inf -Inf -Inf 412s range: 412s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 412s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 412s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 412s real (double) w/ na.rm = TRUE: 412s [,1] [,2] [,3] 412s [1,] 1 5 9 412s [2,] 2 6 10 412s [3,] 3 7 11 412s [4,] 4 8 12 412s min: 412s num [1:4] 1 2 3 4 412s num [1:4] 1 2 3 4 412s num [1:4] 1 2 3 4 412s max: 412s num [1:4] 9 10 11 12 412s num [1:4] 9 10 11 12 412s num [1:4] 9 10 11 12 412s range: 412s num [1:4, 1:2] 1 2 3 4 9 10 11 12 412s num [1:4, 1:2] 1 2 3 4 9 10 11 12 412s num [1:4, 1:2] 1 2 3 4 9 10 11 12 412s real (double) w/ na.rm = TRUE: 412s [,1] [,2] [,3] 412s [1,] 1 5 9 412s [2,] 2 6 10 412s [3,] 3 7 11 412s [4,] 4 8 12 412s min: 412s num [1:4] 1 2 3 4 412s num [1:4] 1 2 3 4 412s num [1:4] 1 2 3 4 412s max: 412s num [1:4] 9 10 11 12 412s num [1:4] 9 10 11 12 412s num [1:4] 9 10 11 12 412s range: 412s num [1:4, 1:2] 1 2 3 4 9 10 11 12 412s num [1:4, 1:2] 1 2 3 4 9 10 11 12 412s num [1:4, 1:2] 1 2 3 4 9 10 11 12 412s real w/ NA (double) w/ na.rm = TRUE: 412s [,1] [,2] [,3] 412s [1,] NA NA NA 412s [2,] NA NA NA 412s [3,] NA NA NA 412s [4,] NA NA NA 412s min: 412s num [1:4] Inf Inf Inf Inf 412s num [1:4] Inf Inf Inf Inf 412s num [1:4] Inf Inf Inf Inf 412s max: 412s num [1:4] -Inf -Inf -Inf -Inf 412s num [1:4] -Inf -Inf -Inf -Inf 412s num [1:4] -Inf -Inf -Inf -Inf 412s range: 412s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 412s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 412s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 412s real w/ NA (double) w/ na.rm = TRUE: 412s [,1] [,2] [,3] 412s [1,] NA NA NA 412s [2,] NA NA NA 412s [3,] NA NA NA 412s [4,] NA NA NA 412s min: 412s num [1:4] Inf Inf Inf Inf 412s num [1:4] Inf Inf Inf Inf 412s num [1:4] Inf Inf Inf Inf 412s max: 412s num [1:4] -Inf -Inf -Inf -Inf 412s num [1:4] -Inf -Inf -Inf -Inf 412s num [1:4] -Inf -Inf -Inf -Inf 412s range: 412s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 412s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 412s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 412s real + NA cell (double) w/ na.rm = TRUE: 412s [,1] [,2] [,3] 412s [1,] 1 5 9 412s [2,] 2 NA 10 412s [3,] 3 7 11 412s [4,] 4 8 12 412s min: 412s num [1:4] 1 2 3 4 412s num [1:4] 1 2 3 4 412s num [1:4] 1 2 3 4 412s max: 412s num [1:4] 9 10 11 12 412s num [1:4] 9 10 11 12 412s num [1:4] 9 10 11 12 412s range: 412s num [1:4, 1:2] 1 2 3 4 9 10 11 12 412s num [1:4, 1:2] 1 2 3 4 9 10 11 12 412s num [1:4, 1:2] 1 2 3 4 9 10 11 12 412s real + NA cell (double) w/ na.rm = TRUE: 412s [,1] [,2] [,3] 412s [1,] 1 5 9 412s [2,] 2 NA 10 412s [3,] 3 7 11 412s [4,] 4 8 12 412s min: 412s num [1:4] 1 2 3 4 412s num [1:4] 1 2 3 4 412s num [1:4] 1 2 3 4 412s max: 412s num [1:4] 9 10 11 12 412s num [1:4] 9 10 11 12 412s num [1:4] 9 10 11 12 412s range: 412s num [1:4, 1:2] 1 2 3 4 9 10 11 12 412s num [1:4, 1:2] 1 2 3 4 9 10 11 12 412s num [1:4, 1:2] 1 2 3 4 9 10 11 12 412s real + NA row (double) w/ na.rm = TRUE: 412s [,1] [,2] [,3] 412s [1,] 1 5 9 412s [2,] NA NA NA 412s [3,] 3 7 11 412s [4,] 4 8 12 412s min: 412s num [1:4] 1 Inf 3 4 412s num [1:4] 1 Inf 3 4 412s num [1:4] 1 Inf 3 4 412s max: 412s num [1:4] 9 -Inf 11 12 412s num [1:4] 9 -Inf 11 12 412s num [1:4] 9 -Inf 11 12 412s range: 412s num [1:4, 1:2] 1 Inf 3 4 9 ... 412s num [1:4, 1:2] 1 Inf 3 4 9 ... 412s num [1:4, 1:2] 1 Inf 3 4 9 ... 412s real + NA row (double) w/ na.rm = TRUE: 412s [,1] [,2] [,3] 412s [1,] 1 5 9 412s [2,] NA NA NA 412s [3,] 3 7 11 412s [4,] 4 8 12 412s min: 412s num [1:4] 1 Inf 3 4 412s num [1:4] 1 Inf 3 4 412s num [1:4] 1 Inf 3 4 412s max: 412s num [1:4] 9 -Inf 11 12 412s num [1:4] 9 -Inf 11 12 412s num [1:4] 9 -Inf 11 12 412s range: 412s num [1:4, 1:2] 1 Inf 3 4 9 ... 412s num [1:4, 1:2] 1 Inf 3 4 9 ... 412s num [1:4, 1:2] 1 Inf 3 4 9 ... 412s real + NaN row (double) w/ na.rm = TRUE: 412s [,1] [,2] [,3] 412s [1,] 1 5 9 412s [2,] NaN NaN NaN 412s [3,] 3 7 11 412s [4,] 4 8 12 412s min: 412s num [1:4] 1 Inf 3 4 412s num [1:4] 1 Inf 3 4 412s num [1:4] 1 Inf 3 4 412s max: 412s num [1:4] 9 -Inf 11 12 412s num [1:4] 9 -Inf 11 12 412s num [1:4] 9 -Inf 11 12 412s range: 412s num [1:4, 1:2] 1 Inf 3 4 9 ... 412s num [1:4, 1:2] 1 Inf 3 4 9 ... 412s num [1:4, 1:2] 1 Inf 3 4 9 ... 412s real + NaN row (double) w/ na.rm = TRUE: 412s [,1] [,2] [,3] 412s [1,] 1 5 9 412s [2,] NaN NaN NaN 412s [3,] 3 7 11 412s [4,] 4 8 12 412s min: 412s num [1:4] 1 Inf 3 4 412s num [1:4] 1 Inf 3 4 412s num [1:4] 1 Inf 3 4 412s max: 412s num [1:4] 9 -Inf 11 12 412s num [1:4] 9 -Inf 11 12 412s num [1:4] 9 -Inf 11 12 412s range: 412s num [1:4, 1:2] 1 Inf 3 4 9 ... 412s num [1:4, 1:2] 1 Inf 3 4 9 ... 412s num [1:4, 1:2] 1 Inf 3 4 9 ... 412s real + Inf cell (double) w/ na.rm = TRUE: 412s [,1] [,2] [,3] 412s [1,] 1 5 9 412s [2,] 2 Inf 10 412s [3,] 3 7 11 412s [4,] 4 8 12 412s min: 412s num [1:4] 1 2 3 4 412s num [1:4] 1 2 3 4 412s num [1:4] 1 2 3 4 412s max: 412s num [1:4] 9 Inf 11 12 412s num [1:4] 9 Inf 11 12 412s num [1:4] 9 Inf 11 12 412s range: 412s num [1:4, 1:2] 1 2 3 4 9 ... 412s num [1:4, 1:2] 1 2 3 4 9 ... 412s num [1:4, 1:2] 1 2 3 4 9 ... 412s real + Inf cell (double) w/ na.rm = TRUE: 412s [,1] [,2] [,3] 412s [1,] 1 5 9 412s [2,] 2 Inf 10 412s [3,] 3 7 11 412s [4,] 4 8 12 412s min: 412s num [1:4] 1 2 3 4 412s num [1:4] 1 2 3 4 412s num [1:4] 1 2 3 4 412s max: 412s num [1:4] 9 Inf 11 12 412s num [1:4] 9 Inf 11 12 412s num [1:4] 9 Inf 11 12 412s range: 412s num [1:4, 1:2] 1 2 3 4 9 ... 412s num [1:4, 1:2] 1 2 3 4 9 ... 412s num [1:4, 1:2] 1 2 3 4 9 ... 412s real + Inf row (double) w/ na.rm = TRUE: 412s [,1] [,2] [,3] 412s [1,] 1 5 9 412s [2,] Inf Inf Inf 412s [3,] 3 7 11 412s [4,] 4 8 12 412s min: 412s num [1:4] 1 Inf 3 4 412s num [1:4] 1 Inf 3 4 412s num [1:4] 1 Inf 3 4 412s max: 412s num [1:4] 9 Inf 11 12 412s num [1:4] 9 Inf 11 12 412s num [1:4] 9 Inf 11 12 412s range: 412s num [1:4, 1:2] 1 Inf 3 4 9 ... 412s num [1:4, 1:2] 1 Inf 3 4 9 ... 412s num [1:4, 1:2] 1 Inf 3 4 9 ... 412s real + Inf row (double) w/ na.rm = TRUE: 412s [,1] [,2] [,3] 412s [1,] 1 5 9 412s [2,] Inf Inf Inf 412s [3,] 3 7 11 412s [4,] 4 8 12 412s min: 412s num [1:4] 1 Inf 3 4 412s num [1:4] 1 Inf 3 4 412s num [1:4] 1 Inf 3 4 412s max: 412s num [1:4] 9 Inf 11 12 412s num [1:4] 9 Inf 11 12 412s num [1:4] 9 Inf 11 12 412s range: 412s num [1:4, 1:2] 1 Inf 3 4 9 ... 412s num [1:4, 1:2] 1 Inf 3 4 9 ... 412s num [1:4, 1:2] 1 Inf 3 4 9 ... 412s real + NaN cell (double) w/ na.rm = TRUE: 412s [,1] [,2] [,3] 412s [1,] 1 5 9 412s [2,] 2 NaN 10 412s [3,] 3 7 11 412s [4,] 4 8 12 412s min: 412s num [1:4] 1 2 3 4 412s num [1:4] 1 2 3 4 412s num [1:4] 1 2 3 4 412s max: 412s num [1:4] 9 10 11 12 412s num [1:4] 9 10 11 12 412s num [1:4] 9 10 11 12 412s range: 412s num [1:4, 1:2] 1 2 3 4 9 10 11 12 412s num [1:4, 1:2] 1 2 3 4 9 10 11 12 412s num [1:4, 1:2] 1 2 3 4 9 10 11 12 412s real + NaN cell (double) w/ na.rm = TRUE: 412s [,1] [,2] [,3] 412s [1,] 1 5 9 412s [2,] 2 NaN 10 412s [3,] 3 7 11 412s [4,] 4 8 12 412s min: 412s num [1:4] 1 2 3 4 412s num [1:4] 1 2 3 4 412s num [1:4] 1 2 3 4 412s max: 412s num [1:4] 9 10 11 12 412s num [1:4] 9 10 11 12 412s num [1:4] 9 10 11 12 412s range: 412s num [1:4, 1:2] 1 2 3 4 9 10 11 12 412s num [1:4, 1:2] 1 2 3 4 9 10 11 12 412s num [1:4, 1:2] 1 2 3 4 9 10 11 12 412s real w/ NA + NaN cell (double) w/ na.rm = TRUE: 412s [,1] [,2] [,3] 412s [1,] NA NA NA 412s [2,] NA NaN NA 412s [3,] NA NA NA 412s [4,] NA NA NA 412s min: 412s num [1:4] Inf Inf Inf Inf 412s num [1:4] Inf Inf Inf Inf 412s num [1:4] Inf Inf Inf Inf 412s max: 412s num [1:4] -Inf -Inf -Inf -Inf 412s num [1:4] -Inf -Inf -Inf -Inf 412s num [1:4] -Inf -Inf -Inf -Inf 412s range: 412s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 412s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 412s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 412s real w/ NA + NaN cell (double) w/ na.rm = TRUE: 412s [,1] [,2] [,3] 412s [1,] NA NA NA 412s [2,] NA NaN NA 412s [3,] NA NA NA 412s [4,] NA NA NA 412s min: 412s num [1:4] Inf Inf Inf Inf 412s num [1:4] Inf Inf Inf Inf 412s num [1:4] Inf Inf Inf Inf 412s max: 412s num [1:4] -Inf -Inf -Inf -Inf 412s num [1:4] -Inf -Inf -Inf -Inf 412s num [1:4] -Inf -Inf -Inf -Inf 412s range: 412s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 412s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 412s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 412s real w/ NA + NaN row (double) w/ na.rm = TRUE: 412s [,1] [,2] [,3] 412s [1,] NA NA NA 412s [2,] NaN NaN NaN 412s [3,] NA NA NA 412s [4,] NA NA NA 412s min: 412s num [1:4] Inf Inf Inf Inf 412s num [1:4] Inf Inf Inf Inf 412s num [1:4] Inf Inf Inf Inf 412s max: 412s num [1:4] -Inf -Inf -Inf -Inf 412s num [1:4] -Inf -Inf -Inf -Inf 412s num [1:4] -Inf -Inf -Inf -Inf 412s range: 412s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 412s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 412s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 412s real w/ NA + NaN row (double) w/ na.rm = TRUE: 412s [,1] [,2] [,3] 412s [1,] NA NA NA 412s [2,] NaN NaN NaN 412s [3,] NA NA NA 412s [4,] NA NA NA 412s min: 412s num [1:4] Inf Inf Inf Inf 412s num [1:4] Inf Inf Inf Inf 412s num [1:4] Inf Inf Inf Inf 412s max: 412s num [1:4] -Inf -Inf -Inf -Inf 412s num [1:4] -Inf -Inf -Inf -Inf 412s num [1:4] -Inf -Inf -Inf -Inf 412s range: 412s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 412s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 412s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 412s > 412s 412s R version 4.4.3 (2025-02-28) -- "Trophy Case" 412s Copyright (C) 2025 The R Foundation for Statistical Computing 412s Platform: arm-unknown-linux-gnueabihf (32-bit) 412s 412s R is free software and comes with ABSOLUTELY NO WARRANTY. 412s You are welcome to redistribute it under certain conditions. 412s Type 'license()' or 'licence()' for distribution details. 412s 412s R is a collaborative project with many contributors. 412s Type 'contributors()' for more information and 412s 'citation()' on how to cite R or R packages in publications. 412s 412s Type 'demo()' for some demos, 'help()' for on-line help, or 412s 'help.start()' for an HTML browser interface to help. 412s Type 'q()' to quit R. 412s 412s > library("matrixStats") 412s > 412s > rowMins_R <- function(x, ..., useNames = TRUE) { 412s + suppressWarnings({ 412s + res <- apply(x, MARGIN = 1L, FUN = min, ...) 412s + }) 412s + if (!useNames) names(res) <- NULL 412s + res 412s + } # rowMins_R() 412s > 412s > rowMaxs_R <- function(x, ..., useNames = TRUE) { 412s + suppressWarnings({ 412s + res <- apply(x, MARGIN = 1L, FUN = max, ...) 412s + }) 412s + if (!useNames) names(res) <- NULL 412s + res 412s + } # rowMaxs_R() 412s > 412s > rowRanges_R <- function(x, ..., useNames = TRUE) { 412s + suppressWarnings({ 412s + ans <- t(apply(x, MARGIN = 1L, FUN = range, ...)) 412s + }) 412s + 412s + # Preserve rownames attribute 412s + dim <- c(dim(x)[1], 2L) 412s + if (!isTRUE(all.equal(dim(ans), dim))) { 412s + dim(ans) <- dim 412s + rownames <- rownames(x) 412s + if (!is.null(dimnames)) rownames(ans) <- rownames 412s + } 412s + if (!useNames) dimnames(ans) <- NULL 412s + ans 412s + } # rowRanges_R() 412s > 412s > 412s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 412s > # Subsetted tests 412s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 412s > source("utils/validateIndicesFramework.R") 412s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 412s > storage.mode(x) <- "integer" 412s > 412s > # To check rownames/names attributes 412s > dimnames <- list(letters[1:6], LETTERS[1:6]) 412s > 412s > # Test with and without dimnames on x 412s > for (setDimnames in c(TRUE, FALSE)) { 412s + if (setDimnames) dimnames(x) <- dimnames 412s + else dimnames(x) <- NULL 412s + 412s + count <- 0L 412s + for (rows in index_cases) { 412s + for (cols in index_cases) { 412s + count <- count + 1L 412s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 412s + useNames <- c(TRUE, FALSE) 412s + useNames <- useNames[count %% length(useNames) + 1] 412s + 412s + validateIndicesTestMatrix(x, rows, cols, 412s + ftest = rowRanges, fsure = rowRanges_R, 412s + na.rm = na.rm, useNames = useNames) 412s + validateIndicesTestMatrix(x, rows, cols, 412s + ftest = rowMins, fsure = rowMins_R, 412s + na.rm = na.rm, useNames = useNames) 412s + validateIndicesTestMatrix(x, rows, cols, 412s + ftest = rowMaxs, fsure = rowMaxs_R, 412s + na.rm = na.rm, useNames = useNames) 412s + 412s + validateIndicesTestMatrix(x, rows, cols, 412s + fcoltest = colRanges, fsure = rowRanges_R, 412s + na.rm = na.rm, useNames = useNames) 412s + validateIndicesTestMatrix(x, rows, cols, 412s + fcoltest = colMins, fsure = rowMins_R, 412s + na.rm = na.rm, useNames = useNames) 412s + validateIndicesTestMatrix(x, rows, cols, 412s + fcoltest = colMaxs, fsure = rowMaxs_R, 412s + na.rm = na.rm, useNames = useNames) 412s + } 412s + } 412s + } 414s > 414s 414s R version 4.4.3 (2025-02-28) -- "Trophy Case" 414s Copyright (C) 2025 The R Foundation for Statistical Computing 414s Platform: arm-unknown-linux-gnueabihf (32-bit) 414s 414s R is free software and comes with ABSOLUTELY NO WARRANTY. 414s You are welcome to redistribute it under certain conditions. 414s Type 'license()' or 'licence()' for distribution details. 414s 414s R is a collaborative project with many contributors. 414s Type 'contributors()' for more information and 414s 'citation()' on how to cite R or R packages in publications. 414s 414s Type 'demo()' for some demos, 'help()' for on-line help, or 414s 'help.start()' for an HTML browser interface to help. 414s Type 'q()' to quit R. 414s 414s > library("matrixStats") 414s > 414s > dense_rank <- function(x) match(x, table = sort(unique(x))) 414s > 414s > rowRanks_R <- function(x, ties.method, ..., useNames = TRUE) { 414s + if (ties.method == "dense") { 414s + res <- t(apply(x, MARGIN = 1L, FUN = dense_rank)) 414s + } else { 414s + res <- t(apply(x, MARGIN = 1L, FUN = rank, na.last = "keep", ties.method = ties.method)) 414s + } 414s + 414s + # Preserve dimnames attribute? 414s + dim(res) <- dim(x) 414s + dimnames(res) <- if (useNames) dimnames(x) else NULL 414s + 414s + res 414s + } 414s > 414s > colRanks_R <- function(x, ties.method, preserveShape = FALSE, ..., useNames = TRUE) { 414s + if (ties.method == "dense") { 414s + res <- t(apply(x, MARGIN = 2L, FUN = dense_rank)) 414s + } else { 414s + res <- t(apply(x, MARGIN = 2L, FUN = rank, na.last = "keep", ties.method = ties.method)) 414s + } 414s + 414s + # Preserve dimnames attribute? 414s + tx <- t(x) 414s + dim(res) <- dim(tx) 414s + dimnames(res) <- if (useNames) dimnames(tx) else NULL 414s + 414s + if (preserveShape) res <- t(res) 414s + res 414s + } 414s > 414s > set.seed(1) 414s > 414s > cat("Consistency checks:\n") 414s Consistency checks: 414s > xs <- vector("list", length = 4L) 414s > for (kk in 1:4) { 414s + 414s + # Simulate data in a matrix of any shape 414s + dim <- sample(40:80, size = 2L) 414s + n <- prod(dim) 414s + x <- rnorm(n, sd = 10) 414s + dim(x) <- dim 414s + 414s + # Add NAs? 414s + if ((kk %% 4) %in% c(3, 0)) { 414s + cat("Adding NAs\n") 414s + nna <- sample(n, size = 1L) 414s + x[sample(length(x), size = nna)] <- NA_real_ 414s + } 414s + 414s + # Integer or double? 414s + if ((kk %% 4) %in% c(2, 0)) { 414s + cat("Coercing to integers\n") 414s + storage.mode(x) <- "integer" 414s + } 414s + 414s + xs[[kk]] <- x 414s + } # for (kk ...) 414s Coercing to integers 414s Adding NAs 414s Adding NAs 414s Coercing to integers 414s > str(xs) 414s List of 4 414s $ : num [1:43, 1:78] 13.3 12.72 4.15 -15.4 -9.29 ... 414s $ : int [1:46, 1:61] 2 11 -16 -5 19 5 26 -13 1 -9 ... 414s $ : num [1:42, 1:47] NA -22.3 NA NA NA ... 414s $ : int [1:42, 1:78] NA NA NA NA NA NA NA NA NA NA ... 414s > 414s > for (kk in 1:4) { 414s + cat("Random test #", kk, "\n", sep = "") 414s + x <- xs[[kk]] 414s + tx <- t(x) 414s + 414s + for (ties in c("max", "min", "average", "first", "last", "dense")) { 414s + cat(sprintf("ties.method = %s\n", ties)) 414s + # rowRanks(): 414s + y1 <- matrixStats::rowRanks(x, ties.method = ties) 414s + y2 <- rowRanks_R(x, ties.method = ties) 414s + stopifnot(identical(y1, y2)) 414s + 414s + y3 <- matrixStats::colRanks(tx, ties.method = ties) 414s + stopifnot(identical(y1, y3)) 414s + 414s + # colRanks(): 414s + y1 <- matrixStats::colRanks(x, ties.method = ties) 414s + y2 <- colRanks_R(x, ties.method = ties) 414s + stopifnot(identical(y1, y2)) 414s + 414s + y3 <- matrixStats::rowRanks(tx, ties.method = ties) 414s + stopifnot(identical(y1, y3)) 414s + } 414s + } # for (kk ...) 414s Random test #1 414s ties.method = max 414s ties.method = min 415s ties.method = average 415s ties.method = first 415s ties.method = last 415s ties.method = dense 415s Random test #2 415s ties.method = max 415s ties.method = min 415s ties.method = average 415s ties.method = first 415s ties.method = last 415s ties.method = dense 415s Random test #3 415s ties.method = max 415s ties.method = min 415s ties.method = average 415s ties.method = first 415s ties.method = last 415s ties.method = dense 415s Random test #4 415s ties.method = max 415s ties.method = min 415s ties.method = average 415s ties.method = first 415s ties.method = last 415s ties.method = dense 415s > 415s > # Note, below we know ties.method %in% c("min", "max", "average") is correct 415s > 415s > cat("Consistency checks for random:\n") 415s Consistency checks for random: 415s > tolerance <- 0.1 415s > nsamples <- 10000 415s > for (kk in 1:4) { 415s + cat("Random test #", kk, "\n", sep = "") 415s + x <- xs[[kk]] 415s + tx <- t(x) 415s + 415s + for (ties in c("random")) { 415s + cat(sprintf("ties.method = %s\n", ties)) 415s + 415s + ## rowRanks(): 415s + y0 <- rowRanks_R(x, ties.method = ties) 415s + y1 <- matrixStats::rowRanks(x, ties.method = ties) 415s + 415s + ## Assert symmetric rank differences 415s + d <- y1 - y0 415s + stopifnot(all(rowSums(d) == 0, na.rm = TRUE)) 415s + 415s + ## Assert within [min, max] 415s + y2min <- matrixStats::rowRanks(x, ties.method = "min") 415s + y2max <- matrixStats::rowRanks(x, ties.method = "max") 415s + stopifnot(all(y1 >= y2min, na.rm = TRUE) && all(y1 <= y2max, na.rm = TRUE)) 415s + ## Assert near average 415s + y1list <- replicate(nsamples, matrixStats::rowRanks(x, ties.method = ties), simplify = FALSE) 415s + y1mean <- Reduce(`+`, y1list) / nsamples 415s + y2avg <- matrixStats::rowRanks(x, ties.method = "average") 415s + stopifnot(all(abs(y1mean - y2avg) < tolerance, na.rm = TRUE)) 415s + 415s + ## colRanks(): 415s + y0 <- colRanks_R(x, ties.method = ties) 415s + y1 <- matrixStats::colRanks(x, ties.method = ties) 415s + 415s + ## Assert symmetric rank differences 415s + d <- y1 - y0 415s + stopifnot(all(rowSums(d) == 0, na.rm = TRUE)) 415s + 415s + ## Assert within [min, max] 415s + y2min <- matrixStats::colRanks(x, ties.method = "min") 415s + y2max <- matrixStats::colRanks(x, ties.method = "max") 415s + stopifnot(all(y1 >= y2min, na.rm = TRUE) && all(y1 <= y2max, na.rm = TRUE)) 415s + y1list <- replicate(nsamples, matrixStats::colRanks(x, ties.method = ties), simplify = FALSE) 415s + y1mean <- Reduce(`+`, y1list) / nsamples 415s + ## Assert near average 415s + y2avg <- matrixStats::colRanks(x, ties.method = "average") 415s + stopifnot(all(abs(y1mean - y2avg) < tolerance, na.rm = TRUE)) 415s + } 415s + } # for (kk ...) 415s Random test #1 415s ties.method = random 419s Random test #2 419s ties.method = random 422s Random test #3 422s ties.method = random 423s Random test #4 423s ties.method = random 424s > 424s > 424s > ## Exception handling 424s > x <- matrix(1:12, nrow = 3L, ncol = 4L) 424s > y <- try(rowRanks(x, ties.method = "unknown"), silent = TRUE) 424s > stopifnot(inherits(y, "try-error")) 424s > 424s > y <- try(colRanks(x, ties.method = "unknown"), silent = TRUE) 424s > stopifnot(inherits(y, "try-error")) 424s > 424s > dimnames <- list(letters[1:3], LETTERS[1:4]) 424s > for (mode in c("integer", "double")){ 424s + storage.mode(x) <- mode 424s + # Test with and without dimnames on x 424s + for (setDimnames in c(TRUE, FALSE)) { 424s + if (setDimnames) dimnames(x) <- dimnames 424s + else dimnames(x) <- NULL 424s + # Check names attribute 424s + for (useNames in c(TRUE, FALSE)) { 424s + for (ties in c("max", "min", "average", "first", "last", "dense", "random")) { 424s + cat(sprintf("ties.method = %s\n", ties)) 424s + # rowRanks(): 424s + y1 <- matrixStats::rowRanks(x, ties.method = ties, useNames = useNames) 424s + y2 <- rowRanks_R(x, ties.method = ties, useNames = useNames) 424s + stopifnot(identical(y1, y2)) 424s + 424s + y3 <- matrixStats::colRanks(t(x), ties.method = ties, useNames = useNames) 424s + stopifnot(identical(y1, y3)) 424s + 424s + # colRanks(): 424s + y1 <- matrixStats::colRanks(x, ties.method = ties, useNames = useNames) 424s + y2 <- colRanks_R(x, ties.method = ties, useNames = useNames) 424s + stopifnot(identical(y1, y2)) 424s + 424s + y3 <- matrixStats::rowRanks(t(x), ties.method = ties, useNames = useNames) 424s + stopifnot(identical(y1, y3)) 424s + 424s + # Check preserveShape 424s + y1 <- matrixStats::colRanks(x, ties.method = ties, preserveShape = TRUE, useNames = useNames) 424s + y2 <- colRanks_R(x, ties.method = ties, preserveShape = TRUE, useNames = useNames) 424s + stopifnot(identical(y1, y2)) 424s + } 424s + } 424s + } 424s + } 424s ties.method = max 424s ties.method = min 424s ties.method = average 424s ties.method = first 424s ties.method = last 424s ties.method = dense 424s ties.method = random 424s ties.method = max 424s ties.method = min 424s ties.method = average 424s ties.method = first 424s ties.method = last 424s ties.method = dense 424s ties.method = random 424s ties.method = max 424s ties.method = min 424s ties.method = average 424s ties.method = first 424s ties.method = last 424s ties.method = dense 424s ties.method = random 424s ties.method = max 424s ties.method = min 424s ties.method = average 424s ties.method = first 424s ties.method = last 424s ties.method = dense 424s ties.method = random 424s ties.method = max 424s ties.method = min 424s ties.method = average 424s ties.method = first 424s ties.method = last 424s ties.method = dense 424s ties.method = random 424s ties.method = max 424s ties.method = min 424s ties.method = average 424s ties.method = first 425s ties.method = last 425s ties.method = dense 425s ties.method = random 425s ties.method = max 425s ties.method = min 425s ties.method = average 425s ties.method = first 425s ties.method = last 425s ties.method = dense 425s ties.method = random 425s ties.method = max 425s ties.method = min 425s ties.method = average 425s ties.method = first 425s ties.method = last 425s ties.method = dense 425s ties.method = random 425s > 425s 425s R version 4.4.3 (2025-02-28) -- "Trophy Case" 425s Copyright (C) 2025 The R Foundation for Statistical Computing 425s Platform: arm-unknown-linux-gnueabihf (32-bit) 425s 425s R is free software and comes with ABSOLUTELY NO WARRANTY. 425s You are welcome to redistribute it under certain conditions. 425s Type 'license()' or 'licence()' for distribution details. 425s 425s R is a collaborative project with many contributors. 425s Type 'contributors()' for more information and 425s 'citation()' on how to cite R or R packages in publications. 425s 425s Type 'demo()' for some demos, 'help()' for on-line help, or 425s 'help.start()' for an HTML browser interface to help. 425s Type 'q()' to quit R. 425s 425s > library("matrixStats") 425s > 425s > rowRanks_R <- function(x, ties.method = "average", ..., useNames = TRUE) { 425s + ans <- t(apply(x, MARGIN = 1L, FUN = rank, na.last = "keep", 425s + ties.method = ties.method)) 425s + 425s + # Preserve dimnames attribute? 425s + dim(ans) <- dim(x) 425s + dimnames(ans) <- if (useNames) dimnames(x) else NULL 425s + 425s + ans 425s + } 425s > 425s > colRanks_R <- function(x, ties.method, preserveShape = FALSE, ..., useNames = TRUE) { 425s + ans <- t(apply(x, MARGIN = 2L, FUN = rank, na.last = "keep", ties.method = ties.method)) 425s + 425s + # Preserve dimnames attribute? 425s + tx <- t(x) 425s + dim(ans) <- dim(tx) 425s + dimnames(ans) <- if (useNames) dimnames(tx) else NULL 425s + 425s + if (preserveShape) ans <- t(ans) 425s + ans 425s + } 425s > 425s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 425s > # Subsetted tests 425s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 425s > source("utils/validateIndicesFramework.R") 425s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 425s > storage.mode(x) <- "integer" 425s > 425s > # To check dimnames attribute 425s > dimnames <- list(letters[1:6], LETTERS[1:6]) 425s > 425s > colRanks_R_t <- function(x, rows, cols, ..., useNames = TRUE) { 425s + t(colRanks(t(x), rows = cols, cols = rows, preserveShape = TRUE, ..., useNames = useNames)) 425s + } 425s > 425s > # Test with and without dimnames on x 425s > for (setDimnames in c(TRUE, FALSE)) { 425s + if (setDimnames) dimnames(x) <- dimnames 425s + else dimnames(x) <- NULL 425s + 425s + count <- 0L 425s + for (rows in index_cases) { 425s + for (cols in index_cases) { 425s + count <- count + 1L 425s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 425s + useNames <- c(TRUE, FALSE) 425s + useNames <- useNames[count %% length(useNames) + 1] 425s + 425s + validateIndicesTestMatrix(x, rows, cols, 425s + ftest = rowRanks, fsure = rowRanks_R, 425s + ties.method = "average", useNames = useNames) 425s + 425s + validateIndicesTestMatrix(x, rows, cols, 425s + ftest = colRanks_R_t, fsure = rowRanks_R, 425s + ties.method = "average", useNames = useNames) 425s + 425s + for (perserveShape in c(TRUE, FALSE)) { 425s + validateIndicesTestMatrix(x, rows, cols, 425s + ftest = colRanks, fsure = colRanks_R, 425s + ties.method = "average", perserveShape = perserveShape, 425s + useNames = useNames) 425s + } 425s + } 425s + } 425s + } 427s > 427s 427s R version 4.4.3 (2025-02-28) -- "Trophy Case" 427s Copyright (C) 2025 The R Foundation for Statistical Computing 427s Platform: arm-unknown-linux-gnueabihf (32-bit) 427s 427s R is free software and comes with ABSOLUTELY NO WARRANTY. 427s You are welcome to redistribute it under certain conditions. 427s Type 'license()' or 'licence()' for distribution details. 427s 427s R is a collaborative project with many contributors. 427s Type 'contributors()' for more information and 427s 'citation()' on how to cite R or R packages in publications. 427s 427s Type 'demo()' for some demos, 'help()' for on-line help, or 427s 'help.start()' for an HTML browser interface to help. 427s Type 'q()' to quit R. 427s 427s > library("matrixStats") 427s > 427s > ## Always allow testing of the 'center' argument (as long as it's not defunct) 427s > options(matrixStats.center.onUse = "ignore") 427s > 427s > ## Create isFALSE() if running on an old version of R 427s > if (!exists("isFALSE", mode="function")) { 427s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 427s + } 427s > 427s > rowSds_R <- function(x, na.rm = FALSE, center = NULL, ..., useNames = TRUE) { 427s + suppressWarnings({ 427s + sigma <- apply(x, MARGIN = 1L, FUN = sd, na.rm = na.rm) 427s + }) 427s + stopifnot(!any(is.infinite(sigma))) 427s + 427s + # Keep naming support consistency same as rowSds() 427s + if (is.null(center) || ncol(x) <= 1L) { 427s + if (isFALSE(useNames)) names(sigma) <- NULL 427s + } 427s + else if (isFALSE(useNames)) names(sigma) <- NULL 427s + sigma 427s + } 427s > 427s > colSds_R <- function(x, na.rm = FALSE, center = NULL, ..., useNames = TRUE) { 427s + suppressWarnings({ 427s + sigma <- apply(x, MARGIN = 2L, FUN = sd, na.rm = na.rm) 427s + }) 427s + stopifnot(!any(is.infinite(sigma))) 427s + 427s + # Keep naming support consistency same as colSds() 427s + if (is.null(center) || nrow(x) <= 1L) { 427s + if (isFALSE(useNames)) names(sigma) <- NULL 427s + } 427s + if (isFALSE(useNames)) names(sigma) <- NULL 427s + sigma 427s + } 427s > 427s > 427s > rowSds_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) { 427s + center <- rowWeightedMeans(x, cols = cols, na.rm = na.rm, useNames = FALSE) 427s + sigma <- rowSds(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 427s + stopifnot(!any(is.infinite(sigma))) 427s + sigma 427s + } 427s > 427s > colSds_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) { 427s + center <- colWeightedMeans(x, rows = rows, na.rm = na.rm, useNames = FALSE) 427s + sigma <- colSds(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 428s + stopifnot(!any(is.infinite(sigma))) 428s + sigma 428s + } 428s > 428s > 428s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 428s > # With and without some NAs 428s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 428s > for (mode in c("integer", "double")) { 428s + for (add_na in c(FALSE, TRUE)) { 428s + cat("add_na = ", add_na, "\n", sep = "") 428s + 428s + x <- matrix(1:50 + 0.1, nrow = 10L, ncol = 5L) 428s + if (add_na) { 428s + x[3:7, c(2, 4)] <- NA_real_ 428s + } 428s + cat("mode: ", mode, "\n", sep = "") 428s + storage.mode(x) <- mode 428s + str(x) 428s + 428s + # To check names attribute 428s + dimnames <- list(letters[1:10], LETTERS[1:5]) 428s + 428s + # Test with and without dimnames on x 428s + for (setDimnames in c(TRUE, FALSE)) { 428s + if (setDimnames) dimnames(x) <- dimnames 428s + else dimnames(x) <- NULL 428s + # Row/column ranges 428s + for (na.rm in c(FALSE, TRUE)) { 428s + # Check names attribute 428s + for (useNames in c(TRUE, FALSE)) { 428s + r0 <- rowSds_R(x, na.rm = na.rm, useNames = useNames) 428s + r1 <- rowSds(x, na.rm = na.rm, useNames = useNames) 428s + r1b <- rowSds_center(x, na.rm = na.rm, useNames = useNames) 428s + r2 <- colSds(t(x), na.rm = na.rm, useNames = useNames) 428s + r2b <- colSds_center(t(x), na.rm = na.rm, useNames = useNames) 428s + stopifnot(all.equal(r1, r2)) 428s + stopifnot(all.equal(r1, r0)) 428s + stopifnot(all.equal(r2, r0)) 428s + stopifnot(all.equal(r1b, r2b)) 428s + stopifnot( 428s + !any(is.infinite(r1)), 428s + !any(is.infinite(r2)), 428s + !any(is.infinite(r1b)), 428s + !any(is.infinite(r2b)) 428s + ) 428s + } 428s + } 428s + } 428s + } # for (add_na ...) 428s + } 428s add_na = FALSE 428s mode: integer 428s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 428s add_na = TRUE 428s mode: integer 428s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 428s add_na = FALSE 428s mode: double 428s 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 ... 428s add_na = TRUE 428s mode: double 428s 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 ... 428s > 428s > 428s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 428s > # All NAs 428s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 428s > for (mode in c("integer", "double")) { 428s + x <- matrix(NA_real_, nrow = 10L, ncol = 5L) 428s + cat("mode: ", mode, "\n", sep = "") 428s + storage.mode(x) <- mode 428s + str(x) 428s + 428s + # Test with and without dimnames on x 428s + for (setDimnames in c(TRUE, FALSE)) { 428s + if (setDimnames) dimnames(x) <- dimnames 428s + else dimnames(x) <- NULL 428s + # Row/column ranges 428s + for (na.rm in c(FALSE, TRUE)) { 428s + # Check names attribute 428s + for (useNames in c(TRUE, FALSE)) { 428s + r0 <- rowSds_R(x, na.rm = na.rm, useNames = useNames) 428s + r1 <- rowSds(x, na.rm = na.rm, useNames = useNames) 428s + r1b <- rowSds_center(x, na.rm = na.rm, useNames = useNames) 428s + r2 <- colSds(t(x), na.rm = na.rm, useNames = useNames) 428s + r2b <- colSds_center(t(x), na.rm = na.rm, useNames = useNames) 428s + stopifnot(all.equal(r1, r2)) 428s + stopifnot(all.equal(r1, r0)) 428s + stopifnot(all.equal(r2, r0)) 428s + stopifnot(all.equal(r1b, r2b)) 428s + stopifnot( 428s + !any(is.infinite(r1)), 428s + !any(is.infinite(r2)), 428s + !any(is.infinite(r1b)), 428s + !any(is.infinite(r2b)) 428s + ) 428s + } 428s + } 428s + } 428s + } 428s mode: integer 428s int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 428s mode: double 428s num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 428s > 428s > 428s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 428s > # A 1x1 matrix 428s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 428s > x <- matrix(0, nrow = 1L, ncol = 1L) 428s > dimnames <- list("a", "A") 428s > for (na.rm in c(FALSE, TRUE)) { 428s + cat("na.rm = ", na.rm, "\n", sep = "") 428s + 428s + # Test with and without dimnames on x 428s + for (setDimnames in c(TRUE, FALSE)) { 428s + if (setDimnames) dimnames(x) <- dimnames 428s + else dimnames(x) <- NULL 428s + # Row/column ranges 428s + for (na.rm in c(FALSE, TRUE)) { 428s + # Check names attribute 428s + for (useNames in c(TRUE, FALSE)) { 428s + r0 <- rowSds_R(x, na.rm = na.rm, useNames = useNames) 428s + r1 <- rowSds(x, na.rm = na.rm, useNames = useNames) 428s + r1b <- rowSds_center(x, na.rm = na.rm, useNames = useNames) 428s + r2 <- colSds(t(x), na.rm = na.rm, useNames = useNames) 428s + r2b <- colSds_center(t(x), na.rm = na.rm, useNames = useNames) 428s + stopifnot(all.equal(r1, r2)) 428s + stopifnot(all.equal(r1, r0)) 428s + stopifnot(all.equal(r2, r0)) 428s + stopifnot(all.equal(r1b, r2b)) 428s + stopifnot( 428s + !any(is.infinite(r1)), 428s + !any(is.infinite(r2)), 428s + !any(is.infinite(r1b)), 428s + !any(is.infinite(r2b)) 428s + ) 428s + } 428s + } 428s + } 428s + } 428s na.rm = FALSE 428s na.rm = TRUE 428s > 428s 428s R version 4.4.3 (2025-02-28) -- "Trophy Case" 428s Copyright (C) 2025 The R Foundation for Statistical Computing 428s Platform: arm-unknown-linux-gnueabihf (32-bit) 428s 428s R is free software and comes with ABSOLUTELY NO WARRANTY. 428s You are welcome to redistribute it under certain conditions. 428s Type 'license()' or 'licence()' for distribution details. 428s 428s R is a collaborative project with many contributors. 428s Type 'contributors()' for more information and 428s 'citation()' on how to cite R or R packages in publications. 428s 428s Type 'demo()' for some demos, 'help()' for on-line help, or 428s 'help.start()' for an HTML browser interface to help. 428s Type 'q()' to quit R. 428s 428s > library("matrixStats") 428s > 428s > ## Always allow testing of the 'center' argument (as long as it's not defunct) 428s > options(matrixStats.center.onUse = "ignore") 428s > 428s > ## Create isFALSE() if running on an old version of R 428s > if (!exists("isFALSE", mode="function")) { 428s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 428s + } 428s > 428s > rowSds_R <- function(x, na.rm = FALSE, center = NULL, ..., useNames = TRUE) { 428s + suppressWarnings({ 428s + sigma <- apply(x, MARGIN = 1L, FUN = sd, na.rm = na.rm) 428s + }) 428s + stopifnot(!any(is.infinite(sigma))) 428s + 428s + # Keep naming support consistency same as rowSds() 428s + if (is.null(center) || ncol(x) <= 1L) { 428s + if (isFALSE(useNames)) names(sigma) <- NULL 428s + } 428s + else if (isFALSE(useNames)) names(sigma) <- NULL 428s + sigma 428s + } 428s > 428s > colSds_R <- function(x, na.rm = FALSE, center = NULL, ..., useNames = TRUE) { 428s + suppressWarnings({ 428s + sigma <- apply(x, MARGIN = 2L, FUN = sd, na.rm = na.rm) 428s + }) 428s + stopifnot(!any(is.infinite(sigma))) 428s + 428s + # Keep naming support consistency same as colSds() 428s + if (is.null(center) || nrow(x) <= 1L) { 428s + if (isFALSE(useNames)) names(sigma) <- NULL 428s + } 428s + else if (isFALSE(useNames)) names(sigma) <- NULL 428s + sigma 428s + } 428s > 428s > 428s > rowSds_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) { 428s + center <- rowWeightedMeans(x, cols = cols, na.rm = na.rm, useNames = FALSE) 428s + sigma <- rowSds(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 428s + stopifnot(!any(is.infinite(sigma))) 428s + sigma 428s + } 428s > 428s > colSds_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) { 428s + center <- colWeightedMeans(x, rows = rows, na.rm = na.rm, useNames = FALSE) 428s + sigma <- colSds(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 428s + stopifnot(!any(is.infinite(sigma))) 428s + sigma 428s + } 428s > 428s > 428s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 428s > # Subsetted tests 428s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 428s > source("utils/validateIndicesFramework.R") 428s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 428s > storage.mode(x) <- "integer" 428s > 428s > # To check names attribute 428s > dimnames <- list(letters[1:6], LETTERS[1:6]) 428s > 428s > # Test with and without dimnames on x 428s > for (setDimnames in c(TRUE, FALSE)) { 428s + if (setDimnames) dimnames(x) <- dimnames 428s + else dimnames(x) <- NULL 428s + 428s + count <- 0L 428s + for (rows in index_cases) { 428s + for (cols in index_cases) { 428s + count <- count + 1L 428s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 428s + useNames <- c(TRUE, FALSE) 428s + useNames <- useNames[count %% length(useNames) + 1] 428s + 428s + validateIndicesTestMatrix(x, rows, cols, 428s + ftest = rowSds, fsure = rowSds_R, 428s + na.rm = na.rm, useNames = useNames) 428s + validateIndicesTestMatrix(x, rows, cols, 428s + ftest = rowSds_center, fsure = rowSds_R, 428s + na.rm = na.rm, center = TRUE, useNames = useNames) 428s + 428s + validateIndicesTestMatrix(x, rows, cols, 428s + fcoltest = colSds, fsure = rowSds_R, 428s + na.rm = na.rm, useNames = useNames) 428s + validateIndicesTestMatrix(x, rows, cols, 428s + fcoltest = colSds_center, fsure = rowSds_R, 428s + na.rm = na.rm, center = TRUE, useNames = useNames) 428s + } 428s + } 428s + } 429s > 429s 429s R version 4.4.3 (2025-02-28) -- "Trophy Case" 429s Copyright (C) 2025 The R Foundation for Statistical Computing 429s Platform: arm-unknown-linux-gnueabihf (32-bit) 429s 429s R is free software and comes with ABSOLUTELY NO WARRANTY. 429s You are welcome to redistribute it under certain conditions. 429s Type 'license()' or 'licence()' for distribution details. 429s 429s R is a collaborative project with many contributors. 429s Type 'contributors()' for more information and 429s 'citation()' on how to cite R or R packages in publications. 429s 429s Type 'demo()' for some demos, 'help()' for on-line help, or 429s 'help.start()' for an HTML browser interface to help. 429s Type 'q()' to quit R. 429s 429s > library("matrixStats") 429s > 429s > rowSums2_R <- function(x, na.rm = FALSE, ..., useNames = TRUE) { 429s + ## FIXME: sum() may overflow for integers, whereas 429s + ## base::rowSums() doesn't. What should rowSums2() do? 429s + ## apply(x, MARGIN = 1L, FUN = sum, na.rm = na.rm) 429s + res <- rowSums(x, na.rm = na.rm) 429s + if (!useNames) names(res) <- NULL 429s + res 429s + } 429s > 429s > colSums2_R <- function(x, na.rm = FALSE, ..., useNames = TRUE) { 429s + ## FIXME: sum() may overflow for integers, whereas 429s + ## base::colSums() doesn't. What should colSums2() do? 429s + ## apply(x, MARGIN = 2L, FUN = sum, na.rm = na.rm) 429s + res <- colSums(x, na.rm = na.rm) 429s + if (!useNames) names(res) <- NULL 429s + res 429s + } 429s > 429s > for (mode in c("integer", "logical", "double")) { 429s + x <- matrix(-4:4, nrow = 3, ncol = 3) 429s + storage.mode(x) <- mode 429s + if (mode == "double") x <- x + 0.1 429s + 429s + # To check names attribute 429s + dimnames <- list(letters[1:3], LETTERS[1:3]) 429s + 429s + # Test with and without dimnames on x 429s + for (setDimnames in c(TRUE, FALSE)) { 429s + if (setDimnames) dimnames(x) <- dimnames 429s + else dimnames(x) <- NULL 429s + # Check names attribute 429s + for (useNames in c(TRUE, FALSE)) { 429s + y0 <- rowSums2_R(x, na.rm = FALSE, useNames = useNames) 429s + y1 <- rowSums2(x, na.rm = FALSE, useNames = useNames) 429s + stopifnot(all.equal(y1, y0)) 429s + 429s + y0 <- colSums2_R(x, na.rm = FALSE, useNames = useNames) 429s + y1 <- colSums2(x, na.rm = FALSE, useNames = useNames) 429s + stopifnot(all.equal(y1, y0)) 429s + } 429s + } 429s + } 429s > 429s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 429s > # Special case: Single-element matrix 429s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 429s > cat("Special case: Single-element matrix:\n") 429s Special case: Single-element matrix: 429s > for (mode in c("integer", "logical", "double")) { 429s + x <- matrix(1, nrow = 1, ncol = 1) 429s + storage.mode(x) <- mode 429s + 429s + # To check names attribute 429s + dimnames <- list("a", "A") 429s + 429s + # Test with and without dimnames on x 429s + for (setDimnames in c(TRUE, FALSE)) { 429s + if (setDimnames) dimnames(x) <- dimnames 429s + else dimnames(x) <- NULL 429s + # Check names attribute 429s + for (useNames in c(TRUE, FALSE)) { 429s + y0 <- rowSums2_R(x, na.rm = FALSE, useNames = useNames) 429s + y1 <- rowSums2(x, na.rm = FALSE, useNames = useNames) 429s + stopifnot(all.equal(y1, y0)) 429s + 429s + y0 <- colSums2_R(x, na.rm = FALSE, useNames = useNames) 429s + y1 <- colSums2(x, na.rm = FALSE, useNames = useNames) 429s + stopifnot(all.equal(y1, y0)) 429s + } 429s + } 429s + } 429s > 429s > 429s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 429s > # Special case: Empty matrix 429s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 429s > cat("Special case: Empty matrix:\n") 429s Special case: Empty matrix: 429s > for (mode in c("integer", "logical", "double")) { 429s + x <- matrix(integer(0), nrow = 0, ncol = 0) 429s + storage.mode(x) <- mode 429s + 429s + y0 <- rowSums2_R(x, na.rm = FALSE) 429s + y1 <- rowSums2(x, na.rm = FALSE) 429s + stopifnot(all.equal(y1, y0)) 429s + 429s + y0 <- colSums2_R(x, na.rm = FALSE) 429s + y1 <- colSums2(x, na.rm = FALSE) 429s + stopifnot(all.equal(y1, y0)) 429s + } 429s > 429s > 429s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 429s > # Special case: All NAs 429s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 429s > cat("Special case: All NAs:\n") 429s Special case: All NAs: 429s > for (mode in c("integer", "logical", "double")) { 429s + x <- matrix(NA_integer_, nrow = 3, ncol = 3) 429s + storage.mode(x) <- mode 429s + 429s + # To check names attribute 429s + dimnames <- list(letters[1:3], LETTERS[1:3]) 429s + 429s + # Test with and without dimnames on x 429s + for (setDimnames in c(TRUE, FALSE)) { 429s + if (setDimnames) dimnames(x) <- dimnames 429s + else dimnames(x) <- NULL 429s + # Check names attribute 429s + for (useNames in c(TRUE, FALSE)) { 429s + y0 <- rowSums2_R(x, na.rm = TRUE, useNames = useNames) 429s + y1 <- rowSums2(x, na.rm = TRUE, useNames = useNames) 429s + stopifnot(all.equal(y1, y0)) 429s + 429s + y0 <- colSums2_R(x, na.rm = TRUE, useNames = useNames) 429s + y1 <- colSums2(x, na.rm = TRUE, useNames = useNames) 429s + stopifnot(all.equal(y1, y0)) 429s + } 429s + } 429s + } 430s > 430s > 430s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 430s > # Special case: All NaNs 430s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 430s > cat("Special case: All NaNs:\n") 430s Special case: All NaNs: 430s > x <- matrix(NA_real_, nrow = 3, ncol = 3) 430s > 430s > # Test with and without dimnames on x 430s > for (setDimnames in c(TRUE, FALSE)) { 430s + if (setDimnames) dimnames(x) <- dimnames 430s + else dimnames(x) <- NULL 430s + # Check names attribute 430s + for (useNames in c(TRUE, FALSE)) { 430s + y0 <- rowSums2_R(x, na.rm = TRUE, useNames = useNames) 430s + y1 <- rowSums2(x, na.rm = TRUE, useNames = useNames) 430s + stopifnot(all.equal(y1, y0)) 430s + 430s + y0 <- colSums2_R(x, na.rm = TRUE, useNames = useNames) 430s + y1 <- colSums2(x, na.rm = TRUE, useNames = useNames) 430s + stopifnot(all.equal(y1, y0)) 430s + } 430s + } 430s > 430s > 430s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 430s > # Special case: All Infs 430s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 430s > cat("Special case: All Infs:\n") 430s Special case: All Infs: 430s > x <- matrix(Inf, nrow = 3, ncol = 3) 430s > 430s > # Test with and without dimnames on x 430s > for (setDimnames in c(TRUE, FALSE)) { 430s + if (setDimnames) dimnames(x) <- dimnames 430s + else dimnames(x) <- NULL 430s + # Check names attribute 430s + for (useNames in c(TRUE, FALSE)) { 430s + y0 <- rowSums2_R(x, na.rm = FALSE, useNames = useNames) 430s + y1 <- rowSums2(x, na.rm = FALSE, useNames = useNames) 430s + stopifnot(all.equal(y1, y0)) 430s + 430s + y0 <- colSums2_R(x, na.rm = FALSE, useNames = useNames) 430s + y1 <- colSums2(x, na.rm = FALSE, useNames = useNames) 430s + stopifnot(all.equal(y1, y0)) 430s + } 430s + } 430s > 430s > 430s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 430s > # Special case: All -Infs 430s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 430s > cat("Special case: All -Infs:\n") 430s Special case: All -Infs: 430s > x <- matrix(-Inf, nrow = 3, ncol = 3) 430s > 430s > # Test with and without dimnames on x 430s > for (setDimnames in c(TRUE, FALSE)) { 430s + if (setDimnames) dimnames(x) <- dimnames 430s + else dimnames(x) <- NULL 430s + # Check names attribute 430s + for (useNames in c(TRUE, FALSE)) { 430s + y0 <- rowSums2_R(x, na.rm = FALSE, useNames = useNames) 430s + y1 <- rowSums2(x, na.rm = FALSE, useNames = useNames) 430s + stopifnot(all.equal(y1, y0)) 430s + 430s + y0 <- colSums2_R(x, na.rm = FALSE, useNames = useNames) 430s + y1 <- colSums2(x, na.rm = FALSE, useNames = useNames) 430s + stopifnot(all.equal(y1, y0)) 430s + } 430s + } 430s > 430s > 430s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 430s > # Special case: Infs and -Infs 430s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 430s > cat("Special case: Infs and -Infs:\n") 430s Special case: Infs and -Infs: 430s > x <- matrix(c(-Inf, +Inf), nrow = 4, ncol = 4) 430s > 430s > # To check names attribute 430s > dimnames <- list(letters[1:4], LETTERS[1:4]) 430s > 430s > # Test with and without dimnames on x 430s > for (setDimnames in c(TRUE, FALSE)) { 430s + if (setDimnames) dimnames(x) <- dimnames 430s + else dimnames(x) <- NULL 430s + # Check names attribute 430s + for (useNames in c(TRUE, FALSE)) { 430s + y0 <- rowSums2_R(x, na.rm = FALSE, useNames = useNames) 430s + y1 <- rowSums2(x, na.rm = FALSE, useNames = useNames) 430s + stopifnot(all.equal(y1, y0)) 430s + 430s + y0 <- colSums2_R(x, na.rm = FALSE, useNames = useNames) 430s + y1 <- colSums2(x, na.rm = FALSE, useNames = useNames) 430s + stopifnot(all.equal(y1, y0)) 430s + } 430s + } 430s > 430s > 430s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 430s > # Special case: NaNs and NAs 430s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 430s > cat("Special case: Infs and -Infs:\n") 430s Special case: Infs and -Infs: 430s > x <- matrix(c(NaN, NA_real_), nrow = 4, ncol = 4) 430s > 430s > y0 <- rowSums(x, na.rm = FALSE) 430s > str(y0) 430s num [1:4] NaN NA NaN NA 430s > stopifnot(all(is.na(y0)), length(unique(y0)) >= 1L) 430s > y1 <- rowSums2(x, na.rm = FALSE) 430s > str(y0) 430s num [1:4] NaN NA NaN NA 430s > stopifnot(all(is.na(y1)), length(unique(y1)) >= 1L) 430s > stopifnot(all.equal(y1, y0)) 430s > 430s > y0 <- colSums(x, na.rm = FALSE) 430s > stopifnot(all(is.na(y0)), length(unique(y0)) == 1L) 430s > y1 <- colSums2(x, na.rm = FALSE) 430s > stopifnot(all(is.na(y1)), length(unique(y1)) == 1L) 430s > ## NOTE, due to compiler optimization, it is not guaranteed that NA is 430s > ## returned here (as one would expect). NaN might very well be returned, 430s > ## when both NA and NaN are involved. This is an accepted feature in R, 430s > ## which is documented in help("is.nan"). See also 430s > ## https://stat.ethz.ch/pipermail/r-devel/2017-April/074009.html. 430s > ## Thus, we cannot guarantee that y1 is identical to y0. 430s > 430s > 430s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 430s > # Special case: Integer overflow with ties 430s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 430s > cat("Special case: Integer overflow with ties:\n") 430s Special case: Integer overflow with ties: 430s > x <- matrix(.Machine$integer.max, nrow = 4, ncol = 4) 430s > 430s > # Test with and without dimnames on x 430s > for (setDimnames in c(TRUE, FALSE)) { 430s + if (setDimnames) dimnames(x) <- dimnames 430s + else dimnames(x) <- NULL 430s + # Check names attribute 430s + for (useNames in c(TRUE, FALSE)) { 430s + y0 <- rowSums2_R(x, na.rm = FALSE, useNames = useNames) 430s + y1 <- rowSums2(x, na.rm = FALSE, useNames = useNames) 430s + stopifnot(all.equal(y1, y0)) 430s + 430s + y0 <- colSums2_R(x, na.rm = FALSE, useNames = useNames) 430s + y1 <- colSums2(x, na.rm = FALSE, useNames = useNames) 430s + stopifnot(all.equal(y1, y0)) 430s + } 430s + } 430s > 430s > 430s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 430s > # Consistency checks 430s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 430s > set.seed(1) 430s > 430s > cat("Consistency checks:\n") 430s Consistency checks: 430s > n_sims <- if (Sys.getenv("_R_CHECK_USE_VALGRIND_") != "") 4L else 20L 430s > for (kk in seq_len(n_sims)) { 430s + cat("Random test #", kk, "\n", sep = "") 430s + 430s + # Simulate data in a matrix of any shape 430s + dim <- sample(50:200, size = 2) 430s + n <- prod(dim) 430s + x <- rnorm(n, sd = 100) 430s + dim(x) <- dim 430s + 430s + # Add NAs? 430s + if ((kk %% 4) %in% c(3, 0)) { 430s + cat("Adding NAs\n") 430s + nna <- sample(n, size = 1) 430s + na_values <- c(NA_real_, NaN) 430s + t <- sample(na_values, size = nna, replace = TRUE) 430s + x[sample(length(x), size = nna)] <- t 430s + } 430s + 430s + # Mode? 430s + modes <- "double" 430s + if ((kk %% 4) %in% c(2, 0)) { 430s + modes <- c("integer", "logical") 430s + } 430s + 430s + for (mode in modes) { 430s + if (mode != "double") { 430s + cat(sprintf("Coercing from %s to %s\n", storage.mode(x), mode)) 430s + storage.mode(x) <- mode 430s + } 430s + 430s + na.rm <- sample(c(TRUE, FALSE), size = 1) 430s + 430s + # rowSums2(): 430s + y0 <- rowSums2_R(x, na.rm = na.rm) 430s + y1 <- rowSums2(x, na.rm = na.rm) 430s + stopifnot(all.equal(y1, y0)) 430s + y2 <- colSums2(t(x), na.rm = na.rm) 430s + stopifnot(all.equal(y2, y0)) 430s + 430s + # colSums2(): 430s + y0 <- colSums2_R(x, na.rm = na.rm) 430s + y1 <- colSums2(x, na.rm = na.rm) 430s + stopifnot(all.equal(y1, y0)) 430s + y2 <- rowSums2(t(x), na.rm = na.rm) 430s + stopifnot(all.equal(y2, y0)) 430s + } 430s + } # for (kk ...) 430s Random test #1 430s Random test #2 430s Coercing from double to integer 430s Coercing from integer to logical 430s Random test #3 430s Adding NAs 430s Random test #4 430s Adding NAs 430s Coercing from double to integer 430s Coercing from integer to logical 430s Random test #5 430s Random test #6 430s Coercing from double to integer 430s Coercing from integer to logical 430s Random test #7 430s Adding NAs 430s Random test #8 430s Adding NAs 430s Coercing from double to integer 430s Coercing from integer to logical 430s Random test #9 430s Random test #10 430s Coercing from double to integer 430s Coercing from integer to logical 430s Random test #11 430s Adding NAs 430s Random test #12 430s Adding NAs 430s Coercing from double to integer 430s Coercing from integer to logical 430s Random test #13 430s Random test #14 430s Coercing from double to integer 430s Coercing from integer to logical 430s Random test #15 430s Adding NAs 430s Random test #16 430s Adding NAs 430s Coercing from double to integer 430s Coercing from integer to logical 430s Random test #17 430s Random test #18 430s Coercing from double to integer 430s Coercing from integer to logical 430s Random test #19 430s Adding NAs 430s Random test #20 430s Adding NAs 430s Coercing from double to integer 430s Coercing from integer to logical 430s > 430s 430s R version 4.4.3 (2025-02-28) -- "Trophy Case" 430s Copyright (C) 2025 The R Foundation for Statistical Computing 430s Platform: arm-unknown-linux-gnueabihf (32-bit) 430s 430s R is free software and comes with ABSOLUTELY NO WARRANTY. 430s You are welcome to redistribute it under certain conditions. 430s Type 'license()' or 'licence()' for distribution details. 430s 430s R is a collaborative project with many contributors. 430s Type 'contributors()' for more information and 430s 'citation()' on how to cite R or R packages in publications. 430s 430s Type 'demo()' for some demos, 'help()' for on-line help, or 430s 'help.start()' for an HTML browser interface to help. 430s Type 'q()' to quit R. 430s 430s > library("matrixStats") 430s > 430s > rowSums2_R <- function(x, na.rm = FALSE, ..., useNames = TRUE) { 430s + ## FIXME: sum() may overflow for integers, whereas 430s + ## base::rowSums() doesn't. What should rowSums2() do? 430s + ## apply(x, MARGIN = 1L, FUN = sum, na.rm = na.rm) 430s + res <- rowSums(x, na.rm = na.rm) 430s + if (!useNames) names(res) <- NULL 430s + res 430s + } 430s > 430s > colSums2_R <- function(x, na.rm = FALSE, ..., useNames = TRUE) { 430s + ## FIXME: sum() may overflow for integers, whereas 430s + ## base::colSums() doesn't. What should colSums2() do? 430s + ## apply(x, MARGIN = 2L, FUN = sum, na.rm = na.rm) 430s + res <- colSums(x, na.rm = na.rm) 430s + if (!useNames) names(res) <- NULL 430s + res 430s + } 430s > 430s > 430s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 430s > # Subsetted tests 430s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 430s > source("utils/validateIndicesFramework.R") 430s > x <- matrix(runif(6 * 6, min = -3, max = 3), nrow = 6, ncol = 6) 430s > storage.mode(x) <- "integer" 430s > 430s > # To check names attribute 430s > dimnames <- list(letters[1:6], LETTERS[1:6]) 430s > 430s > # Test with and without dimnames on x 430s > for (setDimnames in c(TRUE, FALSE)) { 430s + if (setDimnames) dimnames(x) <- dimnames 430s + else dimnames(x) <- NULL 430s + for (rows in index_cases) { 430s + for (cols in index_cases) { 430s + for (na.rm in c(TRUE, FALSE)) { 430s + for (useNames in c(TRUE, FALSE)) { 430s + validateIndicesTestMatrix(x, rows, cols, 430s + ftest = rowSums2, fsure = rowSums2_R, 430s + na.rm = na.rm, useNames = useNames) 430s + validateIndicesTestMatrix(x, rows, cols, 430s + fcoltest = colSums2, fsure = rowSums2_R, 430s + na.rm = na.rm, useNames = useNames) 430s + } 430s + } 430s + } 430s + } 430s + } 431s > 431s 431s R version 4.4.3 (2025-02-28) -- "Trophy Case" 431s Copyright (C) 2025 The R Foundation for Statistical Computing 431s Platform: arm-unknown-linux-gnueabihf (32-bit) 431s 431s R is free software and comes with ABSOLUTELY NO WARRANTY. 431s You are welcome to redistribute it under certain conditions. 431s Type 'license()' or 'licence()' for distribution details. 431s 431s R is a collaborative project with many contributors. 431s Type 'contributors()' for more information and 431s 'citation()' on how to cite R or R packages in publications. 431s 431s Type 'demo()' for some demos, 'help()' for on-line help, or 431s 'help.start()' for an HTML browser interface to help. 431s Type 'q()' to quit R. 431s 431s > library("matrixStats") 431s > 431s > nrow <- 6L 431s > ncol <- 5L 431s > data <- matrix(0:4, nrow = nrow, ncol = ncol) 431s > 431s > # To check names attribute 431s > dimnames <- list(letters[1:6], LETTERS[1:5]) 431s > 431s > modes <- c("integer", "logical", "raw") 431s > for (mode in modes) { 431s + cat(sprintf("Mode: %s...\n", mode)) 431s + 431s + x <- data 431s + if (mode == "logical") x <- x - 2L 431s + if (mode != "raw") x[c(2,5,7)] <- NA_integer_ 431s + storage.mode(x) <- mode 431s + print(x) 431s + 431s + unique_values <- unique(as.vector(x)) 431s + nbr_of_unique_values <- length(unique_values) 431s + 431s + y <- rowTabulates(x) 431s + print(y) 431s + stopifnot( 431s + identical(dim(y), c(nrow, nbr_of_unique_values)), 431s + all(y >= 0) 431s + ) 431s + if (mode != "raw") { 431s + y0 <- t(table(x, row(x), useNA = "always")[, seq_len(nrow(x))]) 431s + stopifnot(all(y == y0)) 431s + } 431s + # Check names attribute 431s + dimnames(x) <- dimnames 431s + y1 <- rowTabulates(x, useNames = FALSE) 431s + stopifnot(all.equal(y1, y)) 431s + y <- rowTabulates(x, useNames = TRUE) 431s + stopifnot(identical(rownames(y), rownames(x))) 431s + dimnames(x) <- NULL 431s + 431s + y <- colTabulates(x) 431s + print(y) 431s + stopifnot( 431s + identical(dim(y), c(ncol, nbr_of_unique_values)), 431s + all(y >= 0) 431s + ) 431s + if (mode != "raw") { 431s + y0 <- t(table(x, col(x), useNA = "always")[, seq_len(ncol(x))]) 431s + stopifnot(all(y == y0)) 431s + } 431s + # Check names attribute 431s + dimnames(x) <- dimnames 431s + y1 <- colTabulates(x, useNames = FALSE) 431s + stopifnot(all.equal(y1, y)) 431s + y <- colTabulates(x, useNames = TRUE) 431s + stopifnot(identical(rownames(y), colnames(x))) 431s + dimnames(x) <- NULL 431s + 431s + # Count only certain values 431s + if (mode == "integer") { 431s + subset <- c(0:2, NA_integer_) 431s + } else if (mode == "logical") { 431s + subset <- c(TRUE, FALSE, NA) 431s + } else { 431s + subset <- c(0:2) 431s + } 431s + y <- rowTabulates(x, values = subset) 431s + print(y) 431s + stopifnot(identical(dim(y), c(nrow, length(subset)))) 431s + # Check names attribute 431s + dimnames(x) <- dimnames 431s + y1 <- rowTabulates(x, values = subset, useNames = FALSE) 431s + stopifnot(all.equal(y1, y)) 431s + y <- rowTabulates(x, values = subset, useNames = TRUE) 431s + stopifnot(identical(rownames(y), rownames(x))) 431s + dimnames(x) <- NULL 431s + 431s + y <- colTabulates(x, values = subset) 431s + print(y) 431s + stopifnot(identical(dim(y), c(ncol, length(subset)))) 431s + # Check names attribute 431s + dimnames(x) <- dimnames 431s + y1 <- colTabulates(x, values = subset, useNames = FALSE) 431s + stopifnot(all.equal(y1, y)) 431s + y <- colTabulates(x, values = subset, useNames = TRUE) 431s + stopifnot(identical(rownames(y), colnames(x))) 431s + dimnames(x) <- NULL 431s + 431s + # Raw 431s + if (mode %in% c("integer", "raw")) { 431s + subset <- c(0:2) 431s + 431s + y <- rowTabulates(x, values = as.raw(subset)) 431s + print(y) 431s + stopifnot(identical(dim(y), c(nrow, length(subset)))) 431s + # Check names attribute 431s + dimnames(x) <- dimnames 431s + y1 <- rowTabulates(x, values = as.raw(subset), useNames = FALSE) 431s + stopifnot(all.equal(y1, y)) 431s + y3 <- rowTabulates(x, values = as.raw(subset), useNames = TRUE) 431s + stopifnot(identical(rownames(y3), rownames(x))) 431s + dimnames(x) <- NULL 431s + 431s + y2 <- colTabulates(t(x), values = as.raw(subset)) 431s + print(y2) 431s + stopifnot( 431s + identical(dim(y2), c(nrow, length(subset))), 431s + identical(y2, y) 431s + ) 431s + # Check names attribute 431s + dimnames(x) <- dimnames 431s + y1 <- colTabulates(t(x), values = as.raw(subset), useNames = FALSE) 431s + stopifnot(all.equal(y1, y)) 431s + y <- colTabulates(t(x), values = as.raw(subset), useNames = TRUE) 431s + stopifnot(identical(rownames(y), colnames(t(x)))) 431s + dimnames(x) <- NULL 431s + } 431s + 431s + cat(sprintf("Mode: %s...done\n", mode)) 431s + } # for (mode ...) 432s Mode: integer... 432s [,1] [,2] [,3] [,4] [,5] 432s [1,] 0 NA 2 3 4 432s [2,] NA 2 3 4 0 432s [3,] 2 3 4 0 1 432s [4,] 3 4 0 1 2 432s [5,] NA 0 1 2 3 432s [6,] 0 1 2 3 4 432s 0 1 2 3 4 432s [1,] 1 0 1 1 1 1 432s [2,] 1 0 1 1 1 1 432s [3,] 1 1 1 1 1 0 432s [4,] 1 1 1 1 1 0 432s [5,] 1 1 1 1 0 1 432s [6,] 1 1 1 1 1 0 432s 0 1 2 3 4 432s [1,] 2 0 1 1 0 2 432s [2,] 1 1 1 1 1 1 432s [3,] 1 1 2 1 1 0 432s [4,] 1 1 1 2 1 0 432s [5,] 1 1 1 1 2 0 432s 0 1 2 432s [1,] 1 0 1 1 432s [2,] 1 0 1 1 432s [3,] 1 1 1 0 432s [4,] 1 1 1 0 432s [5,] 1 1 1 1 432s [6,] 1 1 1 0 432s 0 1 2 432s [1,] 2 0 1 2 432s [2,] 1 1 1 1 432s [3,] 1 1 2 0 432s [4,] 1 1 1 0 432s [5,] 1 1 1 0 432s 0x0 0x1 0x2 432s [1,] 1 0 1 432s [2,] 1 0 1 432s [3,] 1 1 1 432s [4,] 1 1 1 432s [5,] 1 1 1 432s [6,] 1 1 1 432s 0x0 0x1 0x2 432s [1,] 1 0 1 432s [2,] 1 0 1 432s [3,] 1 1 1 432s [4,] 1 1 1 432s [5,] 1 1 1 432s [6,] 1 1 1 432s Mode: integer...done 432s Mode: logical... 432s [,1] [,2] [,3] [,4] [,5] 432s [1,] TRUE NA FALSE TRUE TRUE 432s [2,] NA FALSE TRUE TRUE TRUE 432s [3,] FALSE TRUE TRUE TRUE TRUE 432s [4,] TRUE TRUE TRUE TRUE FALSE 432s [5,] NA TRUE TRUE FALSE TRUE 432s [6,] TRUE TRUE FALSE TRUE TRUE 432s FALSE TRUE 432s [1,] 1 3 1 432s [2,] 1 3 1 432s [3,] 1 4 0 432s [4,] 1 4 0 432s [5,] 1 3 1 432s [6,] 1 4 0 432s FALSE TRUE 432s [1,] 1 3 2 432s [2,] 1 4 1 432s [3,] 2 4 0 432s [4,] 1 5 0 432s [5,] 1 5 0 432s TRUE FALSE 432s [1,] 3 1 1 432s [2,] 3 1 1 432s [3,] 4 1 0 432s [4,] 4 1 0 432s [5,] 3 1 1 432s [6,] 4 1 0 432s TRUE FALSE 432s [1,] 3 1 2 432s [2,] 4 1 1 432s [3,] 4 2 0 432s [4,] 5 1 0 432s [5,] 5 1 0 432s Mode: logical...done 432s Mode: raw... 432s [,1] [,2] [,3] [,4] [,5] 432s [1,] 00 01 02 03 04 432s [2,] 01 02 03 04 00 432s [3,] 02 03 04 00 01 432s [4,] 03 04 00 01 02 432s [5,] 04 00 01 02 03 432s [6,] 00 01 02 03 04 432s 0x0 0x1 0x2 0x3 0x4 432s [1,] 1 1 1 1 1 432s [2,] 1 1 1 1 1 432s [3,] 1 1 1 1 1 432s [4,] 1 1 1 1 1 432s [5,] 1 1 1 1 1 432s [6,] 1 1 1 1 1 432s 0x0 0x1 0x2 0x3 0x4 432s [1,] 2 1 1 1 1 432s [2,] 1 2 1 1 1 432s [3,] 1 1 2 1 1 432s [4,] 1 1 1 2 1 432s [5,] 1 1 1 1 2 432s 0 1 2 432s [1,] 1 1 1 432s [2,] 1 1 1 432s [3,] 1 1 1 432s [4,] 1 1 1 432s [5,] 1 1 1 432s [6,] 1 1 1 432s 0 1 2 432s [1,] 2 1 1 432s [2,] 1 2 1 432s [3,] 1 1 2 432s [4,] 1 1 1 432s [5,] 1 1 1 432s 0x0 0x1 0x2 432s [1,] 1 1 1 432s [2,] 1 1 1 432s [3,] 1 1 1 432s [4,] 1 1 1 432s [5,] 1 1 1 432s [6,] 1 1 1 432s 0x0 0x1 0x2 432s [1,] 1 1 1 432s [2,] 1 1 1 432s [3,] 1 1 1 432s [4,] 1 1 1 432s [5,] 1 1 1 432s [6,] 1 1 1 432s Mode: raw...done 432s > 432s 432s R version 4.4.3 (2025-02-28) -- "Trophy Case" 432s Copyright (C) 2025 The R Foundation for Statistical Computing 432s Platform: arm-unknown-linux-gnueabihf (32-bit) 432s 432s R is free software and comes with ABSOLUTELY NO WARRANTY. 432s You are welcome to redistribute it under certain conditions. 432s Type 'license()' or 'licence()' for distribution details. 432s 432s R is a collaborative project with many contributors. 432s Type 'contributors()' for more information and 432s 'citation()' on how to cite R or R packages in publications. 432s 432s Type 'demo()' for some demos, 'help()' for on-line help, or 432s 'help.start()' for an HTML browser interface to help. 432s Type 'q()' to quit R. 432s 432s > library("matrixStats") 432s > 432s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 432s > # Subsetted tests 432s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 432s > source("utils/validateIndicesFramework.R") 432s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 432s > storage.mode(x) <- "integer" 432s > 432s > # To check names attribute 432s > dimnames <- list(letters[1:6], LETTERS[1:6]) 432s > 432s > # Test with and without dimnames on x 432s > for (setDimnames in c(TRUE, FALSE)) { 432s + if (setDimnames) dimnames(x) <- dimnames 432s + else dimnames(x) <- NULL 432s + 432s + count <- 0L 432s + for (rows in index_cases) { 432s + for (cols in index_cases) { 432s + count <- count + 1L 432s + useNames <- c(TRUE, FALSE) 432s + useNames <- useNames[count %% length(useNames) + 1] 432s + 432s + validateIndicesTestMatrix(x, rows, cols, 432s + ftest = rowTabulates, fsure = rowTabulates, useNames = useNames) 432s + validateIndicesTestMatrix(x, rows, cols, 432s + ftest = rowTabulates, fsure = rowTabulates, 432s + values = 1:3, useNames = useNames) 432s + 432s + validateIndicesTestMatrix(x, rows, cols, 432s + ftest = colTabulates, fsure = colTabulates, useNames = useNames) 432s + validateIndicesTestMatrix(x, rows, cols, 432s + ftest = colTabulates, fsure = colTabulates, 432s + values = 1:3, useNames = useNames) 432s + } 432s + } 432s + } 433s > 433s 433s R version 4.4.3 (2025-02-28) -- "Trophy Case" 433s Copyright (C) 2025 The R Foundation for Statistical Computing 433s Platform: arm-unknown-linux-gnueabihf (32-bit) 433s 433s R is free software and comes with ABSOLUTELY NO WARRANTY. 433s You are welcome to redistribute it under certain conditions. 433s Type 'license()' or 'licence()' for distribution details. 433s 433s R is a collaborative project with many contributors. 433s Type 'contributors()' for more information and 433s 'citation()' on how to cite R or R packages in publications. 433s 433s Type 'demo()' for some demos, 'help()' for on-line help, or 433s 'help.start()' for an HTML browser interface to help. 433s Type 'q()' to quit R. 433s 434s > library("matrixStats") 434s > 434s > fcns <- list( 434s + rowVarDiffs = list(rowVarDiffs, colVarDiffs), 434s + rowSdDiffs = list(rowSdDiffs, colSdDiffs), 434s + rowMadDiffs = list(rowMadDiffs, colMadDiffs), 434s + rowIQRDiffs = list(rowIQRDiffs, colIQRDiffs) 434s + ) 434s > 434s > for (fcn in names(fcns)) { 434s + cat(sprintf("%s()...\n", fcn)) 434s + row_fcn <- fcns[[fcn]][[1L]] 434s + col_fcn <- fcns[[fcn]][[2L]] 434s + 434s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 434s + # With and without some NAs 434s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 434s + for (mode in c("integer", "double")) { 434s + for (add_na in c(FALSE, TRUE)) { 434s + cat("add_na = ", add_na, "\n", sep = "") 434s + 434s + x <- matrix(1:50 + 0.1, nrow = 10L, ncol = 5L) 434s + if (add_na) { 434s + x[3:7, c(2, 4)] <- NA_real_ 434s + } 434s + cat("mode: ", mode, "\n", sep = "") 434s + storage.mode(x) <- mode 434s + str(x) 434s + 434s + # To check names attribute 434s + dimnames <- list(letters[1:10], LETTERS[1:5]) 434s + 434s + # Test with and without dimnames on x 434s + for (setDimnames in c(TRUE, FALSE)) { 434s + if (setDimnames) dimnames(x) <- dimnames 434s + else dimnames(x) <- NULL 434s + # Row/column ranges 434s + for (na.rm in c(FALSE, TRUE)) { 434s + # Check names attribute 434s + for (useNames in c(TRUE, FALSE)) { 434s + cat("na.rm = ", na.rm, "\n", sep = "") 434s + r1 <- row_fcn(x, na.rm = na.rm, useNames = useNames) 434s + r2 <- col_fcn(t(x), na.rm = na.rm, useNames = useNames) 434s + stopifnot(all.equal(r1, r2)) 434s + } 434s + } 434s + } 434s + } # for (add_na ...) 434s + } 434s + 434s + 434s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 434s + # All NAs 434s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 434s + for (mode in c("integer", "double")) { 434s + x <- matrix(NA_real_, nrow = 10L, ncol = 5L) 434s + cat("mode: ", mode, "\n", sep = "") 434s + storage.mode(x) <- mode 434s + str(x) 434s + 434s + # Test with and without dimnames on x 434s + for (setDimnames in c(TRUE, FALSE)) { 434s + if (setDimnames) dimnames(x) <- dimnames 434s + else dimnames(x) <- NULL 434s + # Row/column ranges 434s + for (na.rm in c(FALSE, TRUE)) { 434s + # Check names attribute 434s + for (useNames in c(TRUE, FALSE)) { 434s + cat("na.rm = ", na.rm, "\n", sep = "") 434s + r1 <- row_fcn(x, na.rm = na.rm, useNames = useNames) 434s + r2 <- col_fcn(t(x), na.rm = na.rm, useNames = useNames) 434s + stopifnot(all.equal(r1, r2)) 434s + } 434s + } 434s + } 434s + } 434s + 434s + 434s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 434s + # A 1x1 matrix 434s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 434s + x <- matrix(0, nrow = 1L, ncol = 1L) 434s + dimnames <- list("a", "A") 434s + # Test with and without dimnames on x 434s + for (setDimnames in c(TRUE, FALSE)) { 434s + if (setDimnames) dimnames(x) <- dimnames 434s + else dimnames(x) <- NULL 434s + # Row/column ranges 434s + for (na.rm in c(FALSE, TRUE)) { 434s + # Check names attribute 434s + for (useNames in c(TRUE, FALSE)) { 434s + cat("na.rm = ", na.rm, "\n", sep = "") 434s + r1 <- row_fcn(x, na.rm = na.rm, useNames = useNames) 434s + r2 <- col_fcn(t(x), na.rm = na.rm, useNames = useNames) 434s + stopifnot(all.equal(r1, r2)) 434s + } 434s + } 434s + } 434s + 434s + cat(sprintf("%s()...DONE\n", fcn)) 434s + } # for (fcn ...) 434s rowVarDiffs()... 434s add_na = FALSE 434s mode: integer 434s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 434s na.rm = FALSE 434s na.rm = FALSE 434s na.rm = TRUE 434s na.rm = TRUE 434s na.rm = FALSE 434s na.rm = FALSE 434s na.rm = TRUE 434s na.rm = TRUE 434s add_na = TRUE 434s mode: integer 434s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 434s na.rm = FALSE 434s na.rm = FALSE 434s na.rm = TRUE 434s na.rm = TRUE 434s na.rm = FALSE 434s na.rm = FALSE 434s na.rm = TRUE 434s na.rm = TRUE 434s add_na = FALSE 434s mode: double 434s 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 ... 434s na.rm = FALSE 434s na.rm = FALSE 434s na.rm = TRUE 434s na.rm = TRUE 434s na.rm = FALSE 434s na.rm = FALSE 434s na.rm = TRUE 434s na.rm = TRUE 434s add_na = TRUE 434s mode: double 434s 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 ... 434s na.rm = FALSE 434s na.rm = FALSE 434s na.rm = TRUE 434s na.rm = TRUE 434s na.rm = FALSE 434s na.rm = FALSE 434s na.rm = TRUE 434s na.rm = TRUE 434s mode: integer 434s int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 434s na.rm = FALSE 434s na.rm = FALSE 434s na.rm = TRUE 434s na.rm = TRUE 434s na.rm = FALSE 434s na.rm = FALSE 434s na.rm = TRUE 434s na.rm = TRUE 434s mode: double 434s num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 434s na.rm = FALSE 434s na.rm = FALSE 434s na.rm = TRUE 434s na.rm = TRUE 434s na.rm = FALSE 434s na.rm = FALSE 434s na.rm = TRUE 434s na.rm = TRUE 434s na.rm = FALSE 434s na.rm = FALSE 434s na.rm = TRUE 434s na.rm = TRUE 434s na.rm = FALSE 434s na.rm = FALSE 434s na.rm = TRUE 434s na.rm = TRUE 434s rowVarDiffs()...DONE 434s rowSdDiffs()... 434s add_na = FALSE 434s mode: integer 434s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 434s na.rm = FALSE 434s na.rm = FALSE 434s na.rm = TRUE 434s na.rm = TRUE 434s na.rm = FALSE 434s na.rm = FALSE 434s na.rm = TRUE 434s na.rm = TRUE 434s add_na = TRUE 434s mode: integer 434s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 434s na.rm = FALSE 434s na.rm = FALSE 434s na.rm = TRUE 434s na.rm = TRUE 434s na.rm = FALSE 434s na.rm = FALSE 434s na.rm = TRUE 434s na.rm = TRUE 434s add_na = FALSE 434s mode: double 434s 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 ... 434s na.rm = FALSE 434s na.rm = FALSE 434s na.rm = TRUE 434s na.rm = TRUE 434s na.rm = FALSE 434s na.rm = FALSE 434s na.rm = TRUE 434s na.rm = TRUE 434s add_na = TRUE 434s mode: double 434s 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 ... 434s na.rm = FALSE 434s na.rm = FALSE 434s na.rm = TRUE 434s na.rm = TRUE 434s na.rm = FALSE 434s na.rm = FALSE 434s na.rm = TRUE 434s na.rm = TRUE 434s mode: integer 434s int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 434s na.rm = FALSE 434s na.rm = FALSE 434s na.rm = TRUE 434s na.rm = TRUE 434s na.rm = FALSE 434s na.rm = FALSE 434s na.rm = TRUE 434s na.rm = TRUE 434s mode: double 434s num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 434s na.rm = FALSE 434s na.rm = FALSE 434s na.rm = TRUE 434s na.rm = TRUE 434s na.rm = FALSE 434s na.rm = FALSE 434s na.rm = TRUE 434s na.rm = TRUE 434s na.rm = FALSE 434s na.rm = FALSE 434s na.rm = TRUE 434s na.rm = TRUE 434s na.rm = FALSE 434s na.rm = FALSE 434s na.rm = TRUE 434s na.rm = TRUE 434s rowSdDiffs()...DONE 434s rowMadDiffs()... 434s add_na = FALSE 434s mode: integer 434s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 434s na.rm = FALSE 434s na.rm = FALSE 434s na.rm = TRUE 434s na.rm = TRUE 434s na.rm = FALSE 434s na.rm = FALSE 434s na.rm = TRUE 434s na.rm = TRUE 434s add_na = TRUE 434s mode: integer 434s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 434s na.rm = FALSE 434s na.rm = FALSE 434s na.rm = TRUE 434s na.rm = TRUE 434s na.rm = FALSE 434s na.rm = FALSE 434s na.rm = TRUE 434s na.rm = TRUE 434s add_na = FALSE 434s mode: double 434s 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 ... 434s na.rm = FALSE 434s na.rm = FALSE 434s na.rm = TRUE 434s na.rm = TRUE 434s na.rm = FALSE 434s na.rm = FALSE 434s na.rm = TRUE 434s na.rm = TRUE 434s add_na = TRUE 434s mode: double 434s 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 ... 434s na.rm = FALSE 434s na.rm = FALSE 434s na.rm = TRUE 434s na.rm = TRUE 434s na.rm = FALSE 434s na.rm = FALSE 434s na.rm = TRUE 434s na.rm = TRUE 434s mode: integer 434s int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 434s na.rm = FALSE 434s na.rm = FALSE 434s na.rm = TRUE 434s na.rm = TRUE 434s na.rm = FALSE 434s na.rm = FALSE 434s na.rm = TRUE 434s na.rm = TRUE 434s mode: double 434s num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 434s na.rm = FALSE 434s na.rm = FALSE 434s na.rm = TRUE 434s na.rm = TRUE 434s na.rm = FALSE 434s na.rm = FALSE 434s na.rm = TRUE 434s na.rm = TRUE 434s na.rm = FALSE 434s na.rm = FALSE 434s na.rm = TRUE 434s na.rm = TRUE 434s na.rm = FALSE 434s na.rm = FALSE 434s na.rm = TRUE 434s na.rm = TRUE 434s rowMadDiffs()...DONE 434s rowIQRDiffs()... 434s add_na = FALSE 434s mode: integer 434s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 434s na.rm = FALSE 434s na.rm = FALSE 434s na.rm = TRUE 434s na.rm = TRUE 434s na.rm = FALSE 434s na.rm = FALSE 434s na.rm = TRUE 434s na.rm = TRUE 434s add_na = TRUE 434s mode: integer 434s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 434s na.rm = FALSE 434s na.rm = FALSE 434s na.rm = TRUE 434s na.rm = TRUE 434s na.rm = FALSE 434s na.rm = FALSE 434s na.rm = TRUE 434s na.rm = TRUE 434s add_na = FALSE 434s mode: double 434s 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 ... 434s na.rm = FALSE 434s na.rm = FALSE 434s na.rm = TRUE 434s na.rm = TRUE 434s na.rm = FALSE 434s na.rm = FALSE 434s na.rm = TRUE 434s na.rm = TRUE 434s add_na = TRUE 434s mode: double 434s 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 ... 434s na.rm = FALSE 434s na.rm = FALSE 434s na.rm = TRUE 434s na.rm = TRUE 434s na.rm = FALSE 434s na.rm = FALSE 434s na.rm = TRUE 434s na.rm = TRUE 434s mode: integer 434s int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 434s na.rm = FALSE 434s na.rm = FALSE 434s na.rm = TRUE 434s na.rm = TRUE 434s na.rm = FALSE 434s na.rm = FALSE 434s na.rm = TRUE 434s na.rm = TRUE 434s mode: double 434s num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 434s na.rm = FALSE 434s na.rm = FALSE 434s na.rm = TRUE 434s na.rm = TRUE 434s na.rm = FALSE 434s na.rm = FALSE 434s na.rm = TRUE 434s na.rm = TRUE 434s na.rm = FALSE 434s na.rm = FALSE 434s na.rm = TRUE 434s na.rm = TRUE 434s na.rm = FALSE 434s na.rm = FALSE 434s na.rm = TRUE 434s na.rm = TRUE 434s rowIQRDiffs()...DONE 434s > 434s 434s R version 4.4.3 (2025-02-28) -- "Trophy Case" 434s Copyright (C) 2025 The R Foundation for Statistical Computing 434s Platform: arm-unknown-linux-gnueabihf (32-bit) 434s 434s R is free software and comes with ABSOLUTELY NO WARRANTY. 434s You are welcome to redistribute it under certain conditions. 434s Type 'license()' or 'licence()' for distribution details. 434s 434s R is a collaborative project with many contributors. 434s Type 'contributors()' for more information and 434s 'citation()' on how to cite R or R packages in publications. 434s 434s Type 'demo()' for some demos, 'help()' for on-line help, or 434s 'help.start()' for an HTML browser interface to help. 434s Type 'q()' to quit R. 434s 434s > library("matrixStats") 434s > 434s > fcns <- list( 434s + madDiff = c(rowMadDiffs, colMadDiffs), 434s + iqrDiff = c(rowIQRDiffs, colIQRDiffs) 434s + ) 434s > 434s > 434s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 434s > # Subsetted tests 434s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 434s > source("utils/validateIndicesFramework.R") 434s > # To check names attribute 434s > dimnames <- list(letters[1:6], LETTERS[1:6]) 434s > trim <- runif(1, min = 0, max = 0.5) 434s > for (fcn in names(fcns)) { 434s + cat(sprintf("subsetted tests on %s()...\n", fcn)) 434s + row_fcn <- fcns[[fcn]][[1L]] 434s + col_fcn <- fcns[[fcn]][[2L]] 434s + 434s + for (mode in c("numeric", "integer")) { 434s + x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6L, ncol = 6L) 434s + storage.mode(x) <- mode 434s + if (mode == "numeric") x[1:2, 3:4] <- Inf 434s + 434s + # Test with and without dimnames on x 434s + for (setDimnames in c(TRUE, FALSE)) { 434s + if (setDimnames) dimnames(x) <- dimnames 434s + else dimnames(x) <- NULL 434s + 434s + count <- 0L 434s + for (diff in 1:2) { 434s + for (rows in index_cases) { 434s + for (cols in index_cases) { 434s + count <- count + 1L 434s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 434s + useNames <- c(TRUE, FALSE) 434s + useNames <- useNames[count %% length(useNames) + 1] 434s + validateIndicesTestMatrix(x, rows, cols, 434s + ftest = row_fcn, fsure = row_fcn, 434s + na.rm = na.rm, diff = diff, trim = trim, useNames = useNames) 434s + validateIndicesTestMatrix(x, rows, cols, 434s + fcoltest = col_fcn, fsure = row_fcn, 434s + na.rm = na.rm, diff = diff, trim = trim, useNames = useNames) 434s + } 434s + } 434s + } 434s + } 434s + } 434s + cat(sprintf("%s()...DONE\n", fcn)) 434s + } 434s subsetted tests on madDiff()... 440s madDiff()...DONE 440s subsetted tests on iqrDiff()... 445s iqrDiff()...DONE 445s > 445s 445s R version 4.4.3 (2025-02-28) -- "Trophy Case" 445s Copyright (C) 2025 The R Foundation for Statistical Computing 445s Platform: arm-unknown-linux-gnueabihf (32-bit) 445s 445s R is free software and comes with ABSOLUTELY NO WARRANTY. 445s You are welcome to redistribute it under certain conditions. 445s Type 'license()' or 'licence()' for distribution details. 445s 445s R is a collaborative project with many contributors. 445s Type 'contributors()' for more information and 445s 'citation()' on how to cite R or R packages in publications. 445s 445s Type 'demo()' for some demos, 'help()' for on-line help, or 445s 'help.start()' for an HTML browser interface to help. 445s Type 'q()' to quit R. 445s 445s > library("matrixStats") 445s > 445s > fcns <- list( 445s + varDiff = c(rowVarDiffs, colVarDiffs), 445s + sdDiff = c(rowSdDiffs, colSdDiffs) 445s + ) 445s > 445s > 445s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 445s > # Subsetted tests 445s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 445s > source("utils/validateIndicesFramework.R") 445s > # To check names attribute 445s > dimnames <- list(letters[1:6], LETTERS[1:6]) 445s > trim <- runif(1, min = 0, max = 0.5) 445s > for (fcn in names(fcns)) { 445s + cat(sprintf("subsetted tests on %s()...\n", fcn)) 445s + row_fcn <- fcns[[fcn]][[1L]] 445s + col_fcn <- fcns[[fcn]][[2L]] 445s + 445s + for (mode in c("numeric", "integer")) { 445s + x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6L, ncol = 6L) 445s + storage.mode(x) <- mode 445s + if (mode == "numeric") x[1:2, 3:4] <- Inf 445s + 445s + # Test with and without dimnames on x 445s + for (setDimnames in c(TRUE, FALSE)) { 445s + if (setDimnames) dimnames(x) <- dimnames 445s + else dimnames(x) <- NULL 445s + 445s + count <- 0L 445s + for (diff in 1:2) { 445s + for (rows in index_cases) { 446s + for (cols in index_cases) { 446s + count <- count + 1L 446s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 446s + useNames <- c(TRUE, FALSE) 446s + useNames <- useNames[count %% length(useNames) + 1] 446s + 446s + validateIndicesTestMatrix(x, rows, cols, 446s + ftest = row_fcn, fsure = row_fcn, 446s + na.rm = na.rm, diff = diff, trim = trim, useNames = useNames) 446s + validateIndicesTestMatrix(x, rows, cols, 446s + fcoltest = col_fcn, fsure = row_fcn, 446s + na.rm = na.rm, diff = diff, trim = trim, useNames = useNames) 446s + } 446s + } 446s + } 446s + } 446s + } 446s + cat(sprintf("%s()...DONE\n", fcn)) 446s + } 446s subsetted tests on varDiff()... 448s varDiff()...DONE 448s subsetted tests on sdDiff()... 450s sdDiff()...DONE 450s > 450s 450s R version 4.4.3 (2025-02-28) -- "Trophy Case" 450s Copyright (C) 2025 The R Foundation for Statistical Computing 450s Platform: arm-unknown-linux-gnueabihf (32-bit) 450s 450s R is free software and comes with ABSOLUTELY NO WARRANTY. 450s You are welcome to redistribute it under certain conditions. 450s Type 'license()' or 'licence()' for distribution details. 450s 450s R is a collaborative project with many contributors. 450s Type 'contributors()' for more information and 450s 'citation()' on how to cite R or R packages in publications. 450s 450s Type 'demo()' for some demos, 'help()' for on-line help, or 450s 'help.start()' for an HTML browser interface to help. 450s Type 'q()' to quit R. 450s 450s > library("matrixStats") 450s > 450s > ## Always allow testing of the 'center' argument (as long as it's not defunct) 450s > options(matrixStats.center.onUse = "ignore") 450s > options(matrixStats.vars.formula.freq = Inf) 450s > 450s > ## Create isFALSE() if running on an old version of R 450s > if (!exists("isFALSE", mode="function")) { 450s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 450s + } 450s > 450s > rowVars_R <- function(x, na.rm = FALSE, center = NULL, ..., useNames = TRUE) { 450s + suppressWarnings({ 450s + res <- apply(x, MARGIN = 1L, FUN = var, na.rm = na.rm) 450s + }) 450s + stopifnot(!any(is.infinite(res))) 450s + 450s + # Keep naming support consistency same as rowVars() 450s + if (is.null(center) || ncol(x) <= 1L) { 450s + if (isFALSE(useNames)) names(res) <- NULL 450s + } 450s + else if (isFALSE(useNames)) names(res) <- NULL 450s + res 450s + } 450s > 450s > colVars_R <- function(x, na.rm = FALSE, center = NULL, ..., useNames = TRUE) { 450s + suppressWarnings({ 450s + res <- apply(x, MARGIN = 2L, FUN = var, na.rm = na.rm) 450s + }) 450s + stopifnot(!any(is.infinite(res))) 450s + 450s + # Keep naming support consistency same as colVars() 450s + if (is.null(center) || ncol(x) <= 1L) { 450s + if (isFALSE(useNames)) names(res) <- NULL 450s + } 450s + else if (isFALSE(useNames)) names(res) <- NULL 450s + res 450s + } 450s > 450s > 450s > rowVars_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) { 450s + center <- rowWeightedMeans(x, cols = cols, na.rm = na.rm, useNames = FALSE) 450s + res <- rowVars(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 450s + stopifnot(!any(is.infinite(res))) 450s + res 450s + } 450s > 450s > colVars_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) { 450s + center <- colWeightedMeans(x, rows = rows, na.rm = na.rm, useNames = FALSE) 450s + res <- colVars(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 450s + stopifnot(!any(is.infinite(res))) 450s + res 450s + } 450s > 450s > rowVars_center_naive <- function(x, rows = NULL, cols = NULL, center = NULL, na.rm = FALSE, ..., useNames = TRUE) { 450s + x <- sweep(x, MARGIN = 1, STATS = as.array(center), FUN = "-") 450s + x[is.infinite(center), ] <- NaN 450s + res <- rowVars(x, rows = rows, cols = cols, center = rep(0, times = nrow(x)), na.rm = na.rm, useNames = useNames) 450s + stopifnot(!any(is.infinite(res))) 450s + res 450s + } 450s > 450s > colVars_center_naive <- function(x, rows = NULL, cols = NULL, center = NULL, na.rm = FALSE, ..., useNames = TRUE) { 450s + x <- sweep(x, MARGIN = 2, STATS = as.array(center), FUN = "-") 450s + x[, is.infinite(center)] <- NaN 450s + res <- colVars(x, rows = rows, cols = cols, center = rep(0, times = ncol(x)), na.rm = na.rm, useNames = useNames) 450s + stopifnot(!any(is.infinite(res))) 450s + res 450s + } 450s > 450s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 450s > # With and without some NAs or Infs 450s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 450s > for (mode in c("integer", "double")) { 450s + if (mode == "integer") { 450s + specials <- c(0L, NA_integer_) 450s + delta <- 0L 450s + } else { 450s + specials <- c(0, NA_real_, Inf) 450s + delta <- 0.1 450s + } 450s + 450s + for (special in specials) { 450s + cat("special = ", special, "\n", sep = "") 450s + x <- matrix(1:50 + delta, nrow = 10L, ncol = 5L) 450s + x[3:7, c(2, 4)] <- special 450s + cat("mode: ", mode, "\n", sep = "") 450s + str(x) 450s + stopifnot(storage.mode(x) == mode) 450s + 450s + # To check names attribute 450s + dimnames <- list(letters[1:10], LETTERS[1:5]) 450s + 450s + # Test with and without dimnames on x 450s + for (setDimnames in c(TRUE, FALSE)) { 450s + if (setDimnames) dimnames(x) <- dimnames 450s + else dimnames(x) <- NULL 450s + # Row/column variance 450s + for (na.rm in c(FALSE, TRUE)) { 450s + # Check names attribute 450s + for (useNames in c(TRUE, FALSE)) { 450s + cat("na.rm = ", na.rm, "\n", sep = "") 450s + center <- rowMeans(x, na.rm = na.rm) 450s + 450s + r0 <- rowVars_R(x, na.rm = na.rm, useNames = useNames) 450s + r1 <- rowVars(x, na.rm = na.rm, useNames = useNames) 450s + r1b <- rowVars_center(x, na.rm = na.rm, useNames = useNames) 450s + r1c <- rowVars(x, center = center, na.rm = na.rm, useNames = useNames) 450s + 450s + tx <- t(x) 450s + r2 <- colVars(tx, na.rm = na.rm, useNames = useNames) 450s + r2b <- colVars_center(tx, na.rm = na.rm, useNames = useNames) 450s + r2c <- colVars(tx, center = center, na.rm = na.rm, useNames = useNames) 450s + tx <- NULL 450s + 450s + stopifnot(all.equal(r1, r2)) 450s + stopifnot(all.equal(r1, r0)) 450s + stopifnot(all.equal(r1b, r1c)) 450s + stopifnot(all.equal(r2, r0)) 450s + stopifnot(all.equal(r2b, r2c)) 450s + 450s + center <- colMeans(x, na.rm = na.rm) 450s + 450s + r3 <- colVars(x, center = center, na.rm = na.rm, useNames = useNames) 450s + r3b <- colVars_center_naive(x, center = center, na.rm = na.rm, useNames = useNames) 450s + r3c <- rowVars(t(x), center = center, na.rm = na.rm, useNames = useNames) 450s + r3d <- rowVars_center_naive(t(x), center = center, na.rm = na.rm, useNames = useNames) 450s + stopifnot(all.equal(r3b, r3)) 450s + stopifnot(all.equal(r3c, r3)) 450s + stopifnot(all.equal(r3d, r3)) 450s + 450s + stopifnot( 450s + !any(is.infinite(r0)), 450s + !any(is.infinite(r1)), 450s + !any(is.infinite(r2)), 450s + !any(is.infinite(r3)), 450s + !any(is.infinite(r1b)), 450s + !any(is.infinite(r1c)), 450s + !any(is.infinite(r2b)), 450s + !any(is.infinite(r2c)), 450s + !any(is.infinite(r3b)), 450s + !any(is.infinite(r3c)), 450s + !any(is.infinite(r3d)) 450s + ) 450s + } 450s + } 450s + } 450s + } # for (special ...) 450s + } 450s special = 0 450s mode: integer 450s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 450s na.rm = FALSE 450s na.rm = FALSE 450s na.rm = TRUE 450s na.rm = TRUE 450s na.rm = FALSE 450s na.rm = FALSE 450s na.rm = TRUE 450s na.rm = TRUE 450s special = NA 450s mode: integer 450s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 450s na.rm = FALSE 450s na.rm = FALSE 450s na.rm = TRUE 450s na.rm = TRUE 450s na.rm = FALSE 450s na.rm = FALSE 450s na.rm = TRUE 450s na.rm = TRUE 450s special = 0 450s mode: double 450s 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 ... 450s na.rm = FALSE 450s na.rm = FALSE 450s na.rm = TRUE 450s na.rm = TRUE 450s na.rm = FALSE 450s na.rm = FALSE 450s na.rm = TRUE 450s na.rm = TRUE 450s special = NA 450s mode: double 450s 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 ... 450s na.rm = FALSE 450s na.rm = FALSE 450s na.rm = TRUE 450s na.rm = TRUE 450s na.rm = FALSE 450s na.rm = FALSE 450s na.rm = TRUE 450s na.rm = TRUE 450s special = Inf 450s mode: double 450s 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 ... 450s na.rm = FALSE 450s na.rm = FALSE 450s na.rm = TRUE 450s na.rm = TRUE 450s na.rm = FALSE 450s na.rm = FALSE 450s na.rm = TRUE 450s na.rm = TRUE 450s > 450s > 450s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 450s > # All NAs 450s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 450s > for (mode in c("integer", "double")) { 450s + x <- matrix(NA_real_, nrow = 10L, ncol = 5L) 450s + cat("mode: ", mode, "\n", sep = "") 450s + storage.mode(x) <- mode 450s + str(x) 450s + 450s + # Test with and without dimnames on x 450s + for (setDimnames in c(TRUE, FALSE)) { 450s + if (setDimnames) dimnames(x) <- dimnames 450s + else dimnames(x) <- NULL 450s + # Row/column variance 450s + for (na.rm in c(FALSE, TRUE)) { 450s + # Check names attribute 450s + for (useNames in c(TRUE, FALSE)) { 450s + cat("na.rm = ", na.rm, "\n", sep = "") 450s + 450s + r0 <- rowVars_R(x, na.rm = na.rm, useNames = useNames) 450s + r1 <- rowVars(x, na.rm = na.rm, useNames = useNames) 450s + r1b <- rowVars_center(x, na.rm = na.rm, useNames = useNames) 450s + r2 <- colVars(t(x), na.rm = na.rm, useNames = useNames) 450s + r2b <- colVars_center(t(x), na.rm = na.rm, useNames = useNames) 450s + stopifnot(all.equal(r1, r2)) 450s + stopifnot(all.equal(r1, r0)) 450s + stopifnot(all.equal(r2, r0)) 450s + stopifnot(all.equal(r1b, r2b)) 450s + stopifnot( 450s + !any(is.infinite(r0)), 450s + !any(is.infinite(r1)), 450s + !any(is.infinite(r2)), 450s + !any(is.infinite(r1b)), 450s + !any(is.infinite(r2b)) 450s + ) 450s + } 450s + } 450s + } 450s + } 450s mode: integer 450s int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 450s na.rm = FALSE 450s na.rm = FALSE 450s na.rm = TRUE 450s na.rm = TRUE 450s na.rm = FALSE 450s na.rm = FALSE 450s na.rm = TRUE 450s na.rm = TRUE 450s mode: double 450s num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 450s na.rm = FALSE 450s na.rm = FALSE 450s na.rm = TRUE 450s na.rm = TRUE 450s na.rm = FALSE 450s na.rm = FALSE 450s na.rm = TRUE 450s na.rm = TRUE 450s > 450s > 450s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 450s > # A 1x1 matrix 450s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 450s > x <- matrix(0, nrow = 1L, ncol = 1L) 450s > dimnames <- list("a", "A") 450s > # Test with and without dimnames on x 450s > for (setDimnames in c(TRUE, FALSE)) { 450s + if (setDimnames) dimnames(x) <- dimnames 450s + else dimnames(x) <- NULL 450s + # Row/column variance 450s + for (na.rm in c(FALSE, TRUE)) { 450s + # Check names attribute 450s + for (useNames in c(TRUE, FALSE)) { 450s + cat("na.rm = ", na.rm, "\n", sep = "") 450s + 450s + r0 <- rowVars_R(x, na.rm = na.rm, useNames = useNames) 450s + r1 <- rowVars(x, na.rm = na.rm, useNames = useNames) 450s + r1b <- rowVars_center(x, na.rm = na.rm, useNames = useNames) 450s + r2 <- colVars(t(x), na.rm = na.rm, useNames = useNames) 450s + r2b <- colVars_center(t(x), na.rm = na.rm, useNames = useNames) 450s + stopifnot(all.equal(r1, r2)) 450s + stopifnot(all.equal(r1, r0)) 450s + stopifnot(all.equal(r2, r0)) 450s + stopifnot(all.equal(r1b, r2b)) 450s + stopifnot( 450s + !any(is.infinite(r0)), 450s + !any(is.infinite(r1)), 450s + !any(is.infinite(r2)), 450s + !any(is.infinite(r1b)), 450s + !any(is.infinite(r2b)) 450s + ) 450s + } 450s + } 450s + } 450s na.rm = FALSE 450s na.rm = FALSE 450s na.rm = TRUE 450s na.rm = TRUE 450s na.rm = FALSE 450s na.rm = FALSE 450s na.rm = TRUE 450s na.rm = TRUE 450s > 450s > 450s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 450s > # center and .dim 450s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 450s > m <- matrix(1:12, nrow = 3L, ncol = 4L) 450s > a <- array(m, dim = c(3, 2, 2)) 450s > stopifnot(prod(dim(a)) == prod(dim(m))) 450s > 450s > y0 <- rowVars(m, dim. = dim(m)) 450s > print(y0) 450s [1] 15 15 15 450s > y1 <- rowVars(a, dim. = dim(m)) 450s > print(y1) 450s [1] 15 15 15 450s > stopifnot(identical(y1, y0)) 450s > stopifnot( 450s + !any(is.infinite(y0)), 450s + !any(is.infinite(y1)) 450s + ) 450s > 450s > mu <- rowMeans(m) 450s > y0 <- rowVars(m, center = mu, dim. = dim(m)) 450s > print(y0) 450s [1] 15 15 15 450s > y1 <- rowVars(a, center = mu, dim. = dim(m)) 450s > print(y1) 450s [1] 15 15 15 450s > stopifnot(identical(y1, y0)) 450s > stopifnot( 450s + !any(is.infinite(y0)), 450s + !any(is.infinite(y1)) 450s + ) 450s > 450s > 450s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 450s > # Corner cases 450s > # https://github.com/HenrikBengtsson/matrixStats/issues/195 450s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 450s > x <- matrix(c(1,2,3,4), nrow = 2L, ncol = 2L) 450s > x[1,1] <- NA_real_ 450s > x[1,2] <- Inf 450s > 450s > center <- colMeans2(x, na.rm = TRUE) 450s > y <- colVars(x, center = center, na.rm = TRUE) 450s > stopifnot(!any(is.infinite(y))) 450s > 450s > x <- t(x) 450s > center <- rowMeans2(x, na.rm = TRUE) 450s > y <- rowVars(x, center = center, na.rm = TRUE) 450s > stopifnot(!any(is.infinite(y))) 450s > 450s 450s R version 4.4.3 (2025-02-28) -- "Trophy Case" 450s Copyright (C) 2025 The R Foundation for Statistical Computing 450s Platform: arm-unknown-linux-gnueabihf (32-bit) 450s 450s R is free software and comes with ABSOLUTELY NO WARRANTY. 450s You are welcome to redistribute it under certain conditions. 450s Type 'license()' or 'licence()' for distribution details. 450s 450s R is a collaborative project with many contributors. 450s Type 'contributors()' for more information and 450s 'citation()' on how to cite R or R packages in publications. 450s 450s Type 'demo()' for some demos, 'help()' for on-line help, or 450s 'help.start()' for an HTML browser interface to help. 450s Type 'q()' to quit R. 450s 451s > library("matrixStats") 451s > 451s > ## Always allow testing of the 'center' argument (as long as it's not defunct) 451s > options(matrixStats.center.onUse = "ignore") 451s > 451s > ## Create isFALSE() if running on an old version of R 451s > if (!exists("isFALSE", mode="function")) { 451s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 451s + } 451s > 451s > rowVars_R <- function(x, na.rm = FALSE, center = NULL, ..., useNames = TRUE) { 451s + suppressWarnings({ 451s + res <- apply(x, MARGIN = 1L, FUN = var, na.rm = na.rm) 451s + }) 451s + stopifnot(!any(is.infinite(res))) 451s + 451s + # Keep naming support consistency same as rowVars() 451s + if (is.null(center) || ncol(x) <= 1L) { 451s + if (isFALSE(useNames)) names(res) <- NULL 451s + } 451s + else if (isFALSE(useNames)) names(res) <- NULL 451s + res 451s + } 451s > 451s > colVars_R <- function(x, na.rm = FALSE, center = NULL, ..., useNames = TRUE) { 451s + suppressWarnings({ 451s + res <- apply(x, MARGIN = 2L, FUN = var, na.rm = na.rm) 451s + }) 451s + stopifnot(!any(is.infinite(res))) 451s + 451s + # Keep naming support consistency same as colVars() 451s + if (is.null(center) || nrow(x) <= 1L) { 451s + if (isFALSE(useNames)) names(res) <- NULL 451s + } 451s + else if (isFALSE(useNames)) names(res) <- NULL 451s + res 451s + } 451s > 451s > 451s > rowVars_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) { 451s + center <- rowWeightedMeans(x, cols = cols, na.rm = na.rm, useNames = FALSE) 451s + res <- rowVars(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 451s + stopifnot(!any(is.infinite(res))) 451s + res 451s + } 451s > 451s > colVars_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) { 451s + center <- colWeightedMeans(x, rows = rows, na.rm = na.rm, useNames = FALSE) 451s + res <- colVars(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 451s + stopifnot(!any(is.infinite(res))) 451s + res 451s + } 451s > 451s > 451s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 451s > # Subsetted tests 451s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 451s > source("utils/validateIndicesFramework.R") 451s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 451s > storage.mode(x) <- "integer" 451s > 451s > # To check names attribute 451s > dimnames <- list(letters[1:6], LETTERS[1:6]) 451s > 451s > # Test with and without dimnames on x 451s > for (setDimnames in c(TRUE, FALSE)) { 451s + if (setDimnames) dimnames(x) <- dimnames 451s + else dimnames(x) <- NULL 451s + 451s + count <- 0L 451s + for (rows in index_cases) { 451s + for (cols in index_cases) { 451s + count <- count + 1L 451s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 451s + useNames <- c(TRUE, FALSE) 451s + useNames <- useNames[count %% length(useNames) + 1] 451s + 451s + validateIndicesTestMatrix(x, rows, cols, 451s + ftest = rowVars, fsure = rowVars_R, 451s + na.rm = na.rm, useNames = useNames) 451s + validateIndicesTestMatrix(x, rows, cols, 451s + ftest = rowVars_center, fsure = rowVars_R, 451s + na.rm = na.rm, center = TRUE, useNames = useNames) 451s + 451s + validateIndicesTestMatrix(x, rows, cols, 451s + fcoltest = colVars, fsure = rowVars_R, 451s + na.rm = na.rm, useNames = useNames) 451s + validateIndicesTestMatrix(x, rows, cols, 451s + fcoltest = colVars_center, fsure = rowVars_R, 451s + na.rm = na.rm, center = TRUE, useNames = useNames) 451s + } 451s + } 451s + } 452s > 452s 452s R version 4.4.3 (2025-02-28) -- "Trophy Case" 452s Copyright (C) 2025 The R Foundation for Statistical Computing 452s Platform: arm-unknown-linux-gnueabihf (32-bit) 452s 452s R is free software and comes with ABSOLUTELY NO WARRANTY. 452s You are welcome to redistribute it under certain conditions. 452s Type 'license()' or 'licence()' for distribution details. 452s 452s R is a collaborative project with many contributors. 452s Type 'contributors()' for more information and 452s 'citation()' on how to cite R or R packages in publications. 452s 452s Type 'demo()' for some demos, 'help()' for on-line help, or 452s 'help.start()' for an HTML browser interface to help. 452s Type 'q()' to quit R. 452s 452s > library("matrixStats") 452s > 452s > ## Create isFALSE() if running on an old version of R 452s > if (!exists("isFALSE", mode="function")) { 452s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 452s + } 452s > 452s > rowWeightedMeans_R <- function(x, w, na.rm = FALSE, ..., useNames = TRUE) { 452s + res <- apply(x, MARGIN = 1L, FUN = weighted.mean, w = w, na.rm = na.rm, ...) 452s + 452s + # Keep naming support consistency same as rowWeightedMeans() 452s + idxs <- which(is.na(w) | w != 0) 452s + nw <- length(idxs) 452s + if (na.rm) na.rm <- anyMissing(x) 452s + if ((!is.null(w) && nw == 0L) || isFALSE(na.rm)) { 452s + if (!useNames) names(res) <- NULL 452s + } 452s + else if (isFALSE(useNames)) names(res) <- NULL 452s + 452s + res 452s + } 452s > 452s > colWeightedMeans_R <- function(x, w, na.rm = FALSE, ..., useNames = TRUE) { 452s + res <- apply(x, MARGIN = 2L, FUN = weighted.mean, w = w, na.rm = na.rm, ...) 452s + 452s + # Keep naming support consistency same as colWeightedMeans() 452s + idxs <- which(is.na(w) | w != 0) 452s + nw <- length(idxs) 452s + if (!is.null(w) && nw == 0L) { 452s + if (!useNames) names(res) <- NULL 452s + } 452s + else if (isFALSE(useNames)) names(res) <- NULL 452s + 452s + res 452s + } 452s > 452s > set.seed(1) 452s > 452s > x <- matrix(rnorm(20), nrow = 5, ncol = 4) 452s > print(x) 452s [,1] [,2] [,3] [,4] 452s [1,] -0.6264538 -0.8204684 1.5117812 -0.04493361 452s [2,] 0.1836433 0.4874291 0.3898432 -0.01619026 452s [3,] -0.8356286 0.7383247 -0.6212406 0.94383621 452s [4,] 1.5952808 0.5757814 -2.2146999 0.82122120 452s [5,] 0.3295078 -0.3053884 1.1249309 0.59390132 452s > 452s > # To check names attribute 452s > dimnames <- list(letters[1:5], LETTERS[1:4]) 452s > 452s > # Non-weighted row averages 452s > x_est0 <- rowMeans(x) 452s > x_est1 <- rowWeightedMeans(x) 452s > print(x_est1) 452s [1] 0.004981341 0.261181337 0.056322931 0.194395865 0.435737906 452s > stopifnot(all.equal(x_est1, x_est0)) 452s > x_est2 <- colWeightedMeans(t(x)) 452s > stopifnot(all.equal(x_est2, x_est0)) 452s > # Check names attribute 452s > dimnames(x) <- dimnames 452s > x_est1 <- rowWeightedMeans(x, useNames = FALSE) 452s > x_est2 <- colWeightedMeans(t(x), useNames = FALSE) 452s > stopifnot(all.equal(x_est1, x_est0)) 452s > stopifnot(all.equal(x_est2, x_est0)) 452s > x_est0 <- rowMeans(x) 452s > x_est1 <- rowWeightedMeans(x, useNames = TRUE) 452s > x_est2 <- colWeightedMeans(t(x), useNames = TRUE) 452s > stopifnot(all.equal(x_est1, x_est0)) 452s > stopifnot(all.equal(x_est2, x_est0)) 452s > dimnames(x) <- NULL 452s > 452s > 452s > # Weighted row averages (uniform weights) 452s > w <- rep(2.5, times = ncol(x)) 452s > x_est0 <- rowMeans(x) 452s > x_est1 <- rowWeightedMeans(x, w = w) 452s > print(x_est1) 452s [1] 0.004981341 0.261181337 0.056322931 0.194395865 0.435737906 452s > stopifnot(all.equal(x_est1, x_est0)) 452s > x_est2 <- colWeightedMeans(t(x), w = w) 452s > stopifnot(all.equal(x_est2, x_est0)) 452s > # Test with and without dimnames on x 452s > for (setDimnames in c(TRUE, FALSE)) { 452s + if (setDimnames) dimnames(x) <- dimnames 452s + else dimnames(x) <- NULL 452s + # Check names attribute 452s + for (useNames in c(TRUE, FALSE)) { 452s + x_est0 <- rowWeightedMeans_R(x, w = w, useNames = useNames) 452s + x_est1 <- rowWeightedMeans(x, w = w, useNames = useNames) 452s + stopifnot(all.equal(x_est1, x_est0)) 452s + x_est0 <- colWeightedMeans_R(t(x), w = w, useNames = useNames) 452s + x_est1 <- colWeightedMeans(t(x), w = w, useNames = useNames) 452s + stopifnot(all.equal(x_est1, x_est0)) 452s + } 452s + } 452s > 452s > 452s > # Weighted row averages (excluding some columns) 452s > w <- c(1, 1, 0, 1) 452s > x_est0 <- rowMeans(x[, (w == 1), drop = FALSE]) 452s > x_est1 <- rowWeightedMeans(x, w = w) 452s > print(x_est1) 452s [1] -0.4972853 0.2182940 0.2821774 0.9974278 0.2060069 452s > stopifnot(all.equal(x_est1, x_est0)) 452s > x_est2 <- colWeightedMeans(t(x), w = w) 452s > stopifnot(all.equal(x_est2, x_est0)) 452s > # Test with and without dimnames on x 452s > for (setDimnames in c(TRUE, FALSE)) { 452s + if (setDimnames) dimnames(x) <- dimnames 452s + else dimnames(x) <- NULL 452s + # Check names attribute 452s + for (useNames in c(TRUE, FALSE)) { 452s + x_est0 <- rowWeightedMeans_R(x, w = w, useNames = useNames) 452s + x_est1 <- rowWeightedMeans(x, w = w, useNames = useNames) 452s + stopifnot(all.equal(x_est1, x_est0)) 452s + x_est0 <- colWeightedMeans_R(t(x), w = w, useNames = useNames) 452s + x_est1 <- colWeightedMeans(t(x), w = w, useNames = useNames) 452s + stopifnot(all.equal(x_est1, x_est0)) 452s + } 452s + } 452s > 452s > 452s > # Weighted row averages (excluding some columns) 452s > w <- c(0, 1, 0, 0) 452s > x_est0 <- rowMeans(x[, (w == 1), drop = FALSE]) 452s > x_est1 <- rowWeightedMeans(x, w = w) 452s > stopifnot(all.equal(x_est1, x_est0)) 452s > x_est2 <- colWeightedMeans(t(x), w = w) 452s > stopifnot(all.equal(x_est2, x_est0)) 452s > # Test with and without dimnames on x 452s > for (setDimnames in c(TRUE, FALSE)) { 452s + if (setDimnames) dimnames(x) <- dimnames 452s + else dimnames(x) <- NULL 452s + # Check names attribute 452s + for (useNames in c(TRUE, FALSE)) { 452s + x_est0 <- rowWeightedMeans_R(x, w = w, useNames = useNames) 452s + x_est1 <- rowWeightedMeans(x, w = w, useNames = useNames) 452s + stopifnot(all.equal(x_est1, x_est0)) 452s + x_est0 <- colWeightedMeans_R(t(x), w = w, useNames = useNames) 452s + x_est1 <- colWeightedMeans(t(x), w = w, useNames = useNames) 452s + stopifnot(all.equal(x_est1, x_est0)) 452s + } 452s + } 452s > 452s > 452s > # Weighted row averages (all zero weights) 452s > w <- c(0, 0, 0, 0) 452s > x_est0 <- rowMeans(x[, (w == 1), drop = FALSE]) 452s > x_est1 <- rowWeightedMeans(x, w = w) 452s > stopifnot(all.equal(x_est1, x_est0)) 452s > x_est2 <- colWeightedMeans(t(x), w = w) 452s > stopifnot(all.equal(x_est2, x_est0)) 452s > # Test with and without dimnames on x 452s > for (setDimnames in c(TRUE, FALSE)) { 452s + if (setDimnames) dimnames(x) <- dimnames 452s + else dimnames(x) <- NULL 452s + # Check names attribute 452s + for (useNames in c(TRUE, FALSE)) { 452s + x_est0 <- rowWeightedMeans_R(x, w = w, useNames = useNames) 452s + x_est1 <- rowWeightedMeans(x, w = w, useNames = useNames) 452s + stopifnot(all.equal(x_est1, x_est0)) 452s + x_est0 <- colWeightedMeans_R(t(x), w = w, useNames = useNames) 452s + x_est1 <- colWeightedMeans(t(x), w = w, useNames = useNames) 452s + stopifnot(all.equal(x_est1, x_est0)) 452s + } 452s + } 452s > 452s > 452s > # Weighted averages by rows and columns 452s > w <- 1:4 452s > x_est1 <- rowWeightedMeans(x, w = w) 452s > print(x_est1) 452s [1] 0.20882185 0.22632701 0.25526439 -0.06123714 0.54691290 452s > x_est2 <- colWeightedMeans(t(x), w = w) 452s > stopifnot(all.equal(x_est2, x_est1)) 452s > # Test with and without dimnames on x 452s > for (setDimnames in c(TRUE, FALSE)) { 452s + if (setDimnames) dimnames(x) <- dimnames 452s + else dimnames(x) <- NULL 452s + # Check names attribute 452s + for (useNames in c(TRUE, FALSE)) { 452s + x_est0 <- rowWeightedMeans_R(x, w = w, useNames = useNames) 452s + x_est1 <- rowWeightedMeans(x, w = w, useNames = useNames) 452s + stopifnot(all.equal(x_est1, x_est0)) 452s + x_est0 <- colWeightedMeans_R(t(x), w = w, useNames = useNames) 452s + x_est1 <- colWeightedMeans(t(x), w = w, useNames = useNames) 452s + stopifnot(all.equal(x_est1, x_est0)) 452s + } 452s + } 452s > 452s > 452s > x[sample(length(x), size = 0.3 * length(x))] <- NA 452s > print(x) 452s [,1] [,2] [,3] [,4] 452s [1,] -0.6264538 NA 1.5117812 -0.04493361 452s [2,] 0.1836433 NA NA -0.01619026 452s [3,] -0.8356286 0.7383247 -0.6212406 0.94383621 452s [4,] 1.5952808 NA -2.2146999 0.82122120 452s [5,] 0.3295078 NA NA 0.59390132 452s > 452s > # Non-weighted row averages with missing values 452s > x_est0 <- rowMeans(x, na.rm = TRUE) 452s > x_est1 <- rowWeightedMeans(x, na.rm = TRUE) 452s > print(x_est1) 452s [1] 0.28013125 0.08372653 0.05632293 0.06726737 0.46170455 452s > stopifnot(all.equal(x_est1, x_est0)) 452s > x_est2 <- colWeightedMeans(t(x), na.rm = TRUE) 452s > stopifnot(all.equal(x_est2, x_est0)) 452s > # Check names attribute 452s > dimnames(x) <- dimnames 452s > x_est1 <- rowWeightedMeans(x, na.rm = TRUE, useNames = FALSE) 452s > x_est2 <- colWeightedMeans(t(x), na.rm = TRUE, useNames = FALSE) 452s > stopifnot(all.equal(x_est1, x_est0)) 452s > stopifnot(all.equal(x_est2, x_est0)) 452s > x_est0 <- rowMeans(x, na.rm = TRUE) 452s > x_est1 <- rowWeightedMeans(x, na.rm = TRUE, useNames = TRUE) 452s > x_est2 <- colWeightedMeans(t(x), na.rm = TRUE, useNames = TRUE) 452s > stopifnot(all.equal(x_est1, x_est0)) 452s > stopifnot(all.equal(x_est2, x_est0)) 452s > dimnames(x) <- NULL 452s > 452s > 452s > # Weighted row averages with missing values 452s > x_est0 <- apply(x, MARGIN = 1L, FUN = weighted.mean, w = w, na.rm = TRUE) 452s > print(x_est0) 452s [1] 0.46614441 0.02377645 0.25526439 -0.22049176 0.54102261 452s > x_est1 <- rowWeightedMeans(x, w = w, na.rm = TRUE) 452s > print(x_est1) 452s [1] 0.46614441 0.02377645 0.25526439 -0.22049176 0.54102261 452s > stopifnot(all.equal(x_est1, x_est0)) 452s > x_est2 <- colWeightedMeans(t(x), w = w, na.rm = TRUE) 452s > stopifnot(all.equal(x_est2, x_est0)) 452s > # Test with and without dimnames on x 452s > for (setDimnames in c(TRUE, FALSE)) { 452s + if (setDimnames) dimnames(x) <- dimnames 452s + else dimnames(x) <- NULL 452s + # Check names attribute 452s + for (useNames in c(TRUE, FALSE)) { 452s + x_est0 <- rowWeightedMeans_R(x, w = w, na.rm = TRUE, useNames = useNames) 452s + x_est1 <- rowWeightedMeans(x, w = w, na.rm = TRUE, useNames = useNames) 452s + stopifnot(all.equal(x_est1, x_est0)) 452s + x_est0 <- colWeightedMeans_R(t(x), w = w, na.rm = TRUE, useNames = useNames) 452s + x_est1 <- colWeightedMeans(t(x), w = w, na.rm = TRUE, useNames = useNames) 452s + stopifnot(all.equal(x_est1, x_est0)) 452s + } 452s + } 452s > 452s > 452s > # Weighted averages by rows and columns 452s > w <- 1:4 452s > x_est1 <- rowWeightedMeans(x, w = w, na.rm = TRUE) 452s > x_est2 <- colWeightedMeans(t(x), w = w, na.rm = TRUE) 452s > stopifnot(all.equal(x_est2, x_est1)) 452s > # Test with and without dimnames on x 452s > for (setDimnames in c(TRUE, FALSE)) { 452s + if (setDimnames) dimnames(x) <- dimnames 452s + else dimnames(x) <- NULL 452s + # Check names attribute 452s + for (useNames in c(TRUE, FALSE)) { 452s + x_est0 <- rowWeightedMeans_R(x, w = w, na.rm = TRUE, useNames = useNames) 452s + x_est1 <- rowWeightedMeans(x, w = w, na.rm = TRUE, useNames = useNames) 452s + stopifnot(all.equal(x_est1, x_est0)) 452s + x_est0 <- colWeightedMeans_R(t(x), w = w, na.rm = TRUE, useNames = useNames) 452s + x_est1 <- colWeightedMeans(t(x), w = w, na.rm = TRUE, useNames = useNames) 452s + stopifnot(all.equal(x_est1, x_est0)) 452s + } 452s + } 452s > 452s > 452s > # w contains missing value 452s > w[1] <- NA_integer_ 452s > x_est1 <- rowWeightedMeans(x, w = w, na.rm = TRUE) 452s > x_est2 <- colWeightedMeans(t(x), w = w, na.rm = TRUE) 452s > stopifnot(all.equal(x_est2, x_est1)) 452s > # Test with and without dimnames on x 452s > for (setDimnames in c(TRUE, FALSE)) { 452s + if (setDimnames) dimnames(x) <- dimnames 452s + else dimnames(x) <- NULL 452s + # Check names attribute 452s + for (useNames in c(TRUE, FALSE)) { 452s + x_est0 <- rowWeightedMeans_R(x, w = w, na.rm = TRUE, useNames = useNames) 452s + x_est1 <- rowWeightedMeans(x, w = w, na.rm = TRUE, useNames = useNames) 452s + stopifnot(all.equal(x_est1, x_est0)) 452s + x_est0 <- colWeightedMeans_R(t(x), w = w, na.rm = TRUE, useNames = useNames) 452s + x_est1 <- colWeightedMeans(t(x), w = w, na.rm = TRUE, useNames = useNames) 452s + stopifnot(all.equal(x_est1, x_est0)) 452s + } 452s + } 452s > 452s > x_est1 <- rowWeightedMeans(x, w = w, na.rm = FALSE) 452s > x_est2 <- colWeightedMeans(t(x), w = w, na.rm = FALSE) 452s > stopifnot(all.equal(x_est2, x_est1)) 452s > # Test with and without dimnames on x 452s > for (setDimnames in c(TRUE, FALSE)) { 452s + if (setDimnames) dimnames(x) <- dimnames 452s + else dimnames(x) <- NULL 452s + # Check names attribute 452s + for (useNames in c(TRUE, FALSE)) { 452s + x_est0 <- rowWeightedMeans_R(x, w = w, na.rm = FALSE, useNames = useNames) 452s + x_est1 <- rowWeightedMeans(x, w = w, na.rm = FALSE, useNames = useNames) 452s + stopifnot(all.equal(x_est1, x_est0)) 452s + x_est0 <- colWeightedMeans_R(t(x), w = w, na.rm = FALSE, useNames = useNames) 452s + x_est1 <- colWeightedMeans(t(x), w = w, na.rm = FALSE, useNames = useNames) 452s + stopifnot(all.equal(x_est1, x_est0)) 452s + } 452s + } 452s > 452s 452s R version 4.4.3 (2025-02-28) -- "Trophy Case" 452s Copyright (C) 2025 The R Foundation for Statistical Computing 452s Platform: arm-unknown-linux-gnueabihf (32-bit) 452s 452s R is free software and comes with ABSOLUTELY NO WARRANTY. 452s You are welcome to redistribute it under certain conditions. 452s Type 'license()' or 'licence()' for distribution details. 452s 452s R is a collaborative project with many contributors. 452s Type 'contributors()' for more information and 452s 'citation()' on how to cite R or R packages in publications. 452s 452s Type 'demo()' for some demos, 'help()' for on-line help, or 452s 'help.start()' for an HTML browser interface to help. 452s Type 'q()' to quit R. 452s 452s > library("matrixStats") 452s > 452s > ## Create isFALSE() if running on an old version of R 452s > if (!exists("isFALSE", mode="function")) { 452s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 452s + } 452s > 452s > rowWeightedMeans_R <- function(x, w, na.rm = FALSE, ..., useNames = TRUE) { 452s + res <- apply(x, MARGIN = 1L, FUN = weighted.mean, w = w, na.rm = na.rm, ...) 452s + 452s + # Keep naming support consistency same as rowWeightedMeans() 452s + idxs <- which(is.na(w) | w != 0) 452s + nw <- length(idxs) 452s + if (na.rm) na.rm <- anyMissing(x) 452s + if ((!is.null(w) && nw == 0L) || isFALSE(na.rm)) { 452s + if (!useNames) names(res) <- NULL 452s + } 452s + else if (isFALSE(useNames)) names(res) <- NULL 452s + 452s + res 452s + } 452s > 452s > colWeightedMeans_R <- function(x, w, na.rm = FALSE, ..., useNames = TRUE) { 452s + res <- apply(x, MARGIN = 1L, FUN = weighted.mean, w = w, na.rm = na.rm, ...) 452s + 452s + # Keep naming support consistency same as colWeightedMeans() 452s + idxs <- which(is.na(w) | w != 0) 452s + nw <- length(idxs) 452s + if (!is.null(w) && nw == 0L) { 452s + if (!useNames) names(res) <- NULL 452s + } 452s + else if (isFALSE(useNames)) names(res) <- NULL 452s + 452s + res 452s + } 452s > 452s > 452s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 452s > # Subsetted tests 452s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 452s > source("utils/validateIndicesFramework.R") 452s > # To check names attribute 452s > dimnames <- list(letters[1:6], LETTERS[1:6]) 452s > for (mode in c("numeric", "integer", "logical")) { 452s + x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 452s + w <- runif(6, min = 0, max = 6) 452s + storage.mode(x) <- mode 452s + storage.mode(w) <- if (mode == "logical") "integer" else mode 452s + if (mode == "numeric") w[1] <- Inf 452s + 452s + # Test with and without dimnames on x 452s + for (setDimnames in c(TRUE, FALSE)) { 452s + if (setDimnames) dimnames(x) <- dimnames 452s + else dimnames(x) <- NULL 452s + 452s + count <- 0L 452s + for (rows in index_cases) { 452s + for (cols in index_cases) { 452s + count <- count + 1L 452s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 452s + useNames <- c(TRUE, FALSE) 452s + useNames <- useNames[count %% length(useNames) + 1] 452s + 452s + validateIndicesTestMatrix_w(x, w, rows, cols, 452s + ftest = rowWeightedMeans, fsure = rowWeightedMeans_R, 452s + na.rm = na.rm, useNames = useNames) 452s + validateIndicesTestMatrix_w(x, w, rows, cols, 452s + fcoltest = colWeightedMeans, fsure = colWeightedMeans_R, 452s + na.rm = na.rm, useNames = useNames) 452s + } 452s + } 452s + } 452s + } 454s > 454s 454s R version 4.4.3 (2025-02-28) -- "Trophy Case" 454s Copyright (C) 2025 The R Foundation for Statistical Computing 454s Platform: arm-unknown-linux-gnueabihf (32-bit) 454s 454s R is free software and comes with ABSOLUTELY NO WARRANTY. 454s You are welcome to redistribute it under certain conditions. 454s Type 'license()' or 'licence()' for distribution details. 454s 454s R is a collaborative project with many contributors. 454s Type 'contributors()' for more information and 454s 'citation()' on how to cite R or R packages in publications. 454s 454s Type 'demo()' for some demos, 'help()' for on-line help, or 454s 'help.start()' for an HTML browser interface to help. 454s Type 'q()' to quit R. 454s 455s > library("matrixStats") 455s > 455s > ## Create isFALSE() if running on an old version of R 455s > if (!exists("isFALSE", mode="function")) { 455s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 455s + } 455s > 455s > rowWeightedMedians_R <- function(x, w, na.rm = FALSE, ..., useNames = TRUE) { 455s + res <- apply(x, MARGIN = 1L, FUN = weightedMedian, w = w, na.rm = na.rm, ...) 455s + 455s + # Keep naming support consistency same as rowWeightedMedians() 455s + if (!is.null(w)) { 455s + if (isFALSE(useNames)) names(res) <- NULL 455s + } 455s + else if (!useNames) names(res) <- NULL 455s + 455s + res 455s + } 455s > 455s > colWeightedMedians_R <- function(x, w, na.rm = FALSE, ..., useNames = TRUE) { 455s + res <- apply(x, MARGIN = 2L, FUN = weightedMedian, w = w, na.rm = na.rm, ...) 455s + 455s + # Keep naming support consistency same as colWeightedMedians() 455s + if (!is.null(w)) { 455s + if (isFALSE(useNames)) names(res) <- NULL 455s + } 455s + else if (!useNames) names(res) <- NULL 455s + 455s + res 455s + } 455s > 455s > set.seed(1) 455s > 455s > x <- matrix(rnorm(20), nrow = 5, ncol = 4) 455s > print(x) 455s [,1] [,2] [,3] [,4] 455s [1,] -0.6264538 -0.8204684 1.5117812 -0.04493361 455s [2,] 0.1836433 0.4874291 0.3898432 -0.01619026 455s [3,] -0.8356286 0.7383247 -0.6212406 0.94383621 455s [4,] 1.5952808 0.5757814 -2.2146999 0.82122120 455s [5,] 0.3295078 -0.3053884 1.1249309 0.59390132 455s > 455s > # To check names attribute 455s > dimnames <- list(letters[1:5], LETTERS[1:4]) 455s > 455s > # Non-weighted row medians 455s > x_est0 <- rowMedians(x) 455s > x_est1 <- rowWeightedMedians(x) 455s > stopifnot(all.equal(x_est1, x_est0)) 455s > x_est2 <- colWeightedMedians(t(x)) 455s > stopifnot(all.equal(x_est2, x_est0)) 455s > # Test with and without dimnames on x 455s > for (setDimnames in c(TRUE, FALSE)) { 455s + if (setDimnames) dimnames(x) <- dimnames 455s + else dimnames(x) <- NULL 455s + # Check names attribute 455s + for (useNames in c(TRUE, FALSE)) { 455s + x_est0 <- rowMedians(x, useNames = useNames) 455s + x_est1 <- rowWeightedMedians(x, useNames = useNames) 455s + x_est2 <- colWeightedMedians(t(x), useNames = useNames) 455s + stopifnot(all.equal(x_est1, x_est0)) 455s + stopifnot(all.equal(x_est2, x_est0)) 455s + } 455s + } 455s > 455s > 455s > # Weighted row medians (uniform weights) 455s > w <- rep(2.5, times = ncol(x)) 455s > x_est0 <- rowMedians(x) 455s > x_est1 <- rowWeightedMedians(x, w = w) 455s > stopifnot(all.equal(x_est1, x_est0)) 455s > x_est2 <- colWeightedMedians(t(x), w = w) 455s > stopifnot(all.equal(x_est2, x_est0)) 455s > # Test with and without dimnames on x 455s > for (setDimnames in c(TRUE, FALSE)) { 455s + if (setDimnames) dimnames(x) <- dimnames 455s + else dimnames(x) <- NULL 455s + # Check names attribute 455s + for (useNames in c(TRUE, FALSE)) { 455s + x_est0 <- rowWeightedMedians_R(x, w = w, useNames = useNames) 455s + x_est1 <- rowWeightedMedians(x, w = w, useNames = useNames) 455s + stopifnot(all.equal(x_est1, x_est0)) 455s + x_est0 <- colWeightedMedians_R(t(x), w = w, useNames = useNames) 455s + x_est1 <- colWeightedMedians(t(x), w = w, useNames = useNames) 455s + stopifnot(all.equal(x_est1, x_est0)) 455s + } 455s + } 455s > 455s > 455s > # Weighted row medians (excluding some columns) 455s > w <- c(1, 1, 0, 1) 455s > x_est0 <- rowMedians(x[, (w == 1), drop = FALSE]) 455s > x_est1 <- rowWeightedMedians(x, w = w) 455s > stopifnot(all.equal(x_est1, x_est0)) 455s > x_est2 <- colWeightedMedians(t(x), w = w) 455s > stopifnot(all.equal(x_est2, x_est0)) 455s > # Test with and without dimnames on x 455s > for (setDimnames in c(TRUE, FALSE)) { 455s + if (setDimnames) dimnames(x) <- dimnames 455s + else dimnames(x) <- NULL 455s + # Check names attribute 455s + for (useNames in c(TRUE, FALSE)) { 455s + x_est0 <- rowWeightedMedians_R(x, w = w, useNames = useNames) 455s + x_est1 <- rowWeightedMedians(x, w = w, useNames = useNames) 455s + stopifnot(all.equal(x_est1, x_est0)) 455s + x_est0 <- colWeightedMedians_R(t(x), w = w, useNames = useNames) 455s + x_est1 <- colWeightedMedians(t(x), w = w, useNames = useNames) 455s + stopifnot(all.equal(x_est1, x_est0)) 455s + } 455s + } 455s > 455s > # Weighted row medians (excluding some columns) 455s > w <- c(0, 1, 0, 0) 455s > x_est0 <- rowMedians(x[, (w == 1), drop = FALSE]) 455s > x_est1 <- rowWeightedMedians(x, w = w) 455s > stopifnot(all.equal(x_est1, x_est0)) 455s > x_est2 <- colWeightedMedians(t(x), w = w) 455s > stopifnot(all.equal(x_est2, x_est0)) 455s > # Test with and without dimnames on x 455s > for (setDimnames in c(TRUE, FALSE)) { 455s + if (setDimnames) dimnames(x) <- dimnames 455s + else dimnames(x) <- NULL 455s + # Check names attribute 455s + for (useNames in c(TRUE, FALSE)) { 455s + x_est0 <- rowWeightedMedians_R(x, w = w, useNames = useNames) 455s + x_est1 <- rowWeightedMedians(x, w = w, useNames = useNames) 455s + stopifnot(all.equal(x_est1, x_est0)) 455s + x_est0 <- colWeightedMedians_R(t(x), w = w, useNames = useNames) 455s + x_est1 <- colWeightedMedians(t(x), w = w, useNames = useNames) 455s + stopifnot(all.equal(x_est1, x_est0)) 455s + } 455s + } 455s > 455s > # Weighted row medians (all zero weights) 455s > w <- c(0, 0, 0, 0) 455s > x_est0 <- rowMedians(x[, (w == 1), drop = FALSE]) 455s > x_est1 <- rowWeightedMedians(x, w = w) 455s > stopifnot(all.equal(x_est1, x_est0)) 455s > x_est2 <- colWeightedMedians(t(x), w = w) 455s > stopifnot(all.equal(x_est2, x_est0)) 455s > # Test with and without dimnames on x 455s > for (setDimnames in c(TRUE, FALSE)) { 455s + if (setDimnames) dimnames(x) <- dimnames 455s + else dimnames(x) <- NULL 455s + # Check names attribute 455s + for (useNames in c(TRUE, FALSE)) { 455s + x_est0 <- rowWeightedMedians_R(x, w = w, useNames = useNames) 455s + x_est1 <- rowWeightedMedians(x, w = w, useNames = useNames) 455s + stopifnot(all.equal(x_est1, x_est0)) 455s + x_est0 <- colWeightedMedians_R(t(x), w = w, useNames = useNames) 455s + x_est1 <- colWeightedMedians(t(x), w = w, useNames = useNames) 455s + stopifnot(all.equal(x_est1, x_est0)) 455s + } 455s + } 455s > 455s > # Weighted medians by rows and columns 455s > w <- 1:4 455s > x_est1 <- rowWeightedMedians(x, w = w) 455s > x_est2 <- colWeightedMedians(t(x), w = w) 455s > stopifnot(all.equal(x_est2, x_est1)) 455s > # Test with and without dimnames on x 455s > for (setDimnames in c(TRUE, FALSE)) { 455s + if (setDimnames) dimnames(x) <- dimnames 455s + else dimnames(x) <- NULL 455s + # Check names attribute 455s + for (useNames in c(TRUE, FALSE)) { 455s + x_est0 <- rowWeightedMedians_R(x, w = w, useNames = useNames) 455s + x_est1 <- rowWeightedMedians(x, w = w, useNames = useNames) 455s + stopifnot(all.equal(x_est1, x_est0)) 455s + x_est0 <- colWeightedMedians_R(t(x), w = w, useNames = useNames) 455s + x_est1 <- colWeightedMedians(t(x), w = w, useNames = useNames) 455s + stopifnot(all.equal(x_est1, x_est0)) 455s + } 455s + } 455s > 455s > 455s > # Weighted row medians with missing values 455s > x_est0 <- apply(x, MARGIN = 1L, FUN = weightedMedian, w = w, na.rm = TRUE) 455s > print(x_est0) 455s [1] -0.04493361 0.23519330 0.73832471 0.65759463 0.59390132 455s > x_est1 <- rowWeightedMedians(x, w = w, na.rm = TRUE) 455s > print(x_est1) 455s [1] -0.04493361 0.23519330 0.73832471 0.65759463 0.59390132 455s > stopifnot(all.equal(x_est1, x_est0)) 455s > x_est2 <- colWeightedMedians(t(x), w = w) 455s > stopifnot(all.equal(x_est2, x_est0)) 455s > # Test with and without dimnames on x 455s > for (setDimnames in c(TRUE, FALSE)) { 455s + if (setDimnames) dimnames(x) <- dimnames 455s + else dimnames(x) <- NULL 455s + # Check names attribute 455s + for (useNames in c(TRUE, FALSE)) { 455s + x_est0 <- rowWeightedMedians_R(x, w = w, na.rm = TRUE, useNames = useNames) 455s + x_est1 <- rowWeightedMedians(x, w = w, na.rm = TRUE, useNames = useNames) 455s + stopifnot(all.equal(x_est1, x_est0)) 455s + x_est0 <- colWeightedMedians_R(t(x), w = w, na.rm = TRUE, useNames = useNames) 455s + x_est1 <- colWeightedMedians(t(x), w = w, na.rm = TRUE, useNames = useNames) 455s + stopifnot(all.equal(x_est1, x_est0)) 455s + } 455s + } 455s > 455s > # Weighted medians by rows and columns 455s > w <- 1:4 455s > x_est1 <- rowWeightedMedians(x, w = w, na.rm = TRUE) 455s > x_est2 <- colWeightedMedians(t(x), w = w, na.rm = TRUE) 455s > stopifnot(all.equal(x_est2, x_est1)) 455s > # Test with and without dimnames on x 455s > for (setDimnames in c(TRUE, FALSE)) { 455s + if (setDimnames) dimnames(x) <- dimnames 455s + else dimnames(x) <- NULL 455s + # Check names attribute 455s + for (useNames in c(TRUE, FALSE)) { 455s + x_est0 <- rowWeightedMedians_R(x, w = w, na.rm = TRUE, useNames = useNames) 455s + x_est1 <- rowWeightedMedians(x, w = w, na.rm = TRUE, useNames = useNames) 455s + stopifnot(all.equal(x_est1, x_est0)) 455s + x_est0 <- colWeightedMedians_R(t(x), w = w, na.rm = TRUE, useNames = useNames) 455s + x_est1 <- colWeightedMedians(t(x), w = w, na.rm = TRUE, useNames = useNames) 455s + stopifnot(all.equal(x_est1, x_est0)) 455s + } 455s + } 455s > 455s > 455s > # Inf weight 455s > x <- matrix(1:2, nrow = 1, ncol = 2) 455s > w <- c(7, Inf) 455s > x_est1 <- rowWeightedMedians(x, w = w) 455s > x_est2 <- colWeightedMedians(t(x), w = w) 455s > stopifnot(identical(2, x_est1)) 455s > stopifnot(identical(2, x_est2)) 455s > # Test with and without dimnames on x 455s > dimnames <- list("a", LETTERS[1:2]) 455s > for (setDimnames in c(TRUE, FALSE)) { 455s + if (setDimnames) dimnames(x) <- dimnames 455s + else dimnames(x) <- NULL 455s + # Check names attribute 455s + for (useNames in c(TRUE, FALSE)) { 455s + x_est0 <- rowWeightedMedians_R(x, w = w, useNames = useNames) 455s + x_est1 <- rowWeightedMedians(x, w = w, useNames = useNames) 455s + stopifnot(all.equal(x_est1, x_est0)) 455s + x_est0 <- colWeightedMedians_R(t(x), w = w, useNames = useNames) 455s + x_est1 <- colWeightedMedians(t(x), w = w, useNames = useNames) 455s + stopifnot(all.equal(x_est1, x_est0)) 455s + } 455s + } 455s > 455s 455s R version 4.4.3 (2025-02-28) -- "Trophy Case" 455s Copyright (C) 2025 The R Foundation for Statistical Computing 455s Platform: arm-unknown-linux-gnueabihf (32-bit) 455s 455s R is free software and comes with ABSOLUTELY NO WARRANTY. 455s You are welcome to redistribute it under certain conditions. 455s Type 'license()' or 'licence()' for distribution details. 455s 455s R is a collaborative project with many contributors. 455s Type 'contributors()' for more information and 455s 'citation()' on how to cite R or R packages in publications. 455s 455s Type 'demo()' for some demos, 'help()' for on-line help, or 455s 'help.start()' for an HTML browser interface to help. 455s Type 'q()' to quit R. 455s 455s > library("matrixStats") 455s > 455s > ## Create isFALSE() if running on an old version of R 455s > if (!exists("isFALSE", mode="function")) { 455s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 455s + } 455s > 455s > rowWeightedMedians_R <- function(x, w, na.rm = FALSE, ..., useNames = TRUE) { 455s + res <- apply(x, MARGIN = 1L, FUN = weightedMedian, w = w, na.rm = na.rm, ...) 455s + 455s + # Keep naming support consistency same as rowWeightedMedians() 455s + if (!is.null(w)) { 455s + if (isFALSE(useNames)) names(res) <- NULL 455s + } 455s + else if (!useNames) names(res) <- NULL 455s + 455s + res 455s + } 455s > 455s > 455s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 455s > # Subsetted tests 455s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 455s > source("utils/validateIndicesFramework.R") 455s > # To check names attribute 455s > dimnames <- list(letters[1:6], LETTERS[1:6]) 455s > for (mode in c("numeric", "integer", "logical")) { 455s + x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 455s + w <- runif(6, min = 0, max = 6) 455s + storage.mode(x) <- mode 455s + storage.mode(w) <- if (mode == "logical") "integer" else mode 455s + if (mode == "numeric") w[1] <- Inf 455s + 455s + # Test with and without dimnames on x 455s + for (setDimnames in c(TRUE, FALSE)) { 455s + if (setDimnames) dimnames(x) <- dimnames 455s + else dimnames(x) <- NULL 455s + 455s + count <- 0L 455s + for (rows in index_cases) { 455s + for (cols in index_cases) { 455s + count <- count + 1L 455s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 455s + useNames <- c(TRUE, FALSE) 455s + useNames <- useNames[count %% length(useNames) + 1] 455s + 455s + validateIndicesTestMatrix_w(x, w, rows, cols, 455s + ftest = rowWeightedMedians, 455s + fsure = rowWeightedMedians_R, 455s + na.rm = na.rm, useNames = useNames) 455s + validateIndicesTestMatrix_w(x, w, rows, cols, 455s + fcoltest = colWeightedMedians, 455s + fsure = rowWeightedMedians_R, 455s + na.rm = na.rm, useNames = useNames) 455s + } 455s + } 455s + } 455s + } 457s > 457s 457s R version 4.4.3 (2025-02-28) -- "Trophy Case" 457s Copyright (C) 2025 The R Foundation for Statistical Computing 457s Platform: arm-unknown-linux-gnueabihf (32-bit) 457s 457s R is free software and comes with ABSOLUTELY NO WARRANTY. 457s You are welcome to redistribute it under certain conditions. 457s Type 'license()' or 'licence()' for distribution details. 457s 457s R is a collaborative project with many contributors. 457s Type 'contributors()' for more information and 457s 'citation()' on how to cite R or R packages in publications. 457s 457s Type 'demo()' for some demos, 'help()' for on-line help, or 457s 'help.start()' for an HTML browser interface to help. 457s Type 'q()' to quit R. 457s 457s > library("matrixStats") 457s > 457s > set.seed(1) 457s > 457s > x <- matrix(rnorm(20), nrow = 5L, ncol = 4L) 457s > print(x) 457s [,1] [,2] [,3] [,4] 457s [1,] -0.6264538 -0.8204684 1.5117812 -0.04493361 457s [2,] 0.1836433 0.4874291 0.3898432 -0.01619026 457s [3,] -0.8356286 0.7383247 -0.6212406 0.94383621 457s [4,] 1.5952808 0.5757814 -2.2146999 0.82122120 457s [5,] 0.3295078 -0.3053884 1.1249309 0.59390132 457s > 457s > # To check names attribute 457s > dimnames <- list(letters[1:5], LETTERS[1:4]) 457s > 457s > # Weighted row variances (uniform weights - all w = 1) 457s > # Non-weighted row variances 457s > x_est0 <- rowVars(x) 457s > w <- rep(1, times = ncol(x)) 457s > x_est1 <- rowWeightedVars(x, w = w) 457s > print(x_est1) 457s [1] 1.11767161 0.05022969 0.83582537 2.76819528 0.35351857 457s > stopifnot(all.equal(x_est1, x_est0)) 457s > x_est2 <- colWeightedVars(t(x), w = w) 457s > stopifnot(all.equal(x_est2, x_est0)) 457s > # Check names attribute 457s > dimnames(x) <- dimnames 457s > x_est1 <- rowWeightedVars(x, w = w, useNames = FALSE) 457s > x_est2 <- colWeightedVars(t(x), w = w, useNames = FALSE) 457s > stopifnot(all.equal(x_est1, x_est0)) 457s > stopifnot(all.equal(x_est2, x_est0)) 457s > x_est0 <- rowVars(x, useNames = TRUE) 457s > x_est1 <- rowWeightedVars(x, w = w, useNames = TRUE) 457s > x_est2 <- colWeightedVars(t(x), w = w, useNames = TRUE) 457s > stopifnot(all.equal(x_est1, x_est0)) 457s > stopifnot(all.equal(x_est2, x_est0)) 457s > dimnames(x) <- NULL 457s > 457s > 457s > # Weighted row variances (uniform weights - all w = 3) 457s > x3 <- cbind(x, x, x) 457s > x_est0 <- rowVars(x3) 457s > w <- rep(3, times = ncol(x)) 457s > x_est1 <- rowWeightedVars(x, w = w) 457s > print(x_est1) 457s [1] 0.91445859 0.04109702 0.68385712 2.26488705 0.28924246 457s > stopifnot(all.equal(x_est1, x_est0)) 457s > x_est2 <- colWeightedVars(t(x), w = w) 457s > stopifnot(all.equal(x_est2, x_est0)) 457s > # Check names attribute 457s > dimnames(x) <- dimnames 457s > x_est1 <- rowWeightedVars(x, w = w, useNames = FALSE) 457s > x_est2 <- colWeightedVars(t(x), w = w, useNames = FALSE) 457s > stopifnot(all.equal(x_est1, x_est0)) 457s > stopifnot(all.equal(x_est2, x_est0)) 457s > x3 <- cbind(x, x, x) 457s > x_est0 <- rowVars(x3, useNames = TRUE) 457s > x_est1 <- rowWeightedVars(x, w = w, useNames = TRUE) 457s > x_est2 <- colWeightedVars(t(x), w = w, useNames = TRUE) 457s > stopifnot(all.equal(x_est1, x_est0)) 457s > stopifnot(all.equal(x_est2, x_est0)) 457s > dimnames(x) <- NULL 457s > 457s > 457s > # Weighted row variances (excluding some columns) 457s > w <- c(1, 1, 0, 1) 457s > x_est0 <- rowVars(x[, (w == 1), drop = FALSE]) 457s > x_est1 <- rowWeightedVars(x, w = w) 457s > print(x_est1) 457s [1] 0.16287693 0.06430861 0.94767651 0.28313135 0.21361984 457s > stopifnot(all.equal(x_est1, x_est0)) 457s > x_est2 <- colWeightedVars(t(x), w = w) 457s > stopifnot(all.equal(x_est2, x_est0)) 457s > # Check names attribute 457s > dimnames(x) <- dimnames 457s > x_est1 <- rowWeightedVars(x, w = w, useNames = FALSE) 457s > x_est2 <- colWeightedVars(t(x), w = w, useNames = FALSE) 457s > stopifnot(all.equal(x_est1, x_est0)) 457s > stopifnot(all.equal(x_est2, x_est0)) 457s > x_est0 <- rowVars(x[, (w == 1), drop = FALSE], useNames = TRUE) 457s > x_est1 <- rowWeightedVars(x, w = w, useNames = TRUE) 457s > x_est2 <- colWeightedVars(t(x), w = w, useNames = TRUE) 457s > stopifnot(all.equal(x_est1, x_est0)) 457s > stopifnot(all.equal(x_est2, x_est0)) 457s > dimnames(x) <- NULL 457s > 457s > 457s > # Weighted row variances (excluding some columns) 457s > w <- c(0, 1, 0, 0) 457s > x_est0 <- rowVars(x[, (w == 1), drop = FALSE]) 457s > x_est1 <- rowWeightedVars(x, w = w) 457s > #stopifnot(all.equal(x_est1, x_est0)) 457s > x_est2 <- colWeightedVars(t(x), w = w) 457s > stopifnot(all.equal(x_est2, x_est1)) 457s > # Check names attribute 457s > dimnames(x) <- dimnames 457s > x_est1 <- rowWeightedVars(x, w = w, useNames = FALSE) 457s > x_est2 <- colWeightedVars(t(x), w = w, useNames = FALSE) 457s > stopifnot(all.equal(x_est1, x_est0)) 457s > stopifnot(all.equal(x_est2, x_est0)) 457s > x_est0 <- rowVars(x[, (w == 1), drop = FALSE], useNames = TRUE) 457s > x_est1 <- rowWeightedVars(x, w = w, useNames = TRUE) 457s > x_est2 <- colWeightedVars(t(x), w = w, useNames = TRUE) 457s > stopifnot(all.equal(x_est1, x_est0)) 457s > stopifnot(all.equal(x_est2, x_est0)) 457s > dimnames(x) <- NULL 457s > 457s > 457s > # Weighted row variances (all zero weights) 457s > w <- c(0, 0, 0, 0) 457s > x_est0 <- rowVars(x[, (w == 1), drop = FALSE]) 457s > x_est1 <- rowWeightedVars(x, w = w) 457s > stopifnot(all.equal(x_est1, x_est0)) 457s > x_est2 <- colWeightedVars(t(x), w = w) 457s > stopifnot(all.equal(x_est2, x_est0)) 457s > # Check names attribute 457s > dimnames(x) <- dimnames 457s > x_est1 <- rowWeightedVars(x, w = w, useNames = FALSE) 457s > x_est2 <- colWeightedVars(t(x), w = w, useNames = FALSE) 457s > stopifnot(all.equal(x_est1, x_est0)) 457s > stopifnot(all.equal(x_est2, x_est0)) 457s > x_est0 <- rowVars(x[, (w == 1), drop = FALSE], useNames = TRUE) 457s > x_est1 <- rowWeightedVars(x, w = w, useNames = TRUE) 457s > x_est2 <- colWeightedVars(t(x), w = w, useNames = TRUE) 457s > stopifnot(all.equal(x_est1, x_est0)) 457s > stopifnot(all.equal(x_est2, x_est0)) 457s > dimnames(x) <- NULL 457s > 457s > # Weighted variances by rows and columns 457s > w <- 1:4 457s > # Test with and without dimnames on x 457s > for (setDimnames in c(TRUE, FALSE)) { 457s + if (setDimnames) dimnames(x) <- dimnames 457s + else dimnames(x) <- NULL 457s + # Check names attribute 457s + for (useNames in c(TRUE, FALSE)) { 457s + x_est1 <- rowWeightedVars(x, w = w, useNames = useNames) 457s + print(x_est1) 457s + x_est2 <- colWeightedVars(t(x), w = w, useNames = useNames) 457s + stopifnot(all.equal(x_est2, x_est1)) 457s + } 457s + } 457s a b c d e 457s 0.90747094 0.05040463 0.65089440 2.28697479 0.27902734 457s [1] 0.90747094 0.05040463 0.65089440 2.28697479 0.27902734 457s [1] 0.90747094 0.05040463 0.65089440 2.28697479 0.27902734 457s [1] 0.90747094 0.05040463 0.65089440 2.28697479 0.27902734 457s > 457s > 457s > x[sample(length(x), size = 0.3 * length(x))] <- NA 457s > print(x) 457s [,1] [,2] [,3] [,4] 457s [1,] -0.6264538 NA 1.5117812 -0.04493361 457s [2,] 0.1836433 NA NA -0.01619026 457s [3,] -0.8356286 0.7383247 -0.6212406 0.94383621 457s [4,] 1.5952808 NA -2.2146999 0.82122120 457s [5,] 0.3295078 NA NA 0.59390132 457s > 457s > # Non-weighted row variances with missing values 457s > x_est0 <- rowVars(x, na.rm = TRUE) 457s > x_est1 <- rowWeightedVars(x, w = rep(1, times = ncol(x)), na.rm = TRUE) 457s > print(x_est1) 457s [1] 1.22226258 0.01996673 0.83582537 4.05532299 0.03495197 457s > stopifnot(all.equal(x_est1, x_est0)) 457s > x_est2 <- colWeightedVars(t(x), w = rep(1, times = ncol(x)), na.rm = TRUE) 457s > stopifnot(all.equal(x_est2, x_est0)) 457s > # Check names attribute 457s > dimnames(x) <- dimnames 457s > x_est1 <- rowWeightedVars(x, w = rep(1, times = ncol(x)), na.rm = TRUE, useNames = FALSE) 457s > x_est2 <- colWeightedVars(t(x), w = rep(1, times = ncol(x)), na.rm = TRUE, useNames = FALSE) 457s > stopifnot(all.equal(x_est1, x_est0)) 457s > stopifnot(all.equal(x_est2, x_est0)) 457s > x_est0 <- rowVars(x, na.rm = TRUE, useNames = TRUE) 457s > x_est1 <- rowWeightedVars(x, w = rep(1, times = ncol(x)), na.rm = TRUE, useNames = TRUE) 457s > x_est2 <- colWeightedVars(t(x), w = rep(1, times = ncol(x)), na.rm = TRUE, useNames = TRUE) 457s > stopifnot(all.equal(x_est1, x_est0)) 457s > stopifnot(all.equal(x_est2, x_est0)) 457s > dimnames(x) <- NULL 457s > 457s > 457s > # Weighted row variances with missing values 457s > # Test with and without dimnames on x 457s > for (setDimnames in c(TRUE, FALSE)) { 457s + if (setDimnames) dimnames(x) <- dimnames 457s + else dimnames(x) <- NULL 457s + # Check names attribute 457s + for (useNames in c(TRUE, FALSE)) { 457s + x_est1 <- rowWeightedVars(x, w = w, na.rm = TRUE, useNames = useNames) 457s + print(x_est1) 457s + x_est2 <- colWeightedVars(t(x), w = w, na.rm = TRUE, useNames = useNames) 457s + stopifnot(all.equal(x_est2, x_est1)) 457s + } 457s + } 458s a b c d e 458s 0.788377504 0.007986693 0.650894398 2.795470241 0.013980790 458s [1] 0.788377504 0.007986693 0.650894398 2.795470241 0.013980790 458s [1] 0.788377504 0.007986693 0.650894398 2.795470241 0.013980790 458s [1] 0.788377504 0.007986693 0.650894398 2.795470241 0.013980790 458s > 458s > 458s > # Weighted variances by rows and columns 458s > w <- 1:4 458s > # Test with and without dimnames on x 458s > for (setDimnames in c(TRUE, FALSE)) { 458s + if (setDimnames) dimnames(x) <- dimnames 458s + else dimnames(x) <- NULL 458s + # Check names attribute 458s + for (useNames in c(TRUE, FALSE)) { 458s + x_est1 <- rowWeightedVars(x, w = w, na.rm = TRUE, useNames = useNames) 458s + print(x_est1) 458s + x_est2 <- colWeightedVars(t(x), w = w, na.rm = TRUE, useNames = useNames) 458s + stopifnot(all.equal(x_est2, x_est1)) 458s + } 458s + } 458s a b c d e 458s 0.788377504 0.007986693 0.650894398 2.795470241 0.013980790 458s [1] 0.788377504 0.007986693 0.650894398 2.795470241 0.013980790 458s [1] 0.788377504 0.007986693 0.650894398 2.795470241 0.013980790 458s [1] 0.788377504 0.007986693 0.650894398 2.795470241 0.013980790 458s > 458s > 458s > # Weighted row standard deviation (excluding some columns) 458s > w <- c(1, 1, 0, 1) 458s > ## FIXME: rowVars()/rowSds() needs na.rm = FALSE (wrong default) 458s > x_est0 <- rowSds(x[, (w == 1), drop = FALSE], na.rm = FALSE) 458s > x_est1 <- rowWeightedSds(x, w = w) 458s > print(x_est1) 458s [1] NA NA 0.9734868 NA NA 458s > stopifnot(all.equal(x_est1, x_est0)) 458s > x_est2 <- colWeightedSds(t(x), w = w, na.rm = FALSE) 458s > stopifnot(all.equal(x_est2, x_est0)) 458s > # Check names attribute 458s > dimnames(x) <- dimnames 458s > x_est1 <- rowWeightedSds(x, w = w, na.rm = FALSE, useNames = FALSE) 458s > x_est2 <- colWeightedSds(t(x), w = w, na.rm = FALSE, useNames = FALSE) 458s > stopifnot(all.equal(x_est1, x_est0)) 458s > stopifnot(all.equal(x_est2, x_est0)) 458s > x_est0 <- rowSds(x[, (w == 1), drop = FALSE], na.rm = FALSE, useNames = TRUE) 458s > x_est1 <- rowWeightedSds(x, w = w, na.rm = FALSE, useNames = TRUE) 458s > x_est2 <- colWeightedSds(t(x), w = w, na.rm = FALSE, useNames = TRUE) 458s > stopifnot(all.equal(x_est1, x_est0)) 458s > stopifnot(all.equal(x_est2, x_est0)) 458s > dimnames(x) <- NULL 458s > 458s > 458s > # Weighted row MADs (excluding some columns) 458s > w <- c(1, 1, 0, 1) 458s > x_est0 <- rowMads(x[, (w == 1), drop = FALSE]) 458s > x_est1 <- rowWeightedMads(x, w = w) 458s > print(x_est1) 458s [1] NA NA 0.3046914 NA NA 458s > stopifnot(all.equal(x_est1, x_est0)) 458s > x_est2 <- colWeightedMads(t(x), w = w) 458s > stopifnot(all.equal(x_est2, x_est0)) 458s > # Check names attribute 458s > dimnames(x) <- dimnames 458s > x_est1 <- rowWeightedMads(x, w = w, useNames = FALSE) 458s > x_est2 <- colWeightedMads(t(x), w = w, useNames = FALSE) 458s > stopifnot(all.equal(x_est1, x_est0)) 458s > stopifnot(all.equal(x_est2, x_est0)) 458s > x_est0 <- rowMads(x[, (w == 1), drop = FALSE], useNames = TRUE) 458s > x_est1 <- rowWeightedMads(x, w = w, useNames = TRUE) 458s > x_est2 <- colWeightedMads(t(x), w = w, useNames = TRUE) 458s > stopifnot(all.equal(x_est1, x_est0)) 458s > stopifnot(all.equal(x_est2, x_est0)) 458s > dimnames(x) <- NULL 458s > 458s 458s R version 4.4.3 (2025-02-28) -- "Trophy Case" 458s Copyright (C) 2025 The R Foundation for Statistical Computing 458s Platform: arm-unknown-linux-gnueabihf (32-bit) 458s 458s R is free software and comes with ABSOLUTELY NO WARRANTY. 458s You are welcome to redistribute it under certain conditions. 458s Type 'license()' or 'licence()' for distribution details. 458s 458s R is a collaborative project with many contributors. 458s Type 'contributors()' for more information and 458s 'citation()' on how to cite R or R packages in publications. 458s 458s Type 'demo()' for some demos, 'help()' for on-line help, or 458s 'help.start()' for an HTML browser interface to help. 458s Type 'q()' to quit R. 458s 458s > library("matrixStats") 458s > 458s > fcns <- list( 458s + weightedVar = c(rowWeightedVars, colWeightedVars), 458s + weightedSd = c(rowWeightedSds, colWeightedSds), 458s + weightedMad = c(rowWeightedMads, colWeightedMads) 458s + ) 458s > 458s > 458s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 458s > # Subsetted tests 458s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 458s > source("utils/validateIndicesFramework.R") 458s > # To check names attribute 458s > dimnames <- list(letters[1:6], LETTERS[1:6]) 458s > for (fcn in names(fcns)) { 458s + cat(sprintf("subsetted tests on matrix %s()...\n", fcn)) 458s + row_fcn <- fcns[[fcn]][[1]] 458s + col_fcn <- fcns[[fcn]][[2]] 458s + 458s + for (mode in c("numeric", "integer")) { 458s + x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 458s + w <- runif(6, min = 0, max = 6) 458s + storage.mode(x) <- mode 458s + storage.mode(w) <- mode 458s + if (mode == "numeric") w[1] <- Inf 458s + 458s + # Test with and without dimnames on x 458s + for (setDimnames in c(TRUE, FALSE)) { 458s + if (setDimnames) dimnames(x) <- dimnames 458s + else dimnames(x) <- NULL 458s + 458s + count <- 0L 458s + for (rows in index_cases) { 458s + for (cols in index_cases) { 458s + count <- count + 1L 458s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 458s + useNames <- c(TRUE, FALSE) 458s + useNames <- useNames[count %% length(useNames) + 1] 458s + 458s + validateIndicesTestMatrix_w(x, w, rows, cols, 458s + ftest = row_fcn, fsure = row_fcn, 458s + na.rm = na.rm, useNames = useNames) 458s + validateIndicesTestMatrix_w(x, w, rows, cols, 458s + fcoltest = col_fcn, fsure = row_fcn, 458s + na.rm = na.rm, useNames = useNames) 458s + } 458s + } 458s + } 458s + } 458s + cat(sprintf("%s()...DONE\n", fcn)) 458s + } 458s subsetted tests on matrix weightedVar()... 459s weightedVar()...DONE 459s subsetted tests on matrix weightedSd()... 461s weightedSd()...DONE 461s subsetted tests on matrix weightedMad()... 462s weightedMad()...DONE 462s > 462s 462s R version 4.4.3 (2025-02-28) -- "Trophy Case" 462s Copyright (C) 2025 The R Foundation for Statistical Computing 462s Platform: arm-unknown-linux-gnueabihf (32-bit) 462s 462s R is free software and comes with ABSOLUTELY NO WARRANTY. 462s You are welcome to redistribute it under certain conditions. 462s Type 'license()' or 'licence()' for distribution details. 462s 462s R is a collaborative project with many contributors. 462s Type 'contributors()' for more information and 462s 'citation()' on how to cite R or R packages in publications. 462s 462s Type 'demo()' for some demos, 'help()' for on-line help, or 462s 'help.start()' for an HTML browser interface to help. 462s Type 'q()' to quit R. 462s 462s > library("matrixStats") 462s > 462s > signTabulate0 <- function(x, ...) { 462s + nneg <- sum(x < 0, na.rm = TRUE) 462s + nzero <- sum(x == 0, na.rm = TRUE) 462s + npos <- sum(x > 0, na.rm = TRUE) 462s + nna <- sum(is.na(x)) 462s + nneginf <- sum(is.infinite(x) & x < 0, na.rm = TRUE) 462s + nposinf <- sum(is.infinite(x) & x > 0, na.rm = TRUE) 462s + res <- c(nneg, nzero, npos, nna, nneginf, nposinf) 462s + res <- as.double(res) 462s + names(res) <- c("-1", "0", "+1", "NA", "-Inf", "+Inf") 462s + if (is.integer(x)) res <- res[1:4] 462s + res 462s + } # signTabulate0() 462s > 462s > 462s > # Simulate data 462s > set.seed(0xBEEF) 462s Doubles: 462s > n <- 100L 462s > x <- runif(n) 462s > x[sample(n, size = 0.1 * n)] <- 0 462s > x[sample(n, size = 0.1 * n)] <- NA_real_ 462s > x[sample(n, size = 0.1 * n)] <- -Inf 462s > x[sample(n, size = 0.1 * n)] <- +Inf 462s > 462s > # Doubles 462s > message("Doubles:") 462s > counts0 <- signTabulate0(x) 462s Integers: 462s > print(counts0) 462s -1 0 +1 NA -Inf +Inf 462s 9 7 77 7 9 10 462s > counts1 <- signTabulate(x) 462s > print(counts1) 462s -1 0 +1 NA -Inf +Inf 462s 9 7 77 7 9 10 462s > stopifnot(identical(counts1, counts0)) 462s > 462s > # Integers 462s > message("Integers:") 462s > x <- suppressWarnings(as.integer(x)) 462s > counts0 <- signTabulate0(x) 462s > print(counts0) 462s -1 0 +1 NA 462s 0 74 0 26 462s > counts1 <- signTabulate(x) 462s > print(counts1) 462s -1 0 +1 NA 462s 0 74 0 26 462s > stopifnot(identical(counts1, counts0)) 462s > 462s 462s R version 4.4.3 (2025-02-28) -- "Trophy Case" 462s Copyright (C) 2025 The R Foundation for Statistical Computing 462s Platform: arm-unknown-linux-gnueabihf (32-bit) 462s 462s R is free software and comes with ABSOLUTELY NO WARRANTY. 462s You are welcome to redistribute it under certain conditions. 462s Type 'license()' or 'licence()' for distribution details. 462s 462s R is a collaborative project with many contributors. 462s Type 'contributors()' for more information and 462s 'citation()' on how to cite R or R packages in publications. 462s 462s Type 'demo()' for some demos, 'help()' for on-line help, or 462s 'help.start()' for an HTML browser interface to help. 462s Type 'q()' to quit R. 462s 462s > library("matrixStats") 462s > 462s > signTabulate0 <- function(x, ...) { 462s + nneg <- sum(x < 0, na.rm = TRUE) 462s + nzero <- sum(x == 0, na.rm = TRUE) 462s + npos <- sum(x > 0, na.rm = TRUE) 462s + nna <- sum(is.na(x)) 462s + nneginf <- sum(is.infinite(x) & x < 0, na.rm = TRUE) 462s + nposinf <- sum(is.infinite(x) & x > 0, na.rm = TRUE) 462s + res <- c(nneg, nzero, npos, nna, nneginf, nposinf) 462s + res <- as.double(res) 462s + names(res) <- c("-1", "0", "+1", "NA", "-Inf", "+Inf") 462s + if (is.integer(x)) res <- res[1:4] 462s + res 462s + } # signTabulate0() 462s > 462s > 462s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 462s > # Subsetted tests 462s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 462s > source("utils/validateIndicesFramework.R") 462s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 462s > x[2:3, 4:5] <- +Inf 462s > x[4:5, 1:2] <- -Inf 462s > for (idxs in index_cases) { 462s + validateIndicesTestVector(x, idxs, 462s + ftest = signTabulate, fsure = signTabulate0) 462s + } 462s > 463s 463s R version 4.4.3 (2025-02-28) -- "Trophy Case" 463s Copyright (C) 2025 The R Foundation for Statistical Computing 463s Platform: arm-unknown-linux-gnueabihf (32-bit) 463s 463s R is free software and comes with ABSOLUTELY NO WARRANTY. 463s You are welcome to redistribute it under certain conditions. 463s Type 'license()' or 'licence()' for distribution details. 463s 463s R is a collaborative project with many contributors. 463s Type 'contributors()' for more information and 463s 'citation()' on how to cite R or R packages in publications. 463s 463s Type 'demo()' for some demos, 'help()' for on-line help, or 463s 'help.start()' for an HTML browser interface to help. 463s Type 'q()' to quit R. 463s 463s > library("matrixStats") 463s > options(warn = 1) 463s > 463s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 463s > # Consistency checks 463s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 463s > set.seed(1) 463s > 463s > sum2_R <- function(x, na.rm = FALSE, idxs = NULL) { 463s + if (is.null(idxs)) { 463s + sum(x, na.rm = na.rm) 463s + } else { 463s + sum(x[idxs], na.rm = na.rm) 463s + } 463s + } # sum2_R() 463s > 463s > 463s > cat("Consistency checks:\n") 463s Consistency checks: 463s > for (kk in 1:20) { 463s + cat("Random test #", kk, "\n", sep = "") 463s + 463s + # Simulate data in a matrix of any shape 463s + n <- sample(1e3, size = 1L) 463s + x <- rnorm(n, sd = 100) 463s + 463s + # Add NAs? 463s + if ((kk %% 4) %in% c(3, 0)) { 463s + cat("Adding NAs\n") 463s + nna <- sample(n, size = 1L) 463s + na_values <- c(NA_real_, NaN) 463s + t <- sample(na_values, size = nna, replace = TRUE) 463s + x[sample(length(x), size = nna)] <- t 463s + } 463s + 463s + # Integer or double? 463s + if ((kk %% 4) %in% c(2, 0)) { 463s + cat("Coercing to integers\n") 463s + storage.mode(x) <- "integer" 463s + } 463s + 463s + na.rm <- sample(c(TRUE, FALSE), size = 1L) 463s + 463s + # Sum over all 463s + y0 <- sum2_R(x, na.rm = na.rm) 463s + y1 <- sum2(x, na.rm = na.rm) 463s + stopifnot(all.equal(y1, y0)) 463s + 463s + # Sum over subset 463s + nidxs <- sample(n, size = 1L) 463s + idxs <- sample(n, size = nidxs) 463s + y0 <- sum2_R(x, na.rm = na.rm, idxs = idxs) 463s + y1 <- sum2(x, na.rm = na.rm, idxs = idxs) 463s + stopifnot(all.equal(y1, y0)) 463s + 463s + if (storage.mode(x) == "integer") { 463s + storage.mode(x) <- "logical" 463s + 463s + y0 <- sum2_R(x, na.rm = na.rm) 463s + y1 <- sum2(x, na.rm = na.rm) 463s + stopifnot(all.equal(y1, y0)) 463s + 463s + y0 <- sum2_R(x, na.rm = na.rm, idxs = idxs) 463s + y1 <- sum2(x, na.rm = na.rm, idxs = idxs) 463s + stopifnot(all.equal(y1, y0)) 463s + } 463s + } # for (kk ...) 463s Random test #1 463s Random test #2 463s Coercing to integers 463s Random test #3 463s Adding NAs 463s Random test #4 463s Adding NAs 463s Coercing to integers 463s Random test #5 463s Random test #6 463s Coercing to integers 463s Random test #7 463s Adding NAs 463s Random test #8 463s Adding NAs 463s Coercing to integers 463s Random test #9 463s Random test #10 463s Coercing to integers 463s Random test #11 463s Adding NAs 463s Random test #12 463s Adding NAs 463s Coercing to integers 463s Random test #13 463s Random test #14 463s Coercing to integers 463s Random test #15 463s Adding NAs 463s Random test #16 463s Adding NAs 463s Coercing to integers 463s Random test #17 463s Random test #18 463s Coercing to integers 463s Random test #19 463s Adding NAs 463s Random test #20 463s Adding NAs 463s Coercing to integers 463s > 463s > 463s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 463s > # All missing values 463s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 463s > for (n in 0:2) { 463s + for (na.rm in c(FALSE, TRUE)) { 463s + x <- rep(NA_real_, times = n) 463s + y0 <- sum(x, na.rm = na.rm) 463s + y <- sum2(x, na.rm = na.rm) 463s + stopifnot(all.equal(y, y0)) 463s + 463s + x <- rep(NA_integer_, times = n) 463s + y0 <- sum(x, na.rm = na.rm) 463s + y <- sum2(x, na.rm = na.rm) 463s + stopifnot(all.equal(y, y0)) 463s + 463s + x <- rep(NA, times = n) 463s + y0 <- sum(x, na.rm = na.rm) 463s + y <- sum2(x, na.rm = na.rm) 463s + stopifnot(all.equal(y, y0)) 463s + } 463s + } 463s > 463s > 463s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 463s > # Special cases 463s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 463s > for (na.rm in c(FALSE, TRUE)) { 463s + # Summing over zero elements (integers) 463s + x <- integer(0) 463s + s1 <- sum(x, na.rm = na.rm) 463s + s2 <- sum2(x, na.rm = na.rm) 463s + stopifnot(identical(s1, s2)) 463s + 463s + x <- 1:10 463s + idxs <- integer(0) 463s + s1 <- sum(x[idxs], na.rm = na.rm) 463s + s2 <- sum2(x, idxs = idxs, na.rm = na.rm) 463s + stopifnot(identical(s1, s2)) 463s + 463s + # Summing over NA_integer_:s 463s + x <- rep(NA_integer_, times = 10L) 463s + s1 <- sum(x, na.rm = na.rm) 463s + s2 <- sum2(x, na.rm = na.rm) 463s + stopifnot(identical(s1, s2)) 463s + 463s + x <- rep(NA_integer_, times = 10L) 463s + idxs <- 1:5 463s + s1 <- sum(x[idxs], na.rm = na.rm) 463s + s2 <- sum2(x, idxs = idxs, na.rm = na.rm) 463s + stopifnot(identical(s1, s2)) 463s + 463s + 463s + # Summing over zero elements (doubles) 463s + x <- double(0) 463s + s1 <- sum(x) 463s + s2 <- sum2(x) 463s + stopifnot( 463s + identical(s1, 0), 463s + identical(s1, s2) 463s + ) 463s + 463s + x <- as.double(1:10) 463s + idxs <- integer(0) 463s + s1 <- sum(x[idxs]) 463s + s2 <- sum2(x, idxs = idxs) 463s + stopifnot( 463s + identical(s1, 0), 463s + identical(s1, s2) 463s + ) 463s + 463s + # Summing over NA_real_:s 463s + x <- rep(NA_real_, times = 10L) 463s + s1 <- sum(x, na.rm = na.rm) 463s + s2 <- sum2(x, na.rm = na.rm) 463s + stopifnot( 463s + !na.rm || s1 == 0, 463s + identical(s1, s2) 463s + ) 463s + 463s + x <- rep(NA_real_, times = 10L) 463s + idxs <- 1:5 463s + s1 <- sum(x[idxs], na.rm = na.rm) 463s + s2 <- sum2(x, idxs = idxs, na.rm = na.rm) 463s + stopifnot( 463s + !na.rm || s1 == 0, 463s + identical(s1, s2) 463s + ) 463s + 463s + # Summing over -Inf:s 463s + x <- rep(-Inf, times = 3L) 463s + s1 <- sum(x, na.rm = na.rm) 463s + s2 <- sum2(x, na.rm = na.rm) 463s + stopifnot( 463s + is.infinite(s1) && s1 < 0, 463s + identical(s1, s2) 463s + ) 463s + 463s + # Summing over +Inf:s 463s + x <- rep(+Inf, times = 3L) 463s + s1 <- sum(x, na.rm = na.rm) 463s + s2 <- sum2(x, na.rm = na.rm) 463s + stopifnot(identical(s1, s2)) 463s + stopifnot( 463s + is.infinite(s1) && s1 > 0, 463s + identical(s1, s2) 463s + ) 463s + 463s + # Summing over mix of -Inf:s and +Inf:s 463s + x <- rep(c(-Inf, +Inf), times = 3L) 463s + s1 <- sum(x, na.rm = na.rm) 463s + s2 <- sum2(x, na.rm = na.rm) 463s + stopifnot( 463s + is.nan(s1), 463s + identical(s1, s2) 463s + ) 463s + 463s + # Summing over mix of -Inf:s and +Inf:s and numerics 463s + x <- rep(c(-Inf, +Inf, 3.14), times = 2L) 463s + s1 <- sum(x, na.rm = na.rm) 463s + s2 <- sum2(x, na.rm = na.rm) 463s + stopifnot( 463s + is.nan(s1), 463s + identical(s1, s2) 463s + ) 463s + 463s + # Summing over mix of NaN, NA, +Inf, and numerics 463s + x <- c(NaN, NA, +Inf, 3.14) 463s + s1 <- sum(x, na.rm = na.rm) 463s + s2 <- sum2(x, na.rm = na.rm) 463s + if (na.rm) { 463s + stopifnot( 463s + is.infinite(s1) && s1 > 0, 463s + identical(s2, s1) 463s + ) 463s + } else { 463s + stopifnot(is.na(s1), is.na(s2)) 463s + ## NOTE, due to compiler optimization, it is not guaranteed that NA is 463s + ## returned here (as one would expect). NaN might very well be returned, 463s + ## when both NA and NaN are involved. This is an accepted feature in R, 463s + ## which is documented in help("is.nan"). See also 463s + ## https://stat.ethz.ch/pipermail/r-devel/2017-April/074009.html. 463s + ## Thus, we cannot guarantee that s1 is identical to s0. 463s + } 463s + 463s + # Summing over mix of NaN, NA, +Inf, and numerics 463s + x <- c(NA, NaN, +Inf, 3.14) 463s + s1 <- sum(x, na.rm = na.rm) 463s + s2 <- sum2(x, na.rm = na.rm) 463s + if (na.rm) { 463s + stopifnot( 463s + is.infinite(s1) && s1 > 0, 463s + identical(s2, s1) 463s + ) 463s + } else { 463s + stopifnot(is.na(s1), is.na(s2)) 463s + ## NOTE, due to compiler optimization, it is not guaranteed that NA is 463s + ## returned here (as one would expect). NaN might very well be returned, 463s + ## when both NA and NaN are involved. This is an accepted feature in R, 463s + ## which is documented in help("is.nan"). See also 463s + ## https://stat.ethz.ch/pipermail/r-devel/2017-April/074009.html. 463s + ## Thus, we cannot guarantee that s1 is identical to s0. 463s + } 463s + } 463s Warning in sum2(x[1:2]) : 463s Integer overflow. Use sum2(..., mode = "double") to avoid this. 463s > 463s > 463s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 463s > # Summing of large integers 463s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 463s > x <- c(.Machine$integer.max, 1L, -.Machine$integer.max) 463s > 463s > # Total gives integer overflow 463s > s1 <- sum(x[1:2]) # NA_integer_ w/ warning 463s > s2 <- sum2(x[1:2]) # NA_integer_ w/ warning 463s > stopifnot( 463s + identical(s2, NA_integer_) 463s + ) 463s > 463s > ## Assert above warning 463s > res <- tryCatch({ 463s + s2 <- sum2(x[1:2]) 463s + }, warning = identity) 463s > stopifnot(inherits(res, "warning")) 463s > 463s > 463s > # Total gives integer overflow (coerce to numeric) 463s > s1 <- sum(as.numeric(x[1:2])) # 2147483648 463s > s2 <- sum2(as.numeric(x[1:2])) # 2147483648 463s > s3 <- sum2(x[1:2], mode = "double") # 2147483648 463s > stopifnot( 463s + identical(s1, 2147483648), 463s + identical(s1, s2), 463s + identical(s1, s3) 463s + ) 463s > 463s > # Cumulative sum would give integer overflow but not the total 463s > s1 <- sum(x) # 1L 463s > s2 <- sum2(x) # 1L 463s > stopifnot( 463s + identical(s1, 1L), 463s + identical(s1, s2) 463s + ) 463s > 463s > # Input is double but coercing result to integer 463s > x <- c(1, 2, 3.1) 463s > s1 <- sum2(x) 463s > s2 <- sum2(x, mode = "integer") 463s > stopifnot( 463s + identical(as.integer(s1), s2) 463s + ) 463s > 463s > ## Assert above warning 463s > res <- tryCatch({ 463s + s2 <- sum2(x, mode = "integer") 463s + }, warning = identity) 463s > stopifnot(inherits(res, "warning")) 463s > 463s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 463s > # Summing of large doubles 463s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 463s > ## Double overflow 463s > x <- rep(.Machine$double.xmax, times = 2L) 463s > y0 <- sum(x) 463s > print(y0) 463s [1] Inf 463s > y <- sum2(x) 463s > print(y) 463s [1] Inf 463s > stopifnot( 463s + is.infinite(y) && y > 0, 463s + identical(y, y0) 463s + ) 463s > 463s > x <- rep(-.Machine$double.xmax, times = 2L) 463s > y0 <- sum(x) 463s > print(y0) 463s [1] -Inf 463s > y <- sum2(x) 463s > print(y) 463s [1] -Inf 463s > stopifnot( 463s + is.infinite(y) && y < 0, 463s + identical(y, y0) 463s + ) 463s > 463s > 463s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 463s > # Argument 'idxs' 463s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 463s > x <- 1:10 463s > idxs_list <- list( 463s + integer = 1:5, 463s + double = as.double(1:5), 463s + logical = (x <= 5) 463s + ) 463s > 463s > for (idxs in idxs_list) { 463s + cat("idxs:\n") 463s + str(idxs) 463s + s1 <- sum(x[idxs], na.rm = TRUE) 463s + s2 <- sum2(x, idxs = idxs, na.rm = TRUE) 463s + stopifnot(identical(s1, s2)) 463s + } 463s Warning in sum2(x, mode = "integer") : 463s sum2(x, mode = "integer") called with typeof(x) == "double"; did you mean to use as.integer(sum2(x))? 463s idxs: 463s int [1:5] 1 2 3 4 5 463s idxs: 463s num [1:5] 1 2 3 4 5 463s idxs: 463s logi [1:10] TRUE TRUE TRUE TRUE TRUE FALSE ... 463s > 463s 463s R version 4.4.3 (2025-02-28) -- "Trophy Case" 463s Copyright (C) 2025 The R Foundation for Statistical Computing 463s Platform: arm-unknown-linux-gnueabihf (32-bit) 463s 463s R is free software and comes with ABSOLUTELY NO WARRANTY. 463s You are welcome to redistribute it under certain conditions. 463s Type 'license()' or 'licence()' for distribution details. 463s 463s R is a collaborative project with many contributors. 463s Type 'contributors()' for more information and 463s 'citation()' on how to cite R or R packages in publications. 463s 463s Type 'demo()' for some demos, 'help()' for on-line help, or 463s 'help.start()' for an HTML browser interface to help. 463s Type 'q()' to quit R. 463s 463s > library("matrixStats") 463s > 463s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 463s > # Subsetted tests 463s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 463s > source("utils/validateIndicesFramework.R") 463s > x <- runif(6, min = -6, max = 6) 463s > storage.mode(x) <- "integer" 463s > for (idxs in index_cases) { 463s + validateIndicesTestVector(x, idxs, 463s + ftest = sum2, fsure = sum, 463s + na.rm = FALSE) 463s + validateIndicesTestVector(x, idxs, 463s + ftest = sum2, fsure = sum, 463s + na.rm = TRUE) 463s + } 463s > 463s 463s R version 4.4.3 (2025-02-28) -- "Trophy Case" 463s Copyright (C) 2025 The R Foundation for Statistical Computing 463s Platform: arm-unknown-linux-gnueabihf (32-bit) 463s 463s R is free software and comes with ABSOLUTELY NO WARRANTY. 463s You are welcome to redistribute it under certain conditions. 463s Type 'license()' or 'licence()' for distribution details. 463s 463s R is a collaborative project with many contributors. 463s Type 'contributors()' for more information and 463s 'citation()' on how to cite R or R packages in publications. 463s 463s Type 'demo()' for some demos, 'help()' for on-line help, or 463s 'help.start()' for an HTML browser interface to help. 463s Type 'q()' to quit R. 463s 464s > library("matrixStats") 464s > 464s > set.seed(1) 464s > x <- rnorm(1e4) 464s > 464s > 464s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 464s > # Variance estimators 464s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 464s > sigma2_a <- var(x) 464s > cat(sprintf("var(x) = %g\n", sigma2_a)) 464s var(x) = 1.02487 464s > 464s > sigma2_b <- varDiff(x) 464s > cat(sprintf("varDiff(x) = %g\n", sigma2_b)) 464s varDiff(x) = 1.01224 464s > 464s > d <- abs(sigma2_b - sigma2_a) 464s > cat(sprintf("Absolute difference = %g\n", d)) 464s Absolute difference = 0.0126268 464s > stopifnot(d < 0.02) 464s > 464s > 464s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 464s > # Standard deviation estimators 464s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 464s > sigma_a <- sd(x) 464s > cat(sprintf("sd(x) = %g\n", sigma_a)) 464s sd(x) = 1.01236 464s > 464s > sigma_b <- sdDiff(x) 464s > cat(sprintf("sdDiff(x) = %g\n", sigma_b)) 464s sdDiff(x) = 1.0061 464s > 464s > d <- abs(sigma_b - sigma_a) 464s > cat(sprintf("Absolute difference = %g\n", d)) 464s Absolute difference = 0.00625567 464s > stopifnot(d < 0.01) 464s > 464s > # Sanity checks 464s > stopifnot(abs(sigma2_a - sigma_a ^ 2) < 1e-9) 464s > stopifnot(abs(sigma2_b - sigma_b ^ 2) < 1e-9) 464s > 464s > 464s > sigma_a2 <- mad(x) 464s > cat(sprintf("mad(x) = %g\n", sigma_a2)) 464s mad(x) = 0.998376 464s > 464s > sigma_b2 <- madDiff(x) 464s > cat(sprintf("madDiff(x) = %g\n", sigma_b2)) 464s madDiff(x) = 1.02513 464s > 464s > d <- abs(sigma_b2 - sigma_a2) 464s > cat(sprintf("Absolute difference = %g\n", d)) 464s Absolute difference = 0.0267497 464s > stopifnot(d < 0.05) 464s > 464s > 464s > sigma_a3 <- IQR(x) 464s > cat(sprintf("IQR(x) = %g\n", sigma_a3)) 464s IQR(x) = 1.35105 464s > 464s > sigma_b3 <- iqrDiff(x) 464s > cat(sprintf("iqrDiff(x) = %g\n", sigma_b3)) 464s iqrDiff(x) = 1.37797 464s > 464s > d <- abs(sigma_b3 - sigma_a3) 464s > cat(sprintf("Absolute difference = %g\n", d)) 464s Absolute difference = 0.0269152 464s > stopifnot(d < 0.05) 464s > 464s > 464s > 464s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 464s > # Trimmed estimators 464s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 464s > y <- x 464s > outliers <- sample(length(x), size = 0.1 * length(x)) 464s > y[outliers] <- 100 * y[outliers] 464s > 464s > sigma_ao <- sd(y[-outliers]) 464s > cat(sprintf("sd(y) = %g\n", sigma_ao)) 464s sd(y) = 1.01166 464s > 464s > sigma_bo <- sdDiff(y[-outliers]) 464s > cat(sprintf("sdDiff(y) = %g\n", sigma_bo)) 464s sdDiff(y) = 1.00743 464s > 464s > d <- abs(sigma_b - sigma_a) 464s > cat(sprintf("Absolute difference = %g\n", d)) 464s Absolute difference = 0.00625567 464s > stopifnot(d < 0.01) 464s > 464s > sigma_bot <- sdDiff(y, trim = 0.05) 464s > cat(sprintf("sdDiff(y, trim = 0.05) = %g\n", sigma_bot)) 464s sdDiff(y, trim = 0.05) = 7.74327 464s > 464s > d <- abs(sigma_bot - sigma_a) 464s > cat(sprintf("Absolute difference = %g\n", d)) 464s Absolute difference = 6.73091 464s > #stopifnot(d < 1e-3) 464s > 464s > sigma_cot <- madDiff(y, trim = 0.05) 464s > cat(sprintf("madDiff(y, trim = 0.05) = %g\n", sigma_cot)) 464s madDiff(y, trim = 0.05) = 1.15278 464s > 464s > sigma_dot <- iqrDiff(y, trim = 0.05) 464s > cat(sprintf("iqrDiff(y, trim = 0.05) = %g\n", sigma_dot)) 464s iqrDiff(y, trim = 0.05) = 1.55762 464s > 464s > 464s > fcns <- list( 464s + varDiff = varDiff, 464s + sdDiff = sdDiff, 464s + madDiff = madDiff, 464s + iqrDiff = iqrDiff 464s + ) 464s > 464s > for (name in names(fcns)) { 464s + cat(sprintf("%s()...\n", name)) 464s + fcn <- fcns[[name]] 464s + 464s + for (mode in c("integer", "double")) { 464s + cat("mode: ", mode, "", sep = "") 464s + for (n in 0:3) { 464s + x <- runif(n, min = -5, max = 5) 464s + storage.mode(x) <- mode 464s + str(x) 464s + 464s + y <- fcn(x) 464s + yt <- fcn(x, trim = 0.1) 464s + str(list("non-trimmed" = y, trimmed = yt)) 464s + } # for (mode ...) 464s + } 464s + 464s + cat(sprintf("%s()...DONE\n", name)) 464s + } # for (name ...) 464s varDiff()... 464s mode: integer int(0) 464s List of 2 464s $ non-trimmed: num NA 464s $ trimmed : num NA 464s int -4 464s List of 2 464s $ non-trimmed: num NA 464s $ trimmed : num NA 464s int [1:2] 3 2 464s List of 2 464s $ non-trimmed: num NA 464s $ trimmed : num NA 464s int [1:3] 1 4 -1 464s List of 2 464s $ non-trimmed: num 16 464s $ trimmed : num 16 464s mode: double num(0) 464s List of 2 464s $ non-trimmed: num NA 464s $ trimmed : num NA 464s num -0.794 464s List of 2 464s $ non-trimmed: num NA 464s $ trimmed : num NA 464s num [1:2] 0.897 -3.728 464s List of 2 464s $ non-trimmed: num NA 464s $ trimmed : num NA 464s num [1:3] 2.07 -1.13 1.94 464s List of 2 464s $ non-trimmed: num 9.83 464s $ trimmed : num 9.83 464s varDiff()...DONE 464s sdDiff()... 464s mode: integer int(0) 464s List of 2 464s $ non-trimmed: num NA 464s $ trimmed : num NA 464s int 2 464s List of 2 464s $ non-trimmed: num NA 464s $ trimmed : num NA 464s int [1:2] -4 1 464s List of 2 464s $ non-trimmed: num NA 464s $ trimmed : num NA 464s int [1:3] -2 1 -1 464s List of 2 464s $ non-trimmed: num 2.5 464s $ trimmed : num 2.5 464s mode: double num(0) 464s List of 2 464s $ non-trimmed: num NA 464s $ trimmed : num NA 464s num -3.78 464s List of 2 464s $ non-trimmed: num NA 464s $ trimmed : num NA 464s num [1:2] -2.04 2.38 464s List of 2 464s $ non-trimmed: num NA 464s $ trimmed : num NA 464s num [1:3] 1.42 -2.14 1.14 464s List of 2 464s $ non-trimmed: num 3.42 464s $ trimmed : num 3.42 464s sdDiff()...DONE 464s madDiff()... 464s mode: integer int(0) 464s List of 2 464s $ non-trimmed: num NA 464s $ trimmed : num NA 464s int -1 464s List of 2 464s $ non-trimmed: num NA 464s $ trimmed : num NA 464s int [1:2] -1 4 464s List of 2 464s $ non-trimmed: num NA 464s $ trimmed : num NA 464s int [1:3] -1 0 -3 464s List of 2 464s $ non-trimmed: num 2.1 464s $ trimmed : num 2.1 464s mode: double num(0) 464s List of 2 464s $ non-trimmed: num NA 464s $ trimmed : num NA 464s num -1.13 464s List of 2 464s $ non-trimmed: num NA 464s $ trimmed : num NA 464s num [1:2] -1.7 -1.21 464s List of 2 464s $ non-trimmed: num NA 464s $ trimmed : num NA 464s num [1:3] -2.39 -0.464 3.086 464s List of 2 464s $ non-trimmed: num 0.851 464s $ trimmed : num 0.851 464s madDiff()...DONE 464s iqrDiff()... 464s mode: integer int(0) 464s List of 2 464s $ non-trimmed: num NA 464s $ trimmed : num NA 464s int 3 464s List of 2 464s $ non-trimmed: num 0 464s $ trimmed : num 0 464s int [1:2] -3 4 464s List of 2 464s $ non-trimmed: num 0 464s $ trimmed : num 0 464s int [1:3] 0 -2 -2 464s List of 2 464s $ non-trimmed: num 0.707 464s $ trimmed : num 0.707 464s mode: double num(0) 464s List of 2 464s $ non-trimmed: num NA 464s $ trimmed : num NA 464s num -4.46 464s List of 2 464s $ non-trimmed: num 0 464s $ trimmed : num 0 464s num [1:2] 3.67 1.02 464s List of 2 464s $ non-trimmed: num 0 464s $ trimmed : num 0 464s num [1:3] -0.537 -2.733 2.857 464s List of 2 464s $ non-trimmed: num 2.75 464s $ trimmed : num 2.75 464s iqrDiff()...DONE 464s > 464s 464s R version 4.4.3 (2025-02-28) -- "Trophy Case" 464s Copyright (C) 2025 The R Foundation for Statistical Computing 464s Platform: arm-unknown-linux-gnueabihf (32-bit) 464s 464s R is free software and comes with ABSOLUTELY NO WARRANTY. 464s You are welcome to redistribute it under certain conditions. 464s Type 'license()' or 'licence()' for distribution details. 464s 464s R is a collaborative project with many contributors. 464s Type 'contributors()' for more information and 464s 'citation()' on how to cite R or R packages in publications. 464s 464s Type 'demo()' for some demos, 'help()' for on-line help, or 464s 'help.start()' for an HTML browser interface to help. 464s Type 'q()' to quit R. 464s 464s > library("matrixStats") 464s > 464s > fcns <- list( 464s + varDiff = varDiff, 464s + sdDiff = sdDiff, 464s + madDiff = madDiff, 464s + iqrDiff = iqrDiff 464s + ) 464s > 464s > 464s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 464s > # Subsetted tests 464s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 464s > source("utils/validateIndicesFramework.R") 464s > for (name in names(fcns)) { 464s + cat(sprintf("subsetted tests on %s()...\n", name)) 464s + fcn <- fcns[[name]] 464s + 464s + for (mode in c("numeric", "integer")) { 464s + x <- runif(6, min = -6, max = 6) 464s + storage.mode(x) <- mode 464s + trim <- runif(1, min = 0, max = 0.5) 464s + if (mode == "numeric") x[1] <- Inf 464s + 464s + for (diff in 1:2) { 464s + for (idxs in index_cases) { 464s + validateIndicesTestVector(x, idxs, 464s + ftest = fcn, fsure = fcn, 464s + na.rm = TRUE, diff = diff, trim = trim) 464s + validateIndicesTestVector(x, idxs, 464s + ftest = fcn, fsure = fcn, 464s + na.rm = FALSE, diff = diff, trim = trim) 464s + } 464s + } 464s + } 464s + cat(sprintf("%s()...DONE\n", name)) 464s + } 464s subsetted tests on varDiff()... 464s varDiff()...DONE 464s subsetted tests on sdDiff()... 464s sdDiff()...DONE 464s subsetted tests on madDiff()... 464s madDiff()...DONE 464s subsetted tests on iqrDiff()... 464s iqrDiff()...DONE 464s > 464s 464s R version 4.4.3 (2025-02-28) -- "Trophy Case" 464s Copyright (C) 2025 The R Foundation for Statistical Computing 464s Platform: arm-unknown-linux-gnueabihf (32-bit) 464s 464s R is free software and comes with ABSOLUTELY NO WARRANTY. 464s You are welcome to redistribute it under certain conditions. 464s Type 'license()' or 'licence()' for distribution details. 464s 464s R is a collaborative project with many contributors. 464s Type 'contributors()' for more information and 464s 'citation()' on how to cite R or R packages in publications. 464s 464s Type 'demo()' for some demos, 'help()' for on-line help, or 464s 'help.start()' for an HTML browser interface to help. 464s Type 'q()' to quit R. 464s 464s > library("matrixStats") 464s > 464s > for (mode in c("logical", "integer", "double")) { 464s + cat("mode: ", mode, "", sep = "") 464s + n <- 2L 464s + x <- runif(n, min = -5, max = 5) 464s + if (mode == "logical") { 464s + x <- x > 0 464s + } 464s + storage.mode(x) <- mode 464s + str(x) 464s + 464s + cat("All weights are 1\n") 464s + w <- rep(1, times = n) 464s + m0 <- weighted.mean(x, w) 464s + m1 <- weightedMean(x, w) 464s + str(list(m0 = m0, m1 = m1)) 464s + stopifnot(identical(m1, m0)) 464s + 464s + cat("First weight is 5\n") 464s + # Pull the mean towards zero 464s + w[1] <- 5 464s + str(w) 464s + m0 <- weighted.mean(x, w) 464s + m1 <- weightedMean(x, w) 464s + str(list(m0 = m0, m1 = m1)) 464s + stopifnot(identical(m1, m0)) 464s + 464s + cat("All weights are 0\n") 464s + # All weights set to zero 464s + w <- rep(0, times = n) 464s + m0 <- weighted.mean(x, w) 464s + m1 <- weightedMean(x, w) 464s + str(list(m0 = m0, m1 = m1)) 464s + stopifnot(identical(m1, m0)) 464s + 464s + cat("First weight is 8.5\n") 464s + # Put even more weight on the zero 464s + w[1] <- 8.5 464s + m0 <- weighted.mean(x, w) 464s + m1 <- weightedMean(x, w) 464s + str(list(m0 = m0, m1 = m1)) 464s + stopifnot(identical(m1, m0)) 464s + 464s + cat("First weight is Inf\n") 464s + # All weight on the first value 464s + w[1] <- Inf 464s + m0 <- weighted.mean(x, w) 464s + m1 <- weightedMean(x, w) 464s + str(list(m0 = m0, m1 = m1)) 464s + stopifnot(identical(m1, m0)) 464s + 464s + cat("Last weight is Inf\n") 464s + # All weight on the last value 464s + w[1] <- 1 464s + w[n] <- Inf 464s + m0 <- weighted.mean(x, w) 464s + m1 <- weightedMean(x, w) 464s + str(list(m0 = m0, m1 = m1)) 464s + stopifnot(identical(m1, m0)) 464s + } # for (mode ...) 465s mode: logical logi [1:2] FALSE FALSE 465s All weights are 1 465s List of 2 465s $ m0: num 0 465s $ m1: num 0 465s First weight is 5 465s num [1:2] 5 1 465s List of 2 465s $ m0: num 0 465s $ m1: num 0 465s All weights are 0 465s List of 2 465s $ m0: num NaN 465s $ m1: num NaN 465s First weight is 8.5 465s List of 2 465s $ m0: num 0 465s $ m1: num 0 465s First weight is Inf 465s List of 2 465s $ m0: num NaN 465s $ m1: num NaN 465s Last weight is Inf 465s List of 2 465s $ m0: num NaN 465s $ m1: num NaN 465s mode: integer int [1:2] -4 2 465s All weights are 1 465s List of 2 465s $ m0: num -1 465s $ m1: num -1 465s First weight is 5 465s num [1:2] 5 1 465s List of 2 465s $ m0: num -3 465s $ m1: num -3 465s All weights are 0 465s List of 2 465s $ m0: num NaN 465s $ m1: num NaN 465s First weight is 8.5 465s List of 2 465s $ m0: num -4 465s $ m1: num -4 465s First weight is Inf 465s List of 2 465s $ m0: num NaN 465s $ m1: num NaN 465s Last weight is Inf 465s List of 2 465s $ m0: num NaN 465s $ m1: num NaN 465s mode: double num [1:2] 2.31 -4.95 465s All weights are 1 465s List of 2 465s $ m0: num -1.32 465s $ m1: num -1.32 465s First weight is 5 465s num [1:2] 5 1 465s List of 2 465s $ m0: num 1.1 465s $ m1: num 1.1 465s All weights are 0 465s List of 2 465s $ m0: num NaN 465s $ m1: num NaN 465s First weight is 8.5 465s List of 2 465s $ m0: num 2.31 465s $ m1: num 2.31 465s First weight is Inf 465s List of 2 465s $ m0: num NaN 465s $ m1: num NaN 465s Last weight is Inf 465s List of 2 465s $ m0: num NaN 465s $ m1: num NaN 465s > 465s > 465s > message("*** Testing for missing values") 465s *** Testing for missing values 465s > # NA tests 465s > xs <- list(A = c(1, 2, 3), B = c(NA, 2, 3), C = c(NA, 2, 3)) 465s > ws <- list(A = c(1, 1, 1), B = c(NA, 1, 1), C = c(1, NA, 1)) 465s > ## NOTE: The (B, B) case with na.rm = TRUE is interesting because 465s > ## even if NAs in 'w' are not dropped by na.rm = TRUE, this one 465s > ## is because 'x' is dropped and therefore that first element 465s > ## is skipped in the computation. It basically does 465s > ## keep <- !is.na(x); x <- x[keep]; w <- w[keep] 465s > ## without looking at 'w'. 465s > for (x in xs) { 465s + for (mode in c("logical", "integer", "double")) { 465s + storage.mode(x) <- mode 465s + for (w in ws) { 465s + for (na.rm in c(FALSE, TRUE)) { 465s + cat(sprintf("mode: %s, na.rm = %s\n", mode, na.rm)) 465s + str(list(x = x, w = w)) 465s + m0 <- weighted.mean(x, w, na.rm = na.rm) 465s + m1 <- weightedMean(x, w, na.rm = na.rm) 465s + str(list(m0 = m0, m1 = m1)) 465s + stopifnot(all.equal(m1, m0)) 465s + } 465s + } 465s + } 465s + } 465s mode: logical, na.rm = FALSE 465s List of 2 465s $ x: logi [1:3] TRUE TRUE TRUE 465s $ w: num [1:3] 1 1 1 465s List of 2 465s $ m0: num 1 465s $ m1: num 1 465s mode: logical, na.rm = TRUE 465s List of 2 465s $ x: logi [1:3] TRUE TRUE TRUE 465s $ w: num [1:3] 1 1 1 465s List of 2 465s $ m0: num 1 465s $ m1: num 1 465s mode: logical, na.rm = FALSE 465s List of 2 465s $ x: logi [1:3] TRUE TRUE TRUE 465s $ w: num [1:3] NA 1 1 465s List of 2 465s $ m0: num NA 465s $ m1: num NA 465s mode: logical, na.rm = TRUE 465s List of 2 465s $ x: logi [1:3] TRUE TRUE TRUE 465s $ w: num [1:3] NA 1 1 465s List of 2 465s $ m0: num NA 465s $ m1: num NA 465s mode: logical, na.rm = FALSE 465s List of 2 465s $ x: logi [1:3] TRUE TRUE TRUE 465s $ w: num [1:3] 1 NA 1 465s List of 2 465s $ m0: num NA 465s $ m1: num NA 465s mode: logical, na.rm = TRUE 465s List of 2 465s $ x: logi [1:3] TRUE TRUE TRUE 465s $ w: num [1:3] 1 NA 1 465s List of 2 465s $ m0: num NA 465s $ m1: num NA 465s mode: integer, na.rm = FALSE 465s List of 2 465s $ x: int [1:3] 1 1 1 465s $ w: num [1:3] 1 1 1 465s List of 2 465s $ m0: num 1 465s $ m1: num 1 465s mode: integer, na.rm = TRUE 465s List of 2 465s $ x: int [1:3] 1 1 1 465s $ w: num [1:3] 1 1 1 465s List of 2 465s $ m0: num 1 465s $ m1: num 1 465s mode: integer, na.rm = FALSE 465s List of 2 465s $ x: int [1:3] 1 1 1 465s $ w: num [1:3] NA 1 1 465s List of 2 465s $ m0: num NA 465s $ m1: num NA 465s mode: integer, na.rm = TRUE 465s List of 2 465s $ x: int [1:3] 1 1 1 465s $ w: num [1:3] NA 1 1 465s List of 2 465s $ m0: num NA 465s $ m1: num NA 465s mode: integer, na.rm = FALSE 465s List of 2 465s $ x: int [1:3] 1 1 1 465s $ w: num [1:3] 1 NA 1 465s List of 2 465s $ m0: num NA 465s $ m1: num NA 465s mode: integer, na.rm = TRUE 465s List of 2 465s $ x: int [1:3] 1 1 1 465s $ w: num [1:3] 1 NA 1 465s List of 2 465s $ m0: num NA 465s $ m1: num NA 465s mode: double, na.rm = FALSE 465s List of 2 465s $ x: num [1:3] 1 1 1 465s $ w: num [1:3] 1 1 1 465s List of 2 465s $ m0: num 1 465s $ m1: num 1 465s mode: double, na.rm = TRUE 465s List of 2 465s $ x: num [1:3] 1 1 1 465s $ w: num [1:3] 1 1 1 465s List of 2 465s $ m0: num 1 465s $ m1: num 1 465s mode: double, na.rm = FALSE 465s List of 2 465s $ x: num [1:3] 1 1 1 465s $ w: num [1:3] NA 1 1 465s List of 2 465s $ m0: num NA 465s $ m1: num NA 465s mode: double, na.rm = TRUE 465s List of 2 465s $ x: num [1:3] 1 1 1 465s $ w: num [1:3] NA 1 1 465s List of 2 465s $ m0: num NA 465s $ m1: num NA 465s mode: double, na.rm = FALSE 465s List of 2 465s $ x: num [1:3] 1 1 1 465s $ w: num [1:3] 1 NA 1 465s List of 2 465s $ m0: num NA 465s $ m1: num NA 465s mode: double, na.rm = TRUE 465s List of 2 465s $ x: num [1:3] 1 1 1 465s $ w: num [1:3] 1 NA 1 465s List of 2 465s $ m0: num NA 465s $ m1: num NA 465s mode: logical, na.rm = FALSE 465s List of 2 465s $ x: logi [1:3] NA TRUE TRUE 465s $ w: num [1:3] 1 1 1 465s List of 2 465s $ m0: num NA 465s $ m1: num NA 465s mode: logical, na.rm = TRUE 465s List of 2 465s $ x: logi [1:3] NA TRUE TRUE 465s $ w: num [1:3] 1 1 1 465s List of 2 465s $ m0: num 1 465s $ m1: num 1 465s mode: logical, na.rm = FALSE 465s List of 2 465s $ x: logi [1:3] NA TRUE TRUE 465s $ w: num [1:3] NA 1 1 465s List of 2 465s $ m0: num NA 465s $ m1: num NA 465s mode: logical, na.rm = TRUE 465s List of 2 465s $ x: logi [1:3] NA TRUE TRUE 465s $ w: num [1:3] NA 1 1 465s List of 2 465s $ m0: num 1 465s $ m1: num 1 465s mode: logical, na.rm = FALSE 465s List of 2 465s $ x: logi [1:3] NA TRUE TRUE 465s $ w: num [1:3] 1 NA 1 465s List of 2 465s $ m0: num NA 465s $ m1: num NA 465s mode: logical, na.rm = TRUE 465s List of 2 465s $ x: logi [1:3] NA TRUE TRUE 465s $ w: num [1:3] 1 NA 1 465s List of 2 465s $ m0: num NA 465s $ m1: num NA 465s mode: integer, na.rm = FALSE 465s List of 2 465s $ x: int [1:3] NA 1 1 465s $ w: num [1:3] 1 1 1 465s List of 2 465s $ m0: num NA 465s $ m1: num NA 465s mode: integer, na.rm = TRUE 465s List of 2 465s $ x: int [1:3] NA 1 1 465s $ w: num [1:3] 1 1 1 465s List of 2 465s $ m0: num 1 465s $ m1: num 1 465s mode: integer, na.rm = FALSE 465s List of 2 465s $ x: int [1:3] NA 1 1 465s $ w: num [1:3] NA 1 1 465s List of 2 465s $ m0: num NA 465s $ m1: num NA 465s mode: integer, na.rm = TRUE 465s List of 2 465s $ x: int [1:3] NA 1 1 465s $ w: num [1:3] NA 1 1 465s List of 2 465s $ m0: num 1 465s $ m1: num 1 465s mode: integer, na.rm = FALSE 465s List of 2 465s $ x: int [1:3] NA 1 1 465s $ w: num [1:3] 1 NA 1 465s List of 2 465s $ m0: num NA 465s $ m1: num NA 465s mode: integer, na.rm = TRUE 465s List of 2 465s $ x: int [1:3] NA 1 1 465s $ w: num [1:3] 1 NA 1 465s List of 2 465s $ m0: num NA 465s $ m1: num NA 465s mode: double, na.rm = FALSE 465s List of 2 465s $ x: num [1:3] NA 1 1 465s $ w: num [1:3] 1 1 1 465s List of 2 465s $ m0: num NA 465s $ m1: num NA 465s mode: double, na.rm = TRUE 465s List of 2 465s $ x: num [1:3] NA 1 1 465s $ w: num [1:3] 1 1 1 465s List of 2 465s $ m0: num 1 465s $ m1: num 1 465s mode: double, na.rm = FALSE 465s List of 2 465s $ x: num [1:3] NA 1 1 465s $ w: num [1:3] NA 1 1 465s List of 2 465s $ m0: num NA 465s $ m1: num NA 465s mode: double, na.rm = TRUE 465s List of 2 465s $ x: num [1:3] NA 1 1 465s $ w: num [1:3] NA 1 1 465s List of 2 465s $ m0: num 1 465s $ m1: num 1 465s mode: double, na.rm = FALSE 465s List of 2 465s $ x: num [1:3] NA 1 1 465s $ w: num [1:3] 1 NA 1 465s List of 2 465s $ m0: num NA 465s $ m1: num NA 465s mode: double, na.rm = TRUE 465s List of 2 465s $ x: num [1:3] NA 1 1 465s $ w: num [1:3] 1 NA 1 465s List of 2 465s $ m0: num NA 465s $ m1: num NA 465s mode: logical, na.rm = FALSE 465s List of 2 465s $ x: logi [1:3] NA TRUE TRUE 465s $ w: num [1:3] 1 1 1 465s List of 2 465s $ m0: num NA 465s $ m1: num NA 465s mode: logical, na.rm = TRUE 465s List of 2 465s $ x: logi [1:3] NA TRUE TRUE 465s $ w: num [1:3] 1 1 1 465s List of 2 465s $ m0: num 1 465s $ m1: num 1 465s mode: logical, na.rm = FALSE 465s List of 2 465s $ x: logi [1:3] NA TRUE TRUE 465s $ w: num [1:3] NA 1 1 465s List of 2 465s $ m0: num NA 465s $ m1: num NA 465s mode: logical, na.rm = TRUE 465s List of 2 465s $ x: logi [1:3] NA TRUE TRUE 465s $ w: num [1:3] NA 1 1 465s List of 2 465s $ m0: num 1 465s $ m1: num 1 465s mode: logical, na.rm = FALSE 465s List of 2 465s $ x: logi [1:3] NA TRUE TRUE 465s $ w: num [1:3] 1 NA 1 465s List of 2 465s $ m0: num NA 465s $ m1: num NA 465s mode: logical, na.rm = TRUE 465s List of 2 465s $ x: logi [1:3] NA TRUE TRUE 465s $ w: num [1:3] 1 NA 1 465s List of 2 465s $ m0: num NA 465s $ m1: num NA 465s mode: integer, na.rm = FALSE 465s List of 2 465s $ x: int [1:3] NA 1 1 465s $ w: num [1:3] 1 1 1 465s List of 2 465s $ m0: num NA 465s $ m1: num NA 465s mode: integer, na.rm = TRUE 465s List of 2 465s $ x: int [1:3] NA 1 1 465s $ w: num [1:3] 1 1 1 465s List of 2 465s $ m0: num 1 465s $ m1: num 1 465s mode: integer, na.rm = FALSE 465s List of 2 465s $ x: int [1:3] NA 1 1 465s $ w: num [1:3] NA 1 1 465s List of 2 465s $ m0: num NA 465s $ m1: num NA 465s mode: integer, na.rm = TRUE 465s List of 2 465s $ x: int [1:3] NA 1 1 465s $ w: num [1:3] NA 1 1 465s List of 2 465s $ m0: num 1 465s $ m1: num 1 465s mode: integer, na.rm = FALSE 465s List of 2 465s $ x: int [1:3] NA 1 1 465s $ w: num [1:3] 1 NA 1 465s List of 2 465s $ m0: num NA 465s $ m1: num NA 465s mode: integer, na.rm = TRUE 465s List of 2 465s $ x: int [1:3] NA 1 1 465s $ w: num [1:3] 1 NA 1 465s List of 2 465s $ m0: num NA 465s $ m1: num NA 465s mode: double, na.rm = FALSE 465s List of 2 465s $ x: num [1:3] NA 1 1 465s $ w: num [1:3] 1 1 1 465s List of 2 465s $ m0: num NA 465s $ m1: num NA 465s mode: double, na.rm = TRUE 465s List of 2 465s $ x: num [1:3] NA 1 1 465s $ w: num [1:3] 1 1 1 465s List of 2 465s $ m0: num 1 465s $ m1: num 1 465s mode: double, na.rm = FALSE 465s List of 2 465s $ x: num [1:3] NA 1 1 465s $ w: num [1:3] NA 1 1 465s List of 2 465s $ m0: num NA 465s $ m1: num NA 465s mode: double, na.rm = TRUE 465s List of 2 465s $ x: num [1:3] NA 1 1 465s $ w: num [1:3] NA 1 1 465s List of 2 465s $ m0: num 1 465s $ m1: num 1 465s mode: double, na.rm = FALSE 465s List of 2 465s $ x: num [1:3] NA 1 1 465s $ w: num [1:3] 1 NA 1 465s List of 2 465s $ m0: num NA 465s $ m1: num NA 465s mode: double, na.rm = TRUE 465s List of 2 465s $ x: num [1:3] NA 1 1 465s $ w: num [1:3] 1 NA 1 465s List of 2 465s $ m0: num NA 465s $ m1: num NA 465s > 465s 465s R version 4.4.3 (2025-02-28) -- "Trophy Case" 465s Copyright (C) 2025 The R Foundation for Statistical Computing 465s Platform: arm-unknown-linux-gnueabihf (32-bit) 465s 465s R is free software and comes with ABSOLUTELY NO WARRANTY. 465s You are welcome to redistribute it under certain conditions. 465s Type 'license()' or 'licence()' for distribution details. 465s 465s R is a collaborative project with many contributors. 465s Type 'contributors()' for more information and 465s 'citation()' on how to cite R or R packages in publications. 465s 465s Type 'demo()' for some demos, 'help()' for on-line help, or 465s 'help.start()' for an HTML browser interface to help. 465s Type 'q()' to quit R. 465s 465s > library("matrixStats") 465s > 465s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 465s > # Subsetted tests 465s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 465s > source("utils/validateIndicesFramework.R") 465s > for (mode in c("numeric", "integer")) { 465s + x <- runif(6, min = -6, max = 6) 465s + w <- runif(6, min = 0, max = 6) 465s + storage.mode(x) <- mode 465s + storage.mode(w) <- mode 465s + if (mode == "numeric") w[1] <- Inf 465s + 465s + for (idxs in index_cases) { 465s + validateIndicesTestVector_w(x, w, idxs, 465s + ftest = weightedMean, fsure = weighted.mean, 465s + na.rm = TRUE, refine = TRUE) 465s + validateIndicesTestVector_w(x, w, idxs, 465s + ftest = weightedMean, fsure = weighted.mean, 465s + na.rm = FALSE, refine = TRUE) 465s + } 465s + } 465s > 465s 465s R version 4.4.3 (2025-02-28) -- "Trophy Case" 465s Copyright (C) 2025 The R Foundation for Statistical Computing 465s Platform: arm-unknown-linux-gnueabihf (32-bit) 465s 465s R is free software and comes with ABSOLUTELY NO WARRANTY. 465s You are welcome to redistribute it under certain conditions. 465s Type 'license()' or 'licence()' for distribution details. 465s 465s R is a collaborative project with many contributors. 465s Type 'contributors()' for more information and 465s 'citation()' on how to cite R or R packages in publications. 465s 465s Type 'demo()' for some demos, 'help()' for on-line help, or 465s 'help.start()' for an HTML browser interface to help. 465s Type 'q()' to quit R. 465s 465s > library("matrixStats") 466s > 466s > x <- 1:5 466s > y <- weightedMedian(x) 466s > y <- weightedMedian(x, w = c(NA, Inf, NA, Inf, NA), na.rm = TRUE) 466s > print(y) 466s [1] 3 466s > 466s > y <- weightedMedian(x, w = c(NA, Inf, NA, Inf, NA), na.rm = FALSE) 466s > print(y) 466s [1] NA 466s > stopifnot(is.na(y)) 466s > 466s > x <- 1:10 466s > n <- length(x) 466s > 466s > y1 <- median(x) # 5.5 466s > y2 <- weightedMedian(x) # 5.5 466s > stopifnot(all.equal(y1, y2)) 466s > 466s > 466s > w <- rep(1, times = n) 466s > y1 <- weightedMedian(x, w) # 5.5 (default) 466s > y2a <- weightedMedian(x, ties = "weighted") # 5.5 (default) 466s > y2b <- weightedMedian(x, ties = "min") # 5 466s > y2c <- weightedMedian(x, ties = "max") # 6 466s > stopifnot(all.equal(y2a, y1)) 466s > 466s > y3 <- weightedMedian(x, w) # 5.5 (default) 466s > 466s > 466s > # Pull the median towards zero 466s > w[1] <- 5 466s > y1 <- weightedMedian(x, w) # 3.5 466s > y <- c(rep(0, times = w[1]), x[-1]) # Only possible for integer weights 466s > y2 <- median(y) # 3.5 466s > stopifnot(all.equal(y1, y2)) 466s > 466s > # Put even more weight on the zero 466s > w[1] <- 8.5 466s > y <- weightedMedian(x, w) # 2 466s > 466s > # All weight on the first value 466s > w[1] <- Inf 466s > y <- weightedMedian(x, w) # 1 466s > 466s > # All weight on the last value 466s > w[1] <- 1 466s > w[n] <- Inf 466s > y <- weightedMedian(x, w) # 10 466s > 466s > # All weights set to zero 466s > w <- rep(0, times = n) 466s > y <- weightedMedian(x, w) # NA 466s > 466s > x <- 1:4 466s > w <- rep(1, times = 4) 466s > for (mode in c("integer", "double")) { 466s + storage.mode(x) <- mode 466s + for (ties in c("weighted", "mean", "min", "max")) { 466s + cat(sprintf("ties = %s\n", ties)) 466s + y <- weightedMedian(x, w, ties = ties) 466s + } 466s + } 466s ties = weighted 466s ties = mean 466s ties = min 466s ties = max 466s ties = weighted 466s ties = mean 466s ties = min 466s ties = max 466s > 466s > set.seed(0x42) 466s > 466s > y <- weightedMedian(x = double(0L)) 466s > print(y) 466s [1] NA 466s > stopifnot(length(y) == 1L) 466s > stopifnot(is.na(y)) 466s > 466s > y <- weightedMedian(x = x[1]) 466s > print(y) 466s [1] 1 466s > stopifnot(length(y) == 1L) 466s > stopifnot(all.equal(y, x[1])) 466s > 466s > 466s > n <- 1e3 466s > x <- runif(n) 466s > w <- runif(n, min = 0, max = 1) 466s > for (mode in c("integer", "double")) { 466s + storage.mode(x) <- mode 466s + for (ties in c("weighted", "mean", "min", "max")) { 466s + y <- weightedMedian(x, w, ties = ties) 466s + cat(sprintf("mode = %s, ties = %s, result = %g\n", mode, ties, y)) 466s + } 466s + } 466s mode = integer, ties = weighted, result = 0 466s mode = integer, ties = mean, result = 0 466s mode = integer, ties = min, result = 0 466s mode = integer, ties = max, result = 0 466s mode = double, ties = weighted, result = 0 466s mode = double, ties = mean, result = 0 466s mode = double, ties = min, result = 0 466s mode = double, ties = max, result = 0 466s > 466s > 466s > # A large vector 466s > n <- 1e5 466s > x <- runif(n) 466s > w <- runif(n, min = 0, max = 1) 466s > y <- weightedMedian(x, w) 466s > 466s > y <- weightedMedian(x, w, ties = "min") 466s > 466s > 466s > # Single Number 466s > xs <- c(1, NA_integer_) 466s > ws <- c(1, NA_integer_) 466s > for (x in xs) { 466s + for (w in ws) { 466s + y <- weightedMedian(x = x, w = w) 466s + if (is.na(w)) z <- NA_real_ 466s + else z <- x[1] 466s + stopifnot(all.equal(y, z)) 466s + } 466s + } 466s > 466s > ## Logical 466s > x1 <- c(TRUE, FALSE, TRUE) 466s > w0 <- c(0, 0, 0) 466s > stopifnot(!is.finite(weightedMedian(x1, w0)), 466s + !is.infinite(weightedMedian(x1, w0))) 466s > 466s > w1 <- c(1, 1, 1) 466s > stopifnot(weightedMedian(x1, w1) == 1) 466s > 466s > w2 <- c(1, 2, 3) 466s > stopifnot(weightedMedian(x1, w2) == 1) 466s > 466s > ### NA 466s > stopifnot(is.na(weightedMedian(c(TRUE, FALSE, NA), 466s + c(1, 2, 3))), 466s + all.equal(weightedMedian(c(TRUE, FALSE, NA), 466s + c(1, 2, 3), 466s + na.rm = TRUE), 466s + weightedMedian(c(TRUE, FALSE), 466s + c(1, 2)))) 466s > ### Identical to as.integer() 466s > x <- rcauchy(100) 466s > w <- abs(rcauchy(100)) 466s > stopifnot(all.equal(weightedMedian(x > 0, w), 466s + weightedMedian(as.integer(x > 0), w))) 466s > 466s > 466s > 466s 466s R version 4.4.3 (2025-02-28) -- "Trophy Case" 466s Copyright (C) 2025 The R Foundation for Statistical Computing 466s Platform: arm-unknown-linux-gnueabihf (32-bit) 466s 466s R is free software and comes with ABSOLUTELY NO WARRANTY. 466s You are welcome to redistribute it under certain conditions. 466s Type 'license()' or 'licence()' for distribution details. 466s 466s R is a collaborative project with many contributors. 466s Type 'contributors()' for more information and 466s 'citation()' on how to cite R or R packages in publications. 466s 466s Type 'demo()' for some demos, 'help()' for on-line help, or 466s 'help.start()' for an HTML browser interface to help. 466s Type 'q()' to quit R. 466s 466s > library("matrixStats") 466s > 466s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 466s > # Subsetted tests 466s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 466s > source("utils/validateIndicesFramework.R") 466s > for (mode in c("numeric", "integer")) { 466s + x <- runif(6, min = -6, max = 6) 466s + w <- runif(6, min = 0, max = 6) 466s + storage.mode(x) <- mode 466s + storage.mode(w) <- mode 466s + if (mode == "numeric") w[1] <- Inf 466s + 466s + for (idxs in index_cases) { 466s + validateIndicesTestVector_w(x, w, idxs, 466s + ftest = weightedMedian, 466s + fsure = weightedMedian, 466s + na.rm = TRUE) 466s + validateIndicesTestVector_w(x, w, idxs, 466s + ftest = weightedMedian, 466s + fsure = weightedMedian, 466s + na.rm = FALSE) 466s + 466s + for (ties in c("weighted", "mean", "min", "max")) { 466s + validateIndicesTestVector_w(x, w, idxs, 466s + ftest = weightedMedian, 466s + fsure = weightedMedian, 466s + na.rm = TRUE, ties = ties) 466s + validateIndicesTestVector_w(x, w, idxs, 466s + ftest = weightedMedian, 466s + fsure = weightedMedian, 466s + na.rm = FALSE, ties = ties) 466s + } 466s + } 466s + } 466s > 466s 466s R version 4.4.3 (2025-02-28) -- "Trophy Case" 466s Copyright (C) 2025 The R Foundation for Statistical Computing 466s Platform: arm-unknown-linux-gnueabihf (32-bit) 466s 466s R is free software and comes with ABSOLUTELY NO WARRANTY. 466s You are welcome to redistribute it under certain conditions. 466s Type 'license()' or 'licence()' for distribution details. 466s 466s R is a collaborative project with many contributors. 466s Type 'contributors()' for more information and 466s 'citation()' on how to cite R or R packages in publications. 466s 466s Type 'demo()' for some demos, 'help()' for on-line help, or 466s 'help.start()' for an HTML browser interface to help. 466s Type 'q()' to quit R. 466s 466s > library("matrixStats") 466s > 466s > weightedVar_R <- function(x, w) { 466s + mu <- weighted.mean(x, w = w) 466s + sum(w * (x - mu) ^ 2) / (sum(w) - 1) 466s + } 466s > 466s > 466s > n <- 10 466s > x <- as.double(1:n) 466s > 466s > message("*** weightedVar() ...") 466s > 466s > message("- Zero elements") 466s > m0 <- var(integer(0)) 466s > m1 <- weightedVar(integer(0), w = integer(0)) 466s > str(list(m0 = m0, m1 = m1)) 466s *** weightedVar() ... 466s - Zero elements 466s List of 2 466s $ m0: num NA 466s $ m1:- One elements 466s int NA 466s > stopifnot(all.equal(m1, m0)) 466s > 466s > 466s > message("- One elements") 466s > m0 <- var(1) 466s > m1 <- weightedVar(1) 466s > str(list(m0 = m0, m1 = m1)) 466s List of 2 466s - Uniform weights (all w = 1) 466s $ m0: num NA 466s $ m1: num NA 466s > stopifnot(all.equal(m1, m0)) 466s > 466s > 466s > message("- Uniform weights (all w = 1)") 466s > m0 <- var(x) 466s > w <- rep(1, times = n) 466s > m1 <- weightedVar(x, w = w) 466s > str(list(m0 = m0, m1 = m1)) 466s List of 2 466s $ m0: num 9.17 466s $ m1: num 9.17 466s > stopifnot(all.equal(m1, m0)) 466s > 466s > 466s > message("- Uniform weights (all w = 3)") 466s > m0 <- var(rep(x, each = 3)) 466s > w <- rep(3, times = n) 466s > m1 <- weightedVar(x, w = w) 466s - Uniform weights (all w = 3) 466s > str(list(m0 = m0, m1 = m1)) 466s List of 2 466s $ m0: num 8.53 466s $ m1: num 8.53 466s > stopifnot(all.equal(m1, m0)) 466s > 466s > 466s > message("- Uniform weights on the first five elements") 466s - Uniform weights on the first five elements 466s > idxs <- 1:5 466s > m0 <- var(x[1:5]) 466s > w <- rep(0, times = n) 466s > w[idxs] <- 1 466s > m1 <- weightedVar(x, w = w) 466s > str(list(m0 = m0, m1 = m1)) 466s List of 2 466s $ m0: num 2.5 466s $ m1: num 2.5 466s > stopifnot(all.equal(m1, m0)) 466s > 466s > 466s > message("- Uniform weights on every second elements") 466s > idxs <- seq(from = 1, to = n, by = 2) 466s - Uniform weights on every second elements 466s > m0 <- var(x[idxs]) 466s > w <- rep(0, times = n) 466s > w[idxs] <- 1 466s > m1 <- weightedVar(x, w = w) 466s > str(list(m0 = m0, m1 = m1)) 466s List of 2 466s $ m0:- All weights are zero 466s num 10 466s $ m1: num 10 466s > stopifnot(all.equal(m1, m0)) 466s > 466s > 466s > message("- All weights are zero") 466s > idxs <- integer(0L) 466s > m0 <- var(x[idxs]) 466s > w <- rep(0, times = n) 466s > w[idxs] <- 1 466s > m1 <- weightedVar(x, w = w) 466s > str(list(m0 = m0, m1 = m1)) 466s List of 2 466s $ m0: num NA 466s $ m1:- Infinite weight on first element 466s num NA 466s > stopifnot(all.equal(m1, m0)) 466s > 466s > message("- Infinite weight on first element") 466s > idxs <- 1L 466s > m0 <- var(x[idxs]) 466s > w <- rep(0, times = n) 466s > w[idxs] <- Inf 466s > m1 <- weightedVar(x, w = w) 466s > str(list(m0 = m0, m1 = m1)) 466s List of 2 466s $ m0: num NA 466s $ m1: num NA 466s > stopifnot(all.equal(m1, m0)) 466s > 466s > message("- Missing-value weight on first element") 466s > idxs <- 1L 466s > w <- rep(1, times = n) 466s > w[idxs] <- NA_real_ 466s > m1 <- weightedVar(x, w = w) 466s > str(list(m1 = m1)) 466s List of 1 466s $ m1: num NA 466s > stopifnot(identical(m1, NA_real_)) 466s > 466s > 466s > message("- Frequency weights") 466s > 466s > ## From https://en.wikipedia.org/wiki/Weighted_arithmetic_mean 466s > y <- c(2, 2, 4, 5, 5, 5) 466s > x <- unique(y) 466s > w <- table(y) 466s - Missing-value weight on first element 466s > stopifnot(names(w) == x) 466s > 466s > m0 <- weightedVar(x, w = w) 466s > m1 <- var(y) 466s > stopifnot(all.equal(m1, m0)) 466s > m2 <- weightedVar(x, w = w) 466s > str(list(m0 = m0, m1 = m1, m2 = m2)) 466s List of 3 466s $ m0: num 2.17 466s $ m1: num 2.17 466s $ m2: num 2.17 466s > stopifnot(all.equal(m2, m0)) 466s > 466s > ## From https://github.com/HenrikBengtsson/matrixStats/issues/72 466s > large <- c(21, 8, 26, 1, 15, 33, 12, 25, 0, 84) 466s > years <- c(41706, 9301, 33678, 3082, 27040, 44188, 10049, 30591, 2275, 109831) 466s > 466s > m0 <- weightedVar(large, w = years) 466s > m1 <- weightedVar(large, w = years) 466s > str(list(m0 = m0, m1 = m1)) 466s List of 2 466s $ m0: num 899 466s $ m1: num 899 466s > stopifnot(all.equal(m1, m0)) 466s > 466s > message("*** weightedVar() ... DONE") 466s > 466s - Frequency weights 466s *** weightedVar() ... DONE 466s 466s R version 4.4.3 (2025-02-28) -- "Trophy Case" 466s Copyright (C) 2025 The R Foundation for Statistical Computing 466s Platform: arm-unknown-linux-gnueabihf (32-bit) 466s 466s R is free software and comes with ABSOLUTELY NO WARRANTY. 466s You are welcome to redistribute it under certain conditions. 466s Type 'license()' or 'licence()' for distribution details. 466s 466s R is a collaborative project with many contributors. 466s Type 'contributors()' for more information and 466s 'citation()' on how to cite R or R packages in publications. 466s 466s Type 'demo()' for some demos, 'help()' for on-line help, or 466s 'help.start()' for an HTML browser interface to help. 466s Type 'q()' to quit R. 466s 467s > library("matrixStats") 467s > 467s > fcns <- list( 467s + weightedVar = weightedVar, 467s + weightedSd = weightedSd, 467s + weightedMad = weightedMad 467s + ) 467s > 467s > for (name in names(fcns)) { 467s + cat(sprintf("%s()...\n", name)) 467s + fcn <- fcns[[name]] 467s + 467s + for (mode in c("integer", "double")) { 467s + cat("mode: ", mode, "\n", sep = "") 467s + n <- 15L 467s + x <- runif(n, min = -5, max = 5) 467s + storage.mode(x) <- mode 467s + str(x) 467s + 467s + for (add_na in c(FALSE, TRUE)) { 467s + cat("add_na: ", add_na, "\n", sep = "") 467s + if (add_na) { 467s + x[c(5, 7)] <- NA 467s + } 467s + str(x) 467s + 467s + for (na.rm in c(FALSE, TRUE)) { 467s + cat("na.rm: ", na.rm, "\n", sep = "") 467s + 467s + cat("Weights are not specified (all are 1)\n") 467s + m1 <- fcn(x, na.rm = na.rm) 467s + str(list(m1 = m1)) 467s + 467s + cat("All weights are 1\n") 467s + w <- rep(1, times = n) 467s + m1 <- fcn(x, w, na.rm = na.rm) 467s + str(list(m1 = m1)) 467s + 467s + cat("First weight is 5\n") 467s + # Pull the mean towards zero 467s + w[1] <- 5 467s + str(w) 467s + m1 <- fcn(x, w, na.rm = na.rm) 467s + str(list(m1 = m1)) 467s + 467s + cat("All weights are 0\n") 467s + # All weights set to zero 467s + w <- rep(0, times = n) 467s + m1 <- fcn(x, w, na.rm = na.rm) 467s + str(list(m1 = m1)) 467s + 467s + cat("First weight is 8.5\n") 467s + # Put even more weight on the zero 467s + w[1] <- 8.5 467s + m1 <- fcn(x, w, na.rm = na.rm) 467s + str(list(m1 = m1)) 467s + 467s + cat("First weight is Inf\n") 467s + # All weight on the first value 467s + w[1] <- Inf 467s + m1 <- fcn(x, w, na.rm = na.rm) 467s + str(list(m1 = m1)) 467s + 467s + cat("Last weight is Inf\n") 467s + # All weight on the last value 467s + w[1] <- 1 467s + w[n] <- Inf 467s + m1 <- fcn(x, w, na.rm = na.rm) 467s + str(list(m1 = m1)) 467s + 467s + cat("Last weight is NA\n") 467s + # All weight on the last value 467s + w[1] <- 1 467s + w[n] <- NA_real_ 467s + m1 <- fcn(x, w, na.rm = na.rm) 467s + str(list(m1 = m1)) 467s + } # for (na.rm ...) 467s + } # for (add_na ...) 467s + } # for (mode ...) 467s + 467s + cat(sprintf("%s()...DONE\n", name)) 467s + } # for (name ...) 467s weightedVar()... 467s mode: integer 467s int [1:15] -4 -4 3 3 -4 2 4 -4 2 3 ... 467s add_na: FALSE 467s int [1:15] -4 -4 3 3 -4 2 4 -4 2 3 ... 467s na.rm: FALSE 467s Weights are not specified (all are 1) 467s List of 1 467s $ m1: num 11.1 467s All weights are 1 467s List of 1 467s $ m1: num 11.1 467s First weight is 5 467s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 467s List of 1 467s $ m1: num 11.9 467s All weights are 0 467s List of 1 467s $ m1: int NA 467s First weight is 8.5 467s List of 1 467s $ m1: int NA 467s First weight is Inf 467s List of 1 467s $ m1: int NA 467s Last weight is Inf 467s List of 1 467s $ m1: int NA 467s Last weight is NA 467s List of 1 467s $ m1: int NA 467s na.rm: TRUE 467s Weights are not specified (all are 1) 467s List of 1 467s $ m1: num 11.1 467s All weights are 1 467s List of 1 467s $ m1: num 11.1 467s First weight is 5 467s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 467s List of 1 467s $ m1: num 11.9 467s All weights are 0 467s List of 1 467s $ m1: int NA 467s First weight is 8.5 467s List of 1 467s $ m1: int NA 467s First weight is Inf 467s List of 1 467s $ m1: int NA 467s Last weight is Inf 467s List of 1 467s $ m1: int NA 467s Last weight is NA 467s List of 1 467s $ m1: int NA 467s add_na: TRUE 467s int [1:15] -4 -4 3 3 NA 2 NA -4 2 3 ... 467s na.rm: FALSE 467s Weights are not specified (all are 1) 467s List of 1 467s $ m1: int NA 467s All weights are 1 467s List of 1 467s $ m1: int NA 467s First weight is 5 467s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 467s List of 1 467s $ m1: int NA 467s All weights are 0 467s List of 1 467s $ m1: int NA 467s First weight is 8.5 467s List of 1 467s $ m1: int NA 467s First weight is Inf 467s List of 1 467s $ m1: int NA 467s Last weight is Inf 467s List of 1 467s $ m1: int NA 467s Last weight is NA 467s List of 1 467s $ m1: int NA 467s na.rm: TRUE 467s Weights are not specified (all are 1) 467s List of 1 467s $ m1: num 10.3 467s All weights are 1 467s List of 1 467s $ m1: num 10.3 467s First weight is 5 467s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 467s List of 1 467s $ m1: num 11.4 467s All weights are 0 467s List of 1 467s $ m1: int NA 467s First weight is 8.5 467s List of 1 467s $ m1: int NA 467s First weight is Inf 467s List of 1 467s $ m1: int NA 467s Last weight is Inf 467s List of 1 467s $ m1: int NA 467s Last weight is NA 467s List of 1 467s $ m1: int NA 467s mode: double 467s num [1:15] 2.98 4.86 -1.28 -2.53 -1.1 ... 467s add_na: FALSE 467s num [1:15] 2.98 4.86 -1.28 -2.53 -1.1 ... 467s na.rm: FALSE 467s Weights are not specified (all are 1) 467s List of 1 467s $ m1: num 5.66 467s All weights are 1 467s List of 1 467s $ m1: num 5.66 467s First weight is 5 467s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 467s List of 1 467s $ m1: num 6.14 467s All weights are 0 467s List of 1 467s $ m1: num NA 467s First weight is 8.5 467s List of 1 467s $ m1: num NA 467s First weight is Inf 467s List of 1 467s $ m1: num NA 467s Last weight is Inf 467s List of 1 467s $ m1: num NA 467s Last weight is NA 467s List of 1 467s $ m1: num NA 467s na.rm: TRUE 467s Weights are not specified (all are 1) 467s List of 1 467s $ m1: num 5.66 467s All weights are 1 467s List of 1 467s $ m1: num 5.66 467s First weight is 5 467s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 467s List of 1 467s $ m1: num 6.14 467s All weights are 0 467s List of 1 467s $ m1: num NA 467s First weight is 8.5 467s List of 1 467s $ m1: num NA 467s First weight is Inf 467s List of 1 467s $ m1: num NA 467s Last weight is Inf 467s List of 1 467s $ m1: num NA 467s Last weight is NA 467s List of 1 467s $ m1: num NA 467s add_na: TRUE 467s num [1:15] 2.98 4.86 -1.28 -2.53 NA ... 467s na.rm: FALSE 467s Weights are not specified (all are 1) 467s List of 1 467s $ m1: num NA 467s All weights are 1 467s List of 1 467s $ m1: num NA 467s First weight is 5 467s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 467s List of 1 467s $ m1: num NA 467s All weights are 0 467s List of 1 467s $ m1: num NA 467s First weight is 8.5 467s List of 1 467s $ m1: num NA 467s First weight is Inf 467s List of 1 467s $ m1: num NA 467s Last weight is Inf 467s List of 1 467s $ m1: num NA 467s Last weight is NA 467s List of 1 467s $ m1: num NA 467s na.rm: TRUE 467s Weights are not specified (all are 1) 467s List of 1 467s $ m1: num 6.22 467s All weights are 1 467s List of 1 467s $ m1: num 6.22 467s First weight is 5 467s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 467s List of 1 467s $ m1: num 6.32 467s All weights are 0 467s List of 1 467s $ m1: num NA 467s First weight is 8.5 467s List of 1 467s $ m1: num NA 467s First weight is Inf 467s List of 1 467s $ m1: num NA 467s Last weight is Inf 467s List of 1 467s $ m1: num NA 467s Last weight is NA 467s List of 1 467s $ m1: num NA 467s weightedVar()...DONE 467s weightedSd()... 467s mode: integer 467s int [1:15] 2 0 0 2 4 4 -4 4 4 4 ... 467s add_na: FALSE 467s int [1:15] 2 0 0 2 4 4 -4 4 4 4 ... 467s na.rm: FALSE 467s Weights are not specified (all are 1) 467s List of 1 467s $ m1: num 2.44 467s All weights are 1 467s List of 1 467s $ m1: num 2.44 467s First weight is 5 467s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 467s List of 1 467s $ m1: num 2.16 467s All weights are 0 467s List of 1 467s $ m1: num NA 467s First weight is 8.5 467s List of 1 467s $ m1: num NA 467s First weight is Inf 467s List of 1 467s $ m1: num NA 467s Last weight is Inf 467s List of 1 467s $ m1: num NA 467s Last weight is NA 467s List of 1 467s $ m1: num NA 467s na.rm: TRUE 467s Weights are not specified (all are 1) 467s List of 1 467s $ m1: num 2.44 467s All weights are 1 467s List of 1 467s $ m1: num 2.44 467s First weight is 5 467s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 467s List of 1 467s $ m1: num 2.16 467s All weights are 0 467s List of 1 467s $ m1: num NA 467s First weight is 8.5 467s List of 1 467s $ m1: num NA 467s First weight is Inf 467s List of 1 467s $ m1: num NA 467s Last weight is Inf 467s List of 1 467s $ m1: num NA 467s Last weight is NA 467s List of 1 467s $ m1: num NA 467s add_na: TRUE 467s int [1:15] 2 0 0 2 NA 4 NA 4 4 4 ... 467s na.rm: FALSE 467s Weights are not specified (all are 1) 467s List of 1 467s $ m1: num NA 467s All weights are 1 467s List of 1 467s $ m1: num NA 467s First weight is 5 467s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 467s List of 1 467s $ m1: num NA 467s All weights are 0 467s List of 1 467s $ m1: num NA 467s First weight is 8.5 467s List of 1 467s $ m1: num NA 467s First weight is Inf 467s List of 1 467s $ m1: num NA 467s Last weight is Inf 467s List of 1 467s $ m1: num NA 467s Last weight is NA 467s List of 1 467s $ m1: num NA 467s na.rm: TRUE 467s Weights are not specified (all are 1) 467s List of 1 467s $ m1: num 1.95 467s All weights are 1 467s List of 1 467s $ m1: num 1.95 467s First weight is 5 467s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 467s List of 1 467s $ m1: num 1.69 467s All weights are 0 467s List of 1 467s $ m1: num NA 467s First weight is 8.5 467s List of 1 467s $ m1: num NA 467s First weight is Inf 467s List of 1 467s $ m1: num NA 467s Last weight is Inf 467s List of 1 467s $ m1: num NA 467s Last weight is NA 467s List of 1 467s $ m1: num NA 467s mode: double 467s num [1:15] 0.867 1.106 -1.974 2.527 4.047 ... 467s add_na: FALSE 467s num [1:15] 0.867 1.106 -1.974 2.527 4.047 ... 467s na.rm: FALSE 467s Weights are not specified (all are 1) 467s List of 1 467s $ m1: num 2.5 467s All weights are 1 467s List of 1 467s $ m1: num 2.5 467s First weight is 5 467s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 467s List of 1 467s $ m1: num 2.21 467s All weights are 0 467s List of 1 467s $ m1: num NA 467s First weight is 8.5 467s List of 1 467s $ m1: num NA 467s First weight is Inf 467s List of 1 467s $ m1: num NA 467s Last weight is Inf 467s List of 1 467s $ m1: num NA 467s Last weight is NA 467s List of 1 467s $ m1: num NA 467s na.rm: TRUE 467s Weights are not specified (all are 1) 467s List of 1 467s $ m1: num 2.5 467s All weights are 1 467s List of 1 467s $ m1: num 2.5 467s First weight is 5 467s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 467s List of 1 467s $ m1: num 2.21 467s All weights are 0 467s List of 1 467s $ m1: num NA 467s First weight is 8.5 467s List of 1 467s $ m1: num NA 467s First weight is Inf 467s List of 1 467s $ m1: num NA 467s Last weight is Inf 467s List of 1 467s $ m1: num NA 467s Last weight is NA 467s List of 1 467s $ m1: num NA 467s add_na: TRUE 467s num [1:15] 0.867 1.106 -1.974 2.527 NA ... 467s na.rm: FALSE 467s Weights are not specified (all are 1) 467s List of 1 467s $ m1: num NA 467s All weights are 1 467s List of 1 467s $ m1: num NA 467s First weight is 5 467s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 467s List of 1 467s $ m1: num NA 467s All weights are 0 467s List of 1 467s $ m1: num NA 467s First weight is 8.5 467s List of 1 467s $ m1: num NA 467s First weight is Inf 467s List of 1 467s $ m1: num NA 467s Last weight is Inf 467s List of 1 467s $ m1: num NA 467s Last weight is NA 467s List of 1 467s $ m1: num NA 467s na.rm: TRUE 467s Weights are not specified (all are 1) 467s List of 1 467s $ m1: num 2.5 467s All weights are 1 467s List of 1 467s $ m1: num 2.5 467s First weight is 5 467s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 467s List of 1 467s $ m1: num 2.17 467s All weights are 0 467s List of 1 467s $ m1: num NA 467s First weight is 8.5 467s List of 1 467s $ m1: num NA 467s First weight is Inf 467s List of 1 467s $ m1: num NA 467s Last weight is Inf 467s List of 1 467s $ m1: num NA 467s Last weight is NA 467s List of 1 467s $ m1: num NA 467s weightedSd()...DONE 467s weightedMad()... 467s mode: integer 467s int [1:15] -4 -4 0 1 2 2 -2 -3 0 0 ... 467s add_na: FALSE 467s int [1:15] -4 -4 0 1 2 2 -2 -3 0 0 ... 467s na.rm: FALSE 467s Weights are not specified (all are 1) 467s List of 1 467s $ m1: num 2.97 467s All weights are 1 467s List of 1 467s $ m1: num 2.97 467s First weight is 5 467s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 467s List of 1 467s $ m1: num 2.97 467s All weights are 0 467s List of 1 467s $ m1: int NA 467s First weight is 8.5 467s List of 1 467s $ m1: int 0 467s First weight is Inf 467s List of 1 467s $ m1: int 0 467s Last weight is Inf 467s List of 1 467s $ m1: int 0 467s Last weight is NA 467s List of 1 467s $ m1: int NA 467s na.rm: TRUE 467s Weights are not specified (all are 1) 467s List of 1 467s $ m1: num 2.97 467s All weights are 1 467s List of 1 467s $ m1: num 2.97 467s First weight is 5 467s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 467s List of 1 467s $ m1: num 2.97 467s All weights are 0 467s List of 1 467s $ m1: int NA 467s First weight is 8.5 467s List of 1 467s $ m1: int 0 467s First weight is Inf 467s List of 1 467s $ m1: int 0 467s Last weight is Inf 467s List of 1 467s $ m1: int 0 467s Last weight is NA 467s List of 1 467s $ m1: int NA 467s add_na: TRUE 467s int [1:15] -4 -4 0 1 NA 2 NA -3 0 0 ... 467s na.rm: FALSE 467s Weights are not specified (all are 1) 467s List of 1 467s $ m1: num NA 467s All weights are 1 467s List of 1 467s $ m1: int NA 467s First weight is 5 467s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 467s List of 1 467s $ m1: int NA 467s All weights are 0 467s List of 1 467s $ m1: int NA 467s First weight is 8.5 467s List of 1 467s $ m1: int 0 467s First weight is Inf 467s List of 1 467s $ m1: int 0 467s Last weight is Inf 467s List of 1 467s $ m1: int 0 467s Last weight is NA 467s List of 1 467s $ m1: int NA 467s na.rm: TRUE 467s Weights are not specified (all are 1) 467s List of 1 467s $ m1: num 2.97 467s All weights are 1 467s List of 1 467s $ m1: num 2.97 467s First weight is 5 467s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 467s List of 1 467s $ m1: num 2.97 467s All weights are 0 467s List of 1 467s $ m1: int NA 467s First weight is 8.5 467s List of 1 467s $ m1: int 0 467s First weight is Inf 467s List of 1 467s $ m1: int 0 467s Last weight is Inf 467s List of 1 467s $ m1: int 0 467s Last weight is NA 467s List of 1 467s $ m1: int NA 467s mode: double 467s num [1:15] -2.183343 -0.000346 -0.625159 3.359788 -0.927155 ... 467s add_na: FALSE 467s num [1:15] -2.183343 -0.000346 -0.625159 3.359788 -0.927155 ... 467s na.rm: FALSE 467s Weights are not specified (all are 1) 467s List of 1 467s $ m1: num 3.4 467s All weights are 1 467s List of 1 467s $ m1: num 3.4 467s First weight is 5 467s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 467s List of 1 467s $ m1: num 2.58 467s All weights are 0 467s List of 1 467s $ m1: num NA 467s First weight is 8.5 467s List of 1 467s $ m1: num 0 467s First weight is Inf 467s List of 1 467s $ m1: num 0 467s Last weight is Inf 467s List of 1 467s $ m1: num 0 467s Last weight is NA 467s List of 1 467s $ m1: num NA 467s na.rm: TRUE 467s Weights are not specified (all are 1) 467s List of 1 467s $ m1: num 3.4 467s All weights are 1 467s List of 1 467s $ m1: num 3.4 467s First weight is 5 467s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 467s List of 1 467s $ m1: num 2.58 467s All weights are 0 467s List of 1 467s $ m1: num NA 467s First weight is 8.5 467s List of 1 467s $ m1: num 0 467s First weight is Inf 467s List of 1 467s $ m1: num 0 467s Last weight is Inf 467s List of 1 467s $ m1: num 0 467s Last weight is NA 467s List of 1 467s $ m1: num NA 467s add_na: TRUE 467s num [1:15] -2.183343 -0.000346 -0.625159 3.359788 NA ... 467s na.rm: FALSE 467s Weights are not specified (all are 1) 467s List of 1 467s $ m1: num NA 467s All weights are 1 467s List of 1 467s $ m1: num NA 467s First weight is 5 467s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 467s List of 1 467s $ m1: num NA 467s All weights are 0 467s List of 1 467s $ m1: num NA 467s First weight is 8.5 467s List of 1 467s $ m1: num 0 467s First weight is Inf 467s List of 1 467s $ m1: num 0 467s Last weight is Inf 467s List of 1 467s $ m1: num 0 467s Last weight is NA 467s List of 1 467s $ m1: num NA 467s na.rm: TRUE 467s Weights are not specified (all are 1) 467s List of 1 467s $ m1: num 3.33 467s All weights are 1 467s List of 1 467s $ m1: num 3.33 467s First weight is 5 467s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 467s List of 1 467s $ m1: num 3.3 467s All weights are 0 467s List of 1 467s $ m1: num NA 467s First weight is 8.5 467s List of 1 467s $ m1: num 0 467s First weight is Inf 467s List of 1 467s $ m1: num 0 467s Last weight is Inf 467s List of 1 467s $ m1: num 0 467s Last weight is NA 467s List of 1 467s $ m1: num NA 467s weightedMad()...DONE 467s > 467s 467s R version 4.4.3 (2025-02-28) -- "Trophy Case" 467s Copyright (C) 2025 The R Foundation for Statistical Computing 467s Platform: arm-unknown-linux-gnueabihf (32-bit) 467s 467s R is free software and comes with ABSOLUTELY NO WARRANTY. 467s You are welcome to redistribute it under certain conditions. 467s Type 'license()' or 'licence()' for distribution details. 467s 467s R is a collaborative project with many contributors. 467s Type 'contributors()' for more information and 467s 'citation()' on how to cite R or R packages in publications. 467s 467s Type 'demo()' for some demos, 'help()' for on-line help, or 467s 'help.start()' for an HTML browser interface to help. 467s Type 'q()' to quit R. 467s 467s > library("matrixStats") 467s > 467s > fcns <- list( 467s + weightedVar = weightedVar, 467s + weightedSd = weightedSd, 467s + weightedMad = weightedMad 467s + ) 467s > 467s > 467s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 467s > # Subsetted tests 467s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 467s > source("utils/validateIndicesFramework.R") 467s > for (name in names(fcns)) { 467s + cat(sprintf("subsetted tests on %s()...\n", name)) 467s + fcn <- fcns[[name]] 467s + 467s + for (mode in c("numeric", "integer")) { 467s + x <- runif(6, min = -6, max = 6) 467s + w <- runif(6, min = 0, max = 6) 467s + storage.mode(x) <- mode 467s + storage.mode(w) <- mode 467s + if (mode == "numeric") w[1] <- Inf 467s + 467s + for (idxs in index_cases) { 467s + validateIndicesTestVector_w(x, w, idxs, 467s + ftest = fcn, fsure = fcn, 467s + na.rm = TRUE) 467s + validateIndicesTestVector_w(x, w, idxs, 467s + ftest = fcn, fsure = fcn, 467s + na.rm = FALSE) 467s + } 467s + } 467s + cat(sprintf("%s()...DONE\n", name)) 467s + } 467s subsetted tests on weightedVar()... 467s weightedVar()...DONE 467s subsetted tests on weightedSd()... 467s weightedSd()...DONE 467s subsetted tests on weightedMad()... 467s weightedMad()...DONE 467s > 467s 467s R version 4.4.3 (2025-02-28) -- "Trophy Case" 467s Copyright (C) 2025 The R Foundation for Statistical Computing 467s Platform: arm-unknown-linux-gnueabihf (32-bit) 467s 467s R is free software and comes with ABSOLUTELY NO WARRANTY. 467s You are welcome to redistribute it under certain conditions. 467s Type 'license()' or 'licence()' for distribution details. 467s 467s R is a collaborative project with many contributors. 467s Type 'contributors()' for more information and 467s 'citation()' on how to cite R or R packages in publications. 467s 467s Type 'demo()' for some demos, 'help()' for on-line help, or 467s 'help.start()' for an HTML browser interface to help. 467s Type 'q()' to quit R. 467s 467s > library("matrixStats") 467s > 467s > x_OP_y_R <- function(x, y, OP, na.rm = FALSE) { 467s + if (na.rm) { 467s + xnok <- is.na(x) 467s + ynok <- is.na(y) 467s + anok <- xnok & ynok 467s + unit <- switch(OP, 467s + "+" = 0, 467s + "-" = NA_real_, 467s + "*" = 1, 467s + "/" = NA_real_, 467s + stop("Unknown 'OP' operator: ", OP) 467s + ) 467s + x[xnok] <- unit 467s + y[ynok] <- unit 467s + } 467s + 467s + ans <- switch(OP, 467s + "+" = x + y, 467s + "-" = x - y, 467s + "*" = x * y, 467s + "/" = x / y, 467s + stop("Unknown 'OP' operator: ", OP) 467s + ) 467s + 467s + if (na.rm) { 467s + ans[anok] <- NA_real_ 467s + } 467s + 467s + ans 467s + } # x_OP_y_R() 467s > 467s > 467s > 467s > t_tx_OP_y_R <- function(x, y, OP, na.rm = FALSE) { 467s + t(x_OP_y_R(x = t(x), y = y, OP = OP, na.rm = na.rm)) 467s + } 467s > 467s > 467s > 467s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 467s > # No missing values 467s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 467s > x <- matrix(1:16, nrow = 4, ncol = 4) 467s > y <- 1:nrow(x) 467s > storage.mode(y) <- storage.mode(x) 467s > 467s > for (OP in c("+", "-", "*", "/")) { 467s + for (na.rm in c(FALSE, TRUE)) { 467s + cat(sprintf("OP = '%s', na.rm = %s\n", OP, na.rm)) 467s + 467s + a0 <- x_OP_y_R(x, y, OP, na.rm = na.rm) 467s + a1 <- x_OP_y(x, y, OP, na.rm = na.rm) 467s + str(a1) 467s + stopifnot(all.equal(a1, a0)) 467s + 467s + b0 <- t_tx_OP_y_R(x, y, OP, na.rm = na.rm) 467s + b1 <- t_tx_OP_y(x, y, OP, na.rm = na.rm) 467s + str(b1) 467s + stopifnot(all.equal(b1, b0)) 467s + } 467s + } 467s OP = '+', na.rm = FALSE 467s int [1:4, 1:4] 2 4 6 8 6 8 10 12 10 12 ... 467s int [1:4, 1:4] 2 3 4 5 7 8 9 10 12 13 ... 467s OP = '+', na.rm = TRUE 467s int [1:4, 1:4] 2 4 6 8 6 8 10 12 10 12 ... 467s int [1:4, 1:4] 2 3 4 5 7 8 9 10 12 13 ... 467s OP = '-', na.rm = FALSE 467s int [1:4, 1:4] 0 0 0 0 4 4 4 4 8 8 ... 467s int [1:4, 1:4] 0 1 2 3 3 4 5 6 6 7 ... 467s OP = '-', na.rm = TRUE 467s int [1:4, 1:4] 0 0 0 0 4 4 4 4 8 8 ... 467s int [1:4, 1:4] 0 1 2 3 3 4 5 6 6 7 ... 467s OP = '*', na.rm = FALSE 467s int [1:4, 1:4] 1 4 9 16 5 12 21 32 9 20 ... 467s int [1:4, 1:4] 1 2 3 4 10 12 14 16 27 30 ... 467s OP = '*', na.rm = TRUE 467s int [1:4, 1:4] 1 4 9 16 5 12 21 32 9 20 ... 467s int [1:4, 1:4] 1 2 3 4 10 12 14 16 27 30 ... 467s OP = '/', na.rm = FALSE 467s num [1:4, 1:4] 1 1 1 1 5 ... 467s num [1:4, 1:4] 1 2 3 4 2.5 ... 467s OP = '/', na.rm = TRUE 467s num [1:4, 1:4] 1 1 1 1 5 ... 467s num [1:4, 1:4] 1 2 3 4 2.5 ... 467s > 467s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 467s > # Missing values in x, y, or both. 467s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 467s > for (which in c("x", "y", "both")) { 467s + x <- matrix(1:16, nrow = 4, ncol = 4) 467s + y <- 1:nrow(x) 467s + storage.mode(y) <- storage.mode(x) 467s + 467s + if (which == "x") { 467s + x[3:6] <- NA_real_ 467s + } else if (which == "y") { 467s + y[c(1, 3)] <- NA_real_ 467s + } else if (which == "both") { 467s + x[3:6] <- NA_real_ 467s + y[c(1, 3)] <- NA_real_ 467s + } 467s + 467s + for (OP in c("+", "-", "*", "/")) { 467s + for (na.rm in c(FALSE, TRUE)) { 467s + cat(sprintf("OP = '%s', na.rm = %s\n", OP, na.rm)) 467s + a0 <- x_OP_y_R(x, y, OP, na.rm = na.rm) 467s + a1 <- x_OP_y(x, y, OP, na.rm = na.rm) 467s + str(a1) 467s + stopifnot(all.equal(a1, a0)) 467s + 467s + b0 <- t_tx_OP_y_R(x, y, OP, na.rm = na.rm) 467s + b1 <- t_tx_OP_y(x, y, OP, na.rm = na.rm) 467s + str(b1) 467s + stopifnot(all.equal(b1, b0)) 467s + } 467s + } 467s + } 467s OP = '+', na.rm = FALSE 467s num [1:4, 1:4] 2 4 NA NA NA NA 10 12 10 12 ... 467s num [1:4, 1:4] 2 3 NA NA NA NA 9 10 12 13 ... 467s OP = '+', na.rm = TRUE 467s num [1:4, 1:4] 2 4 3 4 1 2 10 12 10 12 ... 467s num [1:4, 1:4] 2 3 1 1 2 2 9 10 12 13 ... 467s OP = '-', na.rm = FALSE 467s num [1:4, 1:4] 0 0 NA NA NA NA 4 4 8 8 ... 467s num [1:4, 1:4] 0 1 NA NA NA NA 5 6 6 7 ... 467s OP = '-', na.rm = TRUE 467s num [1:4, 1:4] 0 0 NA NA NA NA 4 4 8 8 ... 467s num [1:4, 1:4] 0 1 NA NA NA NA 5 6 6 7 ... 467s OP = '*', na.rm = FALSE 467s num [1:4, 1:4] 1 4 NA NA NA NA 21 32 9 20 ... 467s num [1:4, 1:4] 1 2 NA NA NA NA 14 16 27 30 ... 467s OP = '*', na.rm = TRUE 467s num [1:4, 1:4] 1 4 3 4 1 2 21 32 9 20 ... 467s num [1:4, 1:4] 1 2 1 1 2 2 14 16 27 30 ... 467s OP = '/', na.rm = FALSE 467s num [1:4, 1:4] 1 1 NA NA NA ... 467s num [1:4, 1:4] 1 2 NA NA NA ... 467s OP = '/', na.rm = TRUE 467s num [1:4, 1:4] 1 1 NA NA NA ... 467s num [1:4, 1:4] 1 2 NA NA NA ... 467s OP = '+', na.rm = FALSE 467s num [1:4, 1:4] NA 4 NA 8 NA 8 NA 12 NA 12 ... 467s num [1:4, 1:4] NA NA NA NA 7 8 9 10 NA NA ... 467s OP = '+', na.rm = TRUE 467s num [1:4, 1:4] 1 4 3 8 5 8 7 12 9 12 ... 467s num [1:4, 1:4] 1 2 3 4 7 8 9 10 9 10 ... 467s OP = '-', na.rm = FALSE 467s num [1:4, 1:4] NA 0 NA 0 NA 4 NA 4 NA 8 ... 467s num [1:4, 1:4] NA NA NA NA 3 4 5 6 NA NA ... 467s OP = '-', na.rm = TRUE 467s num [1:4, 1:4] NA 0 NA 0 NA 4 NA 4 NA 8 ... 467s num [1:4, 1:4] NA NA NA NA 3 4 5 6 NA NA ... 467s OP = '*', na.rm = FALSE 467s num [1:4, 1:4] NA 4 NA 16 NA 12 NA 32 NA 20 ... 467s num [1:4, 1:4] NA NA NA NA 10 12 14 16 NA NA ... 467s OP = '*', na.rm = TRUE 467s num [1:4, 1:4] 1 4 3 16 5 12 7 32 9 20 ... 467s num [1:4, 1:4] 1 2 3 4 10 12 14 16 9 10 ... 467s OP = '/', na.rm = FALSE 467s num [1:4, 1:4] NA 1 NA 1 NA 3 NA 2 NA 5 ... 468s num [1:4, 1:4] NA NA NA NA 2.5 3 3.5 4 NA NA ... 468s OP = '/', na.rm = TRUE 468s num [1:4, 1:4] NA 1 NA 1 NA 3 NA 2 NA 5 ... 468s num [1:4, 1:4] NA NA NA NA 2.5 3 3.5 4 NA NA ... 468s OP = '+', na.rm = FALSE 468s num [1:4, 1:4] NA 4 NA NA NA NA NA 12 NA 12 ... 468s num [1:4, 1:4] NA NA NA NA NA NA 9 10 NA NA ... 468s OP = '+', na.rm = TRUE 468s num [1:4, 1:4] 1 4 NA 4 NA 2 7 12 9 12 ... 468s num [1:4, 1:4] 1 2 NA NA 2 2 9 10 9 10 ... 468s OP = '-', na.rm = FALSE 468s num [1:4, 1:4] NA 0 NA NA NA NA NA 4 NA 8 ... 468s num [1:4, 1:4] NA NA NA NA NA NA 5 6 NA NA ... 468s OP = '-', na.rm = TRUE 468s num [1:4, 1:4] NA 0 NA NA NA NA NA 4 NA 8 ... 468s num [1:4, 1:4] NA NA NA NA NA NA 5 6 NA NA ... 468s OP = '*', na.rm = FALSE 468s num [1:4, 1:4] NA 4 NA NA NA NA NA 32 NA 20 ... 468s num [1:4, 1:4] NA NA NA NA NA NA 14 16 NA NA ... 468s OP = '*', na.rm = TRUE 468s num [1:4, 1:4] 1 4 NA 4 NA 2 7 32 9 20 ... 468s num [1:4, 1:4] 1 2 NA NA 2 2 14 16 9 10 ... 468s OP = '/', na.rm = FALSE 468s num [1:4, 1:4] NA 1 NA NA NA NA NA 2 NA 5 ... 468s num [1:4, 1:4] NA NA NA NA NA NA 3.5 4 NA NA ... 468s OP = '/', na.rm = TRUE 468s num [1:4, 1:4] NA 1 NA NA NA NA NA 2 NA 5 ... 468s num [1:4, 1:4] NA NA NA NA NA NA 3.5 4 NA NA ... 468s > 468s > 468s > 468s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 468s > # Length differences 468s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 468s > x <- matrix(1:8, nrow = 2, ncol = 4) 468s > y <- 1:ncol(x) 468s > storage.mode(y) <- storage.mode(x) 468s > 468s > for (OP in c("+", "-", "*", "/")) { 468s + for (na.rm in c(FALSE, TRUE)) { 468s + cat(sprintf("OP = '%s', na.rm = %s\n", OP, na.rm)) 468s + 468s + a0 <- x_OP_y_R(x, y, OP, na.rm = na.rm) 468s + a1 <- x_OP_y(x, y, OP, na.rm = na.rm) 468s + str(a1) 468s + stopifnot(all.equal(a1, a0)) 468s + 468s + b0 <- t_tx_OP_y_R(x, y, OP, na.rm = na.rm) 468s + b1 <- t_tx_OP_y(x, y, OP, na.rm = na.rm) 468s + str(b1) 468s + stopifnot(all.equal(b1, b0)) 468s + } 468s + } 468s OP = '+', na.rm = FALSE 468s int [1:2, 1:4] 2 4 6 8 6 8 10 12 468s int [1:2, 1:4] 2 3 5 6 8 9 11 12 468s OP = '+', na.rm = TRUE 468s int [1:2, 1:4] 2 4 6 8 6 8 10 12 468s int [1:2, 1:4] 2 3 5 6 8 9 11 12 468s OP = '-', na.rm = FALSE 468s int [1:2, 1:4] 0 0 0 0 4 4 4 4 468s int [1:2, 1:4] 0 1 1 2 2 3 3 4 468s OP = '-', na.rm = TRUE 468s int [1:2, 1:4] 0 0 0 0 4 4 4 4 468s int [1:2, 1:4] 0 1 1 2 2 3 3 4 468s OP = '*', na.rm = FALSE 468s int [1:2, 1:4] 1 4 9 16 5 12 21 32 468s int [1:2, 1:4] 1 2 6 8 15 18 28 32 468s OP = '*', na.rm = TRUE 468s int [1:2, 1:4] 1 4 9 16 5 12 21 32 468s int [1:2, 1:4] 1 2 6 8 15 18 28 32 468s OP = '/', na.rm = FALSE 468s num [1:2, 1:4] 1 1 1 1 5 ... 468s num [1:2, 1:4] 1 2 1.5 2 1.67 ... 468s OP = '/', na.rm = TRUE 468s num [1:2, 1:4] 1 1 1 1 5 ... 468s num [1:2, 1:4] 1 2 1.5 2 1.67 ... 468s > 468s > 468s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 468s > # All missing values 468s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 468s > xs <- list( 468s + A = matrix(1:2, nrow = 2, ncol = 2), 468s + B = matrix(NA_integer_, nrow = 2, ncol = 2) 468s + ) 468s > ys <- list( 468s + A = 1L, 468s + B = NA_integer_ 468s + ) 468s > 468s > for (x in xs) { 468s + for (y in ys) { 468s + for (mode in c("logical", "integer", "double")) { 468s + storage.mode(x) <- mode 468s + storage.mode(y) <- mode 468s + str(list(x = x, y = y)) 468s + 468s + for (OP in c("+", "-", "*", "/")) { 468s + for (na.rm in c(FALSE, TRUE)) { 468s + cat(sprintf("mode = '%s', OP = '%s', na.rm = %s\n", mode, OP, na.rm)) 468s + suppressWarnings({ 468s + z0 <- x_OP_y_R(x, y, OP, na.rm = na.rm) 468s + z <- x_OP_y(x, y, OP, na.rm = na.rm) 468s + }) 468s + str(z) 468s + stopifnot(all.equal(z, z0)) 468s + } 468s + } 468s + } # for (mode ...) 468s + } # for (y ...) 468s + } # for (x ...) 468s List of 2 468s $ x: logi [1:2, 1:2] TRUE TRUE TRUE TRUE 468s $ y: logi TRUE 468s mode = 'logical', OP = '+', na.rm = FALSE 468s int [1:2, 1:2] 2 2 2 2 468s mode = 'logical', OP = '+', na.rm = TRUE 468s int [1:2, 1:2] 2 2 2 2 468s mode = 'logical', OP = '-', na.rm = FALSE 468s int [1:2, 1:2] 0 0 0 0 468s mode = 'logical', OP = '-', na.rm = TRUE 468s int [1:2, 1:2] 0 0 0 0 468s mode = 'logical', OP = '*', na.rm = FALSE 468s int [1:2, 1:2] 1 1 1 1 468s mode = 'logical', OP = '*', na.rm = TRUE 468s int [1:2, 1:2] 1 1 1 1 468s mode = 'logical', OP = '/', na.rm = FALSE 468s num [1:2, 1:2] 1 1 1 1 468s mode = 'logical', OP = '/', na.rm = TRUE 468s num [1:2, 1:2] 1 1 1 1 468s List of 2 468s $ x: int [1:2, 1:2] 1 1 1 1 468s $ y: int 1 468s mode = 'integer', OP = '+', na.rm = FALSE 468s int [1:2, 1:2] 2 2 2 2 468s mode = 'integer', OP = '+', na.rm = TRUE 468s int [1:2, 1:2] 2 2 2 2 468s mode = 'integer', OP = '-', na.rm = FALSE 468s int [1:2, 1:2] 0 0 0 0 468s mode = 'integer', OP = '-', na.rm = TRUE 468s int [1:2, 1:2] 0 0 0 0 468s mode = 'integer', OP = '*', na.rm = FALSE 468s int [1:2, 1:2] 1 1 1 1 468s mode = 'integer', OP = '*', na.rm = TRUE 468s int [1:2, 1:2] 1 1 1 1 468s mode = 'integer', OP = '/', na.rm = FALSE 468s num [1:2, 1:2] 1 1 1 1 468s mode = 'integer', OP = '/', na.rm = TRUE 468s num [1:2, 1:2] 1 1 1 1 468s List of 2 468s $ x: num [1:2, 1:2] 1 1 1 1 468s $ y: num 1 468s mode = 'double', OP = '+', na.rm = FALSE 468s num [1:2, 1:2] 2 2 2 2 468s mode = 'double', OP = '+', na.rm = TRUE 468s num [1:2, 1:2] 2 2 2 2 468s mode = 'double', OP = '-', na.rm = FALSE 468s num [1:2, 1:2] 0 0 0 0 468s mode = 'double', OP = '-', na.rm = TRUE 468s num [1:2, 1:2] 0 0 0 0 468s mode = 'double', OP = '*', na.rm = FALSE 468s num [1:2, 1:2] 1 1 1 1 468s mode = 'double', OP = '*', na.rm = TRUE 468s num [1:2, 1:2] 1 1 1 1 468s mode = 'double', OP = '/', na.rm = FALSE 468s num [1:2, 1:2] 1 1 1 1 468s mode = 'double', OP = '/', na.rm = TRUE 468s num [1:2, 1:2] 1 1 1 1 468s List of 2 468s $ x: logi [1:2, 1:2] TRUE TRUE TRUE TRUE 468s $ y: logi NA 468s mode = 'logical', OP = '+', na.rm = FALSE 468s int [1:2, 1:2] NA NA NA NA 468s mode = 'logical', OP = '+', na.rm = TRUE 468s int [1:2, 1:2] 1 1 1 1 468s mode = 'logical', OP = '-', na.rm = FALSE 468s int [1:2, 1:2] NA NA NA NA 468s mode = 'logical', OP = '-', na.rm = TRUE 468s int [1:2, 1:2] NA NA NA NA 468s mode = 'logical', OP = '*', na.rm = FALSE 468s int [1:2, 1:2] NA NA NA NA 468s mode = 'logical', OP = '*', na.rm = TRUE 468s int [1:2, 1:2] 1 1 1 1 468s mode = 'logical', OP = '/', na.rm = FALSE 468s num [1:2, 1:2] NA NA NA NA 468s mode = 'logical', OP = '/', na.rm = TRUE 468s num [1:2, 1:2] NA NA NA NA 468s List of 2 468s $ x: int [1:2, 1:2] 1 1 1 1 468s $ y: int NA 468s mode = 'integer', OP = '+', na.rm = FALSE 468s int [1:2, 1:2] NA NA NA NA 468s mode = 'integer', OP = '+', na.rm = TRUE 468s int [1:2, 1:2] 1 1 1 1 468s mode = 'integer', OP = '-', na.rm = FALSE 468s int [1:2, 1:2] NA NA NA NA 468s mode = 'integer', OP = '-', na.rm = TRUE 468s int [1:2, 1:2] NA NA NA NA 468s mode = 'integer', OP = '*', na.rm = FALSE 468s int [1:2, 1:2] NA NA NA NA 468s mode = 'integer', OP = '*', na.rm = TRUE 468s int [1:2, 1:2] 1 1 1 1 468s mode = 'integer', OP = '/', na.rm = FALSE 468s num [1:2, 1:2] NA NA NA NA 468s mode = 'integer', OP = '/', na.rm = TRUE 468s num [1:2, 1:2] NA NA NA NA 468s List of 2 468s $ x: num [1:2, 1:2] 1 1 1 1 468s $ y: num NA 468s mode = 'double', OP = '+', na.rm = FALSE 468s num [1:2, 1:2] NA NA NA NA 468s mode = 'double', OP = '+', na.rm = TRUE 468s num [1:2, 1:2] 1 1 1 1 468s mode = 'double', OP = '-', na.rm = FALSE 468s num [1:2, 1:2] NA NA NA NA 468s mode = 'double', OP = '-', na.rm = TRUE 468s num [1:2, 1:2] NA NA NA NA 468s mode = 'double', OP = '*', na.rm = FALSE 468s num [1:2, 1:2] NA NA NA NA 468s mode = 'double', OP = '*', na.rm = TRUE 468s num [1:2, 1:2] 1 1 1 1 468s mode = 'double', OP = '/', na.rm = FALSE 468s num [1:2, 1:2] NA NA NA NA 468s mode = 'double', OP = '/', na.rm = TRUE 468s num [1:2, 1:2] NA NA NA NA 468s List of 2 468s $ x: logi [1:2, 1:2] NA NA NA NA 468s $ y: logi TRUE 468s mode = 'logical', OP = '+', na.rm = FALSE 468s int [1:2, 1:2] NA NA NA NA 468s mode = 'logical', OP = '+', na.rm = TRUE 468s int [1:2, 1:2] 1 1 1 1 468s mode = 'logical', OP = '-', na.rm = FALSE 468s int [1:2, 1:2] NA NA NA NA 468s mode = 'logical', OP = '-', na.rm = TRUE 468s int [1:2, 1:2] NA NA NA NA 468s mode = 'logical', OP = '*', na.rm = FALSE 468s int [1:2, 1:2] NA NA NA NA 468s mode = 'logical', OP = '*', na.rm = TRUE 468s int [1:2, 1:2] 1 1 1 1 468s mode = 'logical', OP = '/', na.rm = FALSE 468s num [1:2, 1:2] NA NA NA NA 468s mode = 'logical', OP = '/', na.rm = TRUE 468s num [1:2, 1:2] NA NA NA NA 468s List of 2 468s $ x: int [1:2, 1:2] NA NA NA NA 468s $ y: int 1 468s mode = 'integer', OP = '+', na.rm = FALSE 468s int [1:2, 1:2] NA NA NA NA 468s mode = 'integer', OP = '+', na.rm = TRUE 468s int [1:2, 1:2] 1 1 1 1 468s mode = 'integer', OP = '-', na.rm = FALSE 468s int [1:2, 1:2] NA NA NA NA 468s mode = 'integer', OP = '-', na.rm = TRUE 468s int [1:2, 1:2] NA NA NA NA 468s mode = 'integer', OP = '*', na.rm = FALSE 468s int [1:2, 1:2] NA NA NA NA 468s mode = 'integer', OP = '*', na.rm = TRUE 468s int [1:2, 1:2] 1 1 1 1 468s mode = 'integer', OP = '/', na.rm = FALSE 468s num [1:2, 1:2] NA NA NA NA 468s mode = 'integer', OP = '/', na.rm = TRUE 468s num [1:2, 1:2] NA NA NA NA 468s List of 2 468s $ x: num [1:2, 1:2] NA NA NA NA 468s $ y: num 1 468s mode = 'double', OP = '+', na.rm = FALSE 468s num [1:2, 1:2] NA NA NA NA 468s mode = 'double', OP = '+', na.rm = TRUE 468s num [1:2, 1:2] 1 1 1 1 468s mode = 'double', OP = '-', na.rm = FALSE 468s num [1:2, 1:2] NA NA NA NA 468s mode = 'double', OP = '-', na.rm = TRUE 468s num [1:2, 1:2] NA NA NA NA 468s mode = 'double', OP = '*', na.rm = FALSE 468s num [1:2, 1:2] NA NA NA NA 468s mode = 'double', OP = '*', na.rm = TRUE 468s num [1:2, 1:2] 1 1 1 1 468s mode = 'double', OP = '/', na.rm = FALSE 468s num [1:2, 1:2] NA NA NA NA 468s mode = 'double', OP = '/', na.rm = TRUE 468s num [1:2, 1:2] NA NA NA NA 468s List of 2 468s $ x: logi [1:2, 1:2] NA NA NA NA 468s $ y: logi NA 468s mode = 'logical', OP = '+', na.rm = FALSE 468s int [1:2, 1:2] NA NA NA NA 468s mode = 'logical', OP = '+', na.rm = TRUE 468s int [1:2, 1:2] NA NA NA NA 468s mode = 'logical', OP = '-', na.rm = FALSE 468s int [1:2, 1:2] NA NA NA NA 468s mode = 'logical', OP = '-', na.rm = TRUE 468s int [1:2, 1:2] NA NA NA NA 468s mode = 'logical', OP = '*', na.rm = FALSE 468s int [1:2, 1:2] NA NA NA NA 468s mode = 'logical', OP = '*', na.rm = TRUE 468s int [1:2, 1:2] NA NA NA NA 468s mode = 'logical', OP = '/', na.rm = FALSE 468s num [1:2, 1:2] NA NA NA NA 468s mode = 'logical', OP = '/', na.rm = TRUE 468s num [1:2, 1:2] NA NA NA NA 468s List of 2 468s $ x: int [1:2, 1:2] NA NA NA NA 468s $ y: int NA 468s mode = 'integer', OP = '+', na.rm = FALSE 468s int [1:2, 1:2] NA NA NA NA 468s mode = 'integer', OP = '+', na.rm = TRUE 468s int [1:2, 1:2] NA NA NA NA 468s mode = 'integer', OP = '-', na.rm = FALSE 468s int [1:2, 1:2] NA NA NA NA 468s mode = 'integer', OP = '-', na.rm = TRUE 468s int [1:2, 1:2] NA NA NA NA 468s mode = 'integer', OP = '*', na.rm = FALSE 468s int [1:2, 1:2] NA NA NA NA 468s mode = 'integer', OP = '*', na.rm = TRUE 468s int [1:2, 1:2] NA NA NA NA 468s mode = 'integer', OP = '/', na.rm = FALSE 468s num [1:2, 1:2] NA NA NA NA 468s mode = 'integer', OP = '/', na.rm = TRUE 468s num [1:2, 1:2] NA NA NA NA 468s List of 2 468s $ x: num [1:2, 1:2] NA NA NA NA 468s $ y: num NA 468s mode = 'double', OP = '+', na.rm = FALSE 468s num [1:2, 1:2] NA NA NA NA 468s mode = 'double', OP = '+', na.rm = TRUE 468s num [1:2, 1:2] NA NA NA NA 468s mode = 'double', OP = '-', na.rm = FALSE 468s num [1:2, 1:2] NA NA NA NA 468s mode = 'double', OP = '-', na.rm = TRUE 468s num [1:2, 1:2] NA NA NA NA 468s mode = 'double', OP = '*', na.rm = FALSE 468s num [1:2, 1:2] NA NA NA NA 468s mode = 'double', OP = '*', na.rm = TRUE 468s num [1:2, 1:2] NA NA NA NA 468s mode = 'double', OP = '/', na.rm = FALSE 468s num [1:2, 1:2] NA NA NA NA 468s mode = 'double', OP = '/', na.rm = TRUE 468s num [1:2, 1:2] NA NA NA NA 468s > 468s 468s R version 4.4.3 (2025-02-28) -- "Trophy Case" 468s Copyright (C) 2025 The R Foundation for Statistical Computing 468s Platform: arm-unknown-linux-gnueabihf (32-bit) 468s 468s R is free software and comes with ABSOLUTELY NO WARRANTY. 468s You are welcome to redistribute it under certain conditions. 468s Type 'license()' or 'licence()' for distribution details. 468s 468s R is a collaborative project with many contributors. 468s Type 'contributors()' for more information and 468s 'citation()' on how to cite R or R packages in publications. 468s 468s Type 'demo()' for some demos, 'help()' for on-line help, or 468s 'help.start()' for an HTML browser interface to help. 468s Type 'q()' to quit R. 468s 468s > library("matrixStats") 468s > 468s > x_OP_y_R <- function(x, y, OP, na.rm = FALSE) { 468s + if (na.rm) { 468s + xnok <- is.na(x) 468s + ynok <- is.na(y) 468s + anok <- xnok & ynok 468s + unit <- switch(OP, 468s + "+" = 0, 468s + "-" = NA_real_, 468s + "*" = 1, 468s + "/" = NA_real_, 468s + stop("Unknown 'OP' operator: ", OP) 468s + ) 468s + x[xnok] <- unit 468s + y[ynok] <- unit 468s + } 468s + 468s + ans <- switch(OP, 468s + "+" = x + y, 468s + "-" = x - y, 468s + "*" = x * y, 468s + "/" = x / y, 468s + stop("Unknown 'OP' operator: ", OP) 468s + ) 468s + 468s + if (na.rm) { 468s + ans[anok] <- NA_real_ 468s + } 468s + 468s + ans 468s + } # x_OP_y_R() 468s > 468s > 468s > t_tx_OP_y_R <- function(x, y, OP, na.rm = FALSE) { 468s + t(x_OP_y_R(x = t(x), y = y, OP = OP, na.rm = na.rm)) 468s + } 468s > 468s > 468s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 468s > # Subsetted tests 468s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 468s > source("utils/validateIndicesFramework.R") 468s > for (OP in c("+", "-", "*", "/")) { 468s + for (mode in c("numeric", "integer", "logical")) { 468s + x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6L, ncol = 6L) 468s + y <- runif(6, min = 0, max = 6) 468s + storage.mode(x) <- mode 468s + storage.mode(y) <- mode 468s + if (mode == "numeric") y[1] <- Inf 468s + 468s + for (xrows in index_cases) { 468s + for (xcols in index_cases) { 468s + if (is.null(xrows)) xrows <- seq_len(nrow(x)) 468s + if (is.null(xcols)) xcols <- seq_len(ncol(x)) 468s + 468s + for (yidxs in list(xrows, xcols)) { 468s + for (na.rm in c(TRUE, FALSE)) { 468s + 468s + suppressWarnings({ 468s + actual <- tryCatch( 468s + x_OP_y(x, y, OP, xrows = xrows, xcols = xcols, yidxs = yidxs, 468s + na.rm = na.rm), 468s + error = function(c) "error" 468s + ) 468s + 468s + expect <- tryCatch( 468s + x_OP_y_R(x[xrows, xcols, drop = FALSE], y[yidxs], OP, 468s + na.rm = na.rm), 468s + error = function(c) "error" 468s + ) 468s + }) 468s + stopifnot(all.equal(as.vector(actual), as.vector(expect))) 468s + 468s + suppressWarnings({ 468s + actual <- tryCatch( 468s + t_tx_OP_y(x, y, OP, xrows = xrows, xcols = xcols, yidxs = yidxs, 468s + na.rm = na.rm), 468s + error = function(c) "error" 468s + ) 468s + 468s + expect <- tryCatch( 468s + t_tx_OP_y_R(x[xrows, xcols, drop = FALSE], y[yidxs], OP, 468s + na.rm = na.rm), 468s + error = function(c) "error" 468s + ) 468s + }) 468s + stopifnot(all.equal(as.vector(actual), as.vector(expect))) 468s + } 468s + } 468s + } 468s + } 468s + } 468s + } 475s > 475s 475s R version 4.4.3 (2025-02-28) -- "Trophy Case" 475s Copyright (C) 2025 The R Foundation for Statistical Computing 475s Platform: arm-unknown-linux-gnueabihf (32-bit) 475s 475s R is free software and comes with ABSOLUTELY NO WARRANTY. 475s You are welcome to redistribute it under certain conditions. 475s Type 'license()' or 'licence()' for distribution details. 475s 475s R is a collaborative project with many contributors. 475s Type 'contributors()' for more information and 475s 'citation()' on how to cite R or R packages in publications. 475s 475s Type 'demo()' for some demos, 'help()' for on-line help, or 475s 'help.start()' for an HTML browser interface to help. 475s Type 'q()' to quit R. 475s 475s > ## These tests need to be last of all tests, otherwise 475s > ## covr::package_coverage() gives an error. 475s > cat("1. Loading package\n") 475s 1. Loading package 475s > loadNamespace("matrixStats") 475s 475s > stopifnot("matrixStats" %in% loadedNamespaces()) 475s > 475s > cat("2. Unloading package\n") 475s 2. Unloading package 475s > unloadNamespace("matrixStats") 475s > stopifnot(!"matrixStats" %in% loadedNamespaces()) 475s > 475s > if (FALSE) { 475s + ## 'covr' gives "Error in library("matrixStats") : 475s + ## there is no package called 'matrixStats'" here, cf. 475s + ## https://travis-ci.org/HenrikBengtsson/matrixStats/builds/48015577 475s + 475s + cat("3. Attaching package\n") 475s + library("matrixStats") 475s + stopifnot("package:matrixStats" %in% search()) 475s + 475s + cat("4. Detaching package\n") 475s + detach("package:matrixStats") 475s + stopifnot(!"package:matrixStats" %in% search()) 475s + stopifnot("matrixStats" %in% loadedNamespaces()) 475s + 475s + cat("5. Unloading package\n") 475s + unloadNamespace("matrixStats") 475s + stopifnot(!"matrixStats" %in% loadedNamespaces()) 475s + 475s + cat("6. Attaching package (again)\n") 475s + library("matrixStats") 475s + stopifnot("package:matrixStats" %in% search()) 475s + 475s + cat("7. Detaching package (again)\n") 475s + detach("package:matrixStats") 475s + stopifnot(!"package:matrixStats" %in% search()) 475s + stopifnot("matrixStats" %in% loadedNamespaces()) 475s + } 475s > 475s > cat("7. DONE\n") 475s 7. DONE 475s > 475s autopkgtest [16:27:26]: test run-unit-test: -----------------------] 480s run-unit-test PASS 480s autopkgtest [16:27:31]: test run-unit-test: - - - - - - - - - - results - - - - - - - - - - 483s autopkgtest [16:27:34]: test pkg-r-autopkgtest: preparing testbed 506s autopkgtest [16:27:57]: testbed dpkg architecture: armhf 508s autopkgtest [16:27:59]: testbed apt version: 2.9.33 511s autopkgtest [16:28:02]: @@@@@@@@@@@@@@@@@@@@ test bed setup 513s autopkgtest [16:28:04]: testbed release detected to be: plucky 521s autopkgtest [16:28:12]: updating testbed package index (apt update) 523s Get:1 http://ftpmaster.internal/ubuntu plucky-proposed InRelease [126 kB] 523s Get:2 http://ftpmaster.internal/ubuntu plucky InRelease [257 kB] 524s Get:3 http://ftpmaster.internal/ubuntu plucky-updates InRelease [126 kB] 524s Get:4 http://ftpmaster.internal/ubuntu plucky-security InRelease [126 kB] 524s Get:5 http://ftpmaster.internal/ubuntu plucky-proposed/main Sources [99.7 kB] 524s Get:6 http://ftpmaster.internal/ubuntu plucky-proposed/multiverse Sources [15.8 kB] 524s Get:7 http://ftpmaster.internal/ubuntu plucky-proposed/universe Sources [379 kB] 525s Get:8 http://ftpmaster.internal/ubuntu plucky-proposed/main armhf Packages [114 kB] 525s Get:9 http://ftpmaster.internal/ubuntu plucky-proposed/main armhf c-n-f Metadata [1832 B] 525s Get:10 http://ftpmaster.internal/ubuntu plucky-proposed/restricted armhf c-n-f Metadata [116 B] 525s Get:11 http://ftpmaster.internal/ubuntu plucky-proposed/universe armhf Packages [312 kB] 525s Get:12 http://ftpmaster.internal/ubuntu plucky-proposed/universe armhf c-n-f Metadata [11.1 kB] 525s Get:13 http://ftpmaster.internal/ubuntu plucky-proposed/multiverse armhf Packages [3472 B] 525s Get:14 http://ftpmaster.internal/ubuntu plucky-proposed/multiverse armhf c-n-f Metadata [240 B] 525s Get:15 http://ftpmaster.internal/ubuntu plucky/universe Sources [21.0 MB] 548s Get:16 http://ftpmaster.internal/ubuntu plucky/multiverse Sources [299 kB] 549s Get:17 http://ftpmaster.internal/ubuntu plucky/main Sources [1394 kB] 550s Get:18 http://ftpmaster.internal/ubuntu plucky/main armhf Packages [1378 kB] 552s Get:19 http://ftpmaster.internal/ubuntu plucky/main armhf c-n-f Metadata [29.4 kB] 552s Get:20 http://ftpmaster.internal/ubuntu plucky/restricted armhf c-n-f Metadata [108 B] 552s Get:21 http://ftpmaster.internal/ubuntu plucky/universe armhf Packages [15.1 MB] 568s Get:22 http://ftpmaster.internal/ubuntu plucky/multiverse armhf Packages [172 kB] 570s Fetched 41.0 MB in 47s (878 kB/s) 571s Reading package lists... 577s autopkgtest [16:29:08]: upgrading testbed (apt dist-upgrade and autopurge) 578s Reading package lists... 579s Building dependency tree... 579s Reading state information... 579s Calculating upgrade...Starting pkgProblemResolver with broken count: 0 579s Starting 2 pkgProblemResolver with broken count: 0 579s Done 580s Entering ResolveByKeep 581s 581s Calculating upgrade... 581s The following packages will be upgraded: 581s libc-bin libc6 locales pinentry-curses python3-jinja2 sos strace 582s 7 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 582s Need to get 8683 kB of archives. 582s After this operation, 23.6 kB of additional disk space will be used. 582s Get:1 http://ftpmaster.internal/ubuntu plucky-proposed/main armhf libc6 armhf 2.41-1ubuntu2 [2932 kB] 585s Get:2 http://ftpmaster.internal/ubuntu plucky-proposed/main armhf libc-bin armhf 2.41-1ubuntu2 [545 kB] 586s Get:3 http://ftpmaster.internal/ubuntu plucky-proposed/main armhf locales all 2.41-1ubuntu2 [4246 kB] 590s Get:4 http://ftpmaster.internal/ubuntu plucky/main armhf strace armhf 6.13+ds-1ubuntu1 [445 kB] 591s Get:5 http://ftpmaster.internal/ubuntu plucky/main armhf pinentry-curses armhf 1.3.1-2ubuntu3 [40.6 kB] 591s Get:6 http://ftpmaster.internal/ubuntu plucky/main armhf python3-jinja2 all 3.1.5-2ubuntu1 [109 kB] 591s Get:7 http://ftpmaster.internal/ubuntu plucky/main armhf sos all 4.9.0-5 [365 kB] 592s Preconfiguring packages ... 592s Fetched 8683 kB in 10s (850 kB/s) 592s (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 ... 64655 files and directories currently installed.) 592s Preparing to unpack .../libc6_2.41-1ubuntu2_armhf.deb ... 593s Unpacking libc6:armhf (2.41-1ubuntu2) over (2.41-1ubuntu1) ... 593s Setting up libc6:armhf (2.41-1ubuntu2) ... 593s (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 ... 64655 files and directories currently installed.) 593s Preparing to unpack .../libc-bin_2.41-1ubuntu2_armhf.deb ... 593s Unpacking libc-bin (2.41-1ubuntu2) over (2.41-1ubuntu1) ... 593s Setting up libc-bin (2.41-1ubuntu2) ... 593s (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 ... 64655 files and directories currently installed.) 593s Preparing to unpack .../locales_2.41-1ubuntu2_all.deb ... 593s Unpacking locales (2.41-1ubuntu2) over (2.41-1ubuntu1) ... 594s Preparing to unpack .../strace_6.13+ds-1ubuntu1_armhf.deb ... 594s Unpacking strace (6.13+ds-1ubuntu1) over (6.11-0ubuntu1) ... 594s Preparing to unpack .../pinentry-curses_1.3.1-2ubuntu3_armhf.deb ... 594s Unpacking pinentry-curses (1.3.1-2ubuntu3) over (1.3.1-2ubuntu2) ... 594s Preparing to unpack .../python3-jinja2_3.1.5-2ubuntu1_all.deb ... 594s Unpacking python3-jinja2 (3.1.5-2ubuntu1) over (3.1.5-2) ... 594s Preparing to unpack .../archives/sos_4.9.0-5_all.deb ... 594s Unpacking sos (4.9.0-5) over (4.9.0-4) ... 595s Setting up sos (4.9.0-5) ... 595s Setting up pinentry-curses (1.3.1-2ubuntu3) ... 595s Setting up locales (2.41-1ubuntu2) ... 596s Generating locales (this might take a while)... 601s en_US.UTF-8... done 601s Generation complete. 601s Setting up python3-jinja2 (3.1.5-2ubuntu1) ... 601s Setting up strace (6.13+ds-1ubuntu1) ... 601s Processing triggers for man-db (2.13.0-1) ... 603s Processing triggers for systemd (257.3-1ubuntu3) ... 606s Reading package lists... 606s Building dependency tree... 606s Reading state information... 606s Starting pkgProblemResolver with broken count: 0 607s Starting 2 pkgProblemResolver with broken count: 0 607s Done 607s Solving dependencies... 608s 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 613s autopkgtest [16:29:44]: rebooting testbed after setup commands that affected boot 680s Reading package lists... 680s Building dependency tree... 680s Reading state information... 681s Starting pkgProblemResolver with broken count: 0 682s Starting 2 pkgProblemResolver with broken count: 0 682s Done 683s The following NEW packages will be installed: 683s build-essential cpp cpp-14 cpp-14-arm-linux-gnueabihf 683s cpp-arm-linux-gnueabihf dctrl-tools fontconfig fontconfig-config 683s fonts-dejavu-core fonts-dejavu-mono fonts-glyphicons-halflings fonts-mathjax 683s g++ g++-14 g++-14-arm-linux-gnueabihf g++-arm-linux-gnueabihf gcc gcc-14 683s gcc-14-arm-linux-gnueabihf gcc-arm-linux-gnueabihf gfortran gfortran-14 683s gfortran-14-arm-linux-gnueabihf gfortran-arm-linux-gnueabihf icu-devtools 683s libasan8 libblas-dev libblas3 libbz2-dev libc-dev-bin libc6-dev libcairo2 683s libcc1-0 libcrypt-dev libdatrie1 libdeflate-dev libdeflate0 libfontconfig1 683s libfreetype6 libgcc-14-dev libgfortran-14-dev libgfortran5 libgomp1 683s libgraphite2-3 libharfbuzz0b libice6 libicu-dev libisl23 libjbig0 683s libjpeg-dev libjpeg-turbo8 libjpeg-turbo8-dev libjpeg8 libjpeg8-dev 683s libjs-bootstrap libjs-highlight.js libjs-jquery libjs-jquery-datatables 683s libjs-mathjax liblapack-dev liblapack3 liblerc4 liblzma-dev libmpc3 684s libncurses-dev libpango-1.0-0 libpangocairo-1.0-0 libpangoft2-1.0-0 684s libpaper-utils libpaper2 libpcre2-16-0 libpcre2-32-0 libpcre2-dev 684s libpcre2-posix3 libpixman-1-0 libpkgconf3 libpng-dev libreadline-dev 684s libsharpyuv0 libsm6 libstdc++-14-dev libtcl8.6 libthai-data libthai0 684s libtiff6 libtirpc-dev libtk8.6 libubsan1 libwebp7 libxcb-render0 libxcb-shm0 684s libxft2 libxrender1 libxss1 libxt6t64 linux-libc-dev node-normalize.css 684s pkg-r-autopkgtest pkgconf pkgconf-bin r-base-core r-base-dev 684s r-cran-base64enc r-cran-cli r-cran-colorspace r-cran-commonmark 684s r-cran-evaluate r-cran-fansi r-cran-farver r-cran-ggplot2 r-cran-glue 684s r-cran-gtable r-cran-highr r-cran-isoband r-cran-knitr r-cran-labeling 684s r-cran-lattice r-cran-lifecycle r-cran-magrittr r-cran-markdown r-cran-mass 684s r-cran-matrix r-cran-matrixstats r-cran-mgcv r-cran-munsell r-cran-nlme 684s r-cran-pillar r-cran-pkgconfig r-cran-r6 r-cran-rcolorbrewer r-cran-rlang 684s r-cran-scales r-cran-tibble r-cran-utf8 r-cran-vctrs r-cran-viridislite 684s r-cran-withr r-cran-xfun r-cran-yaml rpcsvc-proto unzip x11-common xdg-utils 684s zip zlib1g-dev 684s 0 upgraded, 145 newly installed, 0 to remove and 0 not upgraded. 684s Need to get 157 MB of archives. 684s After this operation, 416 MB of additional disk space will be used. 684s Get:1 http://ftpmaster.internal/ubuntu plucky-proposed/main armhf libc-dev-bin armhf 2.41-1ubuntu2 [23.0 kB] 684s Get:2 http://ftpmaster.internal/ubuntu plucky/main armhf linux-libc-dev armhf 6.14.0-10.10 [1683 kB] 686s Get:3 http://ftpmaster.internal/ubuntu plucky/main armhf libcrypt-dev armhf 1:4.4.38-1 [120 kB] 686s Get:4 http://ftpmaster.internal/ubuntu plucky/main armhf rpcsvc-proto armhf 1.4.2-0ubuntu7 [62.2 kB] 686s Get:5 http://ftpmaster.internal/ubuntu plucky-proposed/main armhf libc6-dev armhf 2.41-1ubuntu2 [1396 kB] 687s Get:6 http://ftpmaster.internal/ubuntu plucky/main armhf libisl23 armhf 0.27-1 [546 kB] 688s Get:7 http://ftpmaster.internal/ubuntu plucky/main armhf libmpc3 armhf 1.3.1-1build2 [47.1 kB] 688s Get:8 http://ftpmaster.internal/ubuntu plucky/main armhf cpp-14-arm-linux-gnueabihf armhf 14.2.0-17ubuntu3 [9220 kB] 698s Get:9 http://ftpmaster.internal/ubuntu plucky/main armhf cpp-14 armhf 14.2.0-17ubuntu3 [1030 B] 698s Get:10 http://ftpmaster.internal/ubuntu plucky/main armhf cpp-arm-linux-gnueabihf armhf 4:14.2.0-1ubuntu1 [5578 B] 698s Get:11 http://ftpmaster.internal/ubuntu plucky/main armhf cpp armhf 4:14.2.0-1ubuntu1 [22.4 kB] 698s Get:12 http://ftpmaster.internal/ubuntu plucky/main armhf libcc1-0 armhf 15-20250222-0ubuntu1 [38.9 kB] 698s Get:13 http://ftpmaster.internal/ubuntu plucky/main armhf libgomp1 armhf 15-20250222-0ubuntu1 [128 kB] 698s Get:14 http://ftpmaster.internal/ubuntu plucky/main armhf libasan8 armhf 15-20250222-0ubuntu1 [2955 kB] 702s Get:15 http://ftpmaster.internal/ubuntu plucky/main armhf libubsan1 armhf 15-20250222-0ubuntu1 [1191 kB] 703s Get:16 http://ftpmaster.internal/ubuntu plucky/main armhf libgcc-14-dev armhf 14.2.0-17ubuntu3 [897 kB] 704s Get:17 http://ftpmaster.internal/ubuntu plucky/main armhf gcc-14-arm-linux-gnueabihf armhf 14.2.0-17ubuntu3 [18.0 MB] 723s Get:18 http://ftpmaster.internal/ubuntu plucky/main armhf gcc-14 armhf 14.2.0-17ubuntu3 [506 kB] 724s Get:19 http://ftpmaster.internal/ubuntu plucky/main armhf gcc-arm-linux-gnueabihf armhf 4:14.2.0-1ubuntu1 [1218 B] 724s Get:20 http://ftpmaster.internal/ubuntu plucky/main armhf gcc armhf 4:14.2.0-1ubuntu1 [5004 B] 724s Get:21 http://ftpmaster.internal/ubuntu plucky/main armhf libstdc++-14-dev armhf 14.2.0-17ubuntu3 [2573 kB] 726s Get:22 http://ftpmaster.internal/ubuntu plucky/main armhf g++-14-arm-linux-gnueabihf armhf 14.2.0-17ubuntu3 [10.5 MB] 738s Get:23 http://ftpmaster.internal/ubuntu plucky/main armhf g++-14 armhf 14.2.0-17ubuntu3 [21.8 kB] 738s Get:24 http://ftpmaster.internal/ubuntu plucky/main armhf g++-arm-linux-gnueabihf armhf 4:14.2.0-1ubuntu1 [966 B] 738s Get:25 http://ftpmaster.internal/ubuntu plucky/main armhf g++ armhf 4:14.2.0-1ubuntu1 [1084 B] 738s Get:26 http://ftpmaster.internal/ubuntu plucky/main armhf build-essential armhf 12.10ubuntu1 [4928 B] 738s Get:27 http://ftpmaster.internal/ubuntu plucky/main armhf dctrl-tools armhf 2.24-3build3 [94.7 kB] 738s Get:28 http://ftpmaster.internal/ubuntu plucky/main armhf libfreetype6 armhf 2.13.3+dfsg-1 [330 kB] 738s Get:29 http://ftpmaster.internal/ubuntu plucky/main armhf fonts-dejavu-mono all 2.37-8 [502 kB] 739s Get:30 http://ftpmaster.internal/ubuntu plucky/main armhf fonts-dejavu-core all 2.37-8 [835 kB] 740s Get:31 http://ftpmaster.internal/ubuntu plucky/main armhf fontconfig-config armhf 2.15.0-2ubuntu1 [37.5 kB] 740s Get:32 http://ftpmaster.internal/ubuntu plucky/main armhf libfontconfig1 armhf 2.15.0-2ubuntu1 [114 kB] 740s Get:33 http://ftpmaster.internal/ubuntu plucky/main armhf fontconfig armhf 2.15.0-2ubuntu1 [190 kB] 740s Get:34 http://ftpmaster.internal/ubuntu plucky/universe armhf fonts-glyphicons-halflings all 1.009~3.4.1+dfsg-3 [118 kB] 740s Get:35 http://ftpmaster.internal/ubuntu plucky/main armhf fonts-mathjax all 2.7.9+dfsg-1 [2208 kB] 743s Get:36 http://ftpmaster.internal/ubuntu plucky/main armhf libgfortran5 armhf 15-20250222-0ubuntu1 [330 kB] 743s Get:37 http://ftpmaster.internal/ubuntu plucky/main armhf libgfortran-14-dev armhf 14.2.0-17ubuntu3 [370 kB] 743s Get:38 http://ftpmaster.internal/ubuntu plucky/main armhf gfortran-14-arm-linux-gnueabihf armhf 14.2.0-17ubuntu3 [9763 kB] 754s Get:39 http://ftpmaster.internal/ubuntu plucky/main armhf gfortran-14 armhf 14.2.0-17ubuntu3 [13.6 kB] 754s Get:40 http://ftpmaster.internal/ubuntu plucky/main armhf gfortran-arm-linux-gnueabihf armhf 4:14.2.0-1ubuntu1 [1026 B] 754s Get:41 http://ftpmaster.internal/ubuntu plucky/main armhf gfortran armhf 4:14.2.0-1ubuntu1 [1166 B] 754s Get:42 http://ftpmaster.internal/ubuntu plucky/main armhf icu-devtools armhf 76.1-1ubuntu2 [206 kB] 754s Get:43 http://ftpmaster.internal/ubuntu plucky/main armhf libblas3 armhf 3.12.1-2 [132 kB] 754s Get:44 http://ftpmaster.internal/ubuntu plucky/main armhf libblas-dev armhf 3.12.1-2 [141 kB] 754s Get:45 http://ftpmaster.internal/ubuntu plucky/main armhf libbz2-dev armhf 1.0.8-6 [30.9 kB] 754s Get:46 http://ftpmaster.internal/ubuntu plucky/main armhf libpixman-1-0 armhf 0.44.0-3 [183 kB] 755s Get:47 http://ftpmaster.internal/ubuntu plucky/main armhf libxcb-render0 armhf 1.17.0-2 [15.3 kB] 755s Get:48 http://ftpmaster.internal/ubuntu plucky/main armhf libxcb-shm0 armhf 1.17.0-2 [5774 B] 755s Get:49 http://ftpmaster.internal/ubuntu plucky/main armhf libxrender1 armhf 1:0.9.10-1.1build1 [16.0 kB] 755s Get:50 http://ftpmaster.internal/ubuntu plucky/main armhf libcairo2 armhf 1.18.2-2 [484 kB] 755s Get:51 http://ftpmaster.internal/ubuntu plucky/main armhf libdatrie1 armhf 0.2.13-3build1 [15.7 kB] 755s Get:52 http://ftpmaster.internal/ubuntu plucky/main armhf libdeflate0 armhf 1.23-1 [38.5 kB] 755s Get:53 http://ftpmaster.internal/ubuntu plucky/main armhf libdeflate-dev armhf 1.23-1 [45.0 kB] 755s Get:54 http://ftpmaster.internal/ubuntu plucky/main armhf libgraphite2-3 armhf 1.3.14-2ubuntu1 [64.8 kB] 755s Get:55 http://ftpmaster.internal/ubuntu plucky/main armhf libharfbuzz0b armhf 10.2.0-1 [464 kB] 756s Get:56 http://ftpmaster.internal/ubuntu plucky/main armhf x11-common all 1:7.7+23ubuntu3 [21.7 kB] 756s Get:57 http://ftpmaster.internal/ubuntu plucky/main armhf libice6 armhf 2:1.1.1-1 [36.5 kB] 756s Get:58 http://ftpmaster.internal/ubuntu plucky/main armhf libicu-dev armhf 76.1-1ubuntu2 [12.0 MB] 768s Get:59 http://ftpmaster.internal/ubuntu plucky/main armhf libjpeg-turbo8 armhf 2.1.5-3ubuntu2 [127 kB] 768s Get:60 http://ftpmaster.internal/ubuntu plucky/main armhf libjpeg-turbo8-dev armhf 2.1.5-3ubuntu2 [265 kB] 769s Get:61 http://ftpmaster.internal/ubuntu plucky/main armhf libjpeg8 armhf 8c-2ubuntu11 [2148 B] 769s Get:62 http://ftpmaster.internal/ubuntu plucky/main armhf libjpeg8-dev armhf 8c-2ubuntu11 [1484 B] 769s Get:63 http://ftpmaster.internal/ubuntu plucky/main armhf libjpeg-dev armhf 8c-2ubuntu11 [1482 B] 769s Get:64 http://ftpmaster.internal/ubuntu plucky/universe armhf libjs-bootstrap all 3.4.1+dfsg-3 [129 kB] 769s Get:65 http://ftpmaster.internal/ubuntu plucky/universe armhf libjs-highlight.js all 9.18.5+dfsg1-2 [385 kB] 769s Get:66 http://ftpmaster.internal/ubuntu plucky/main armhf libjs-jquery all 3.6.1+dfsg+~3.5.14-1 [328 kB] 769s Get:67 http://ftpmaster.internal/ubuntu plucky/universe armhf libjs-jquery-datatables all 1.11.5+dfsg-2 [146 kB] 770s Get:68 http://ftpmaster.internal/ubuntu plucky/main armhf liblapack3 armhf 3.12.1-2 [2091 kB] 772s Get:69 http://ftpmaster.internal/ubuntu plucky/main armhf liblapack-dev armhf 3.12.1-2 [2207 kB] 774s Get:70 http://ftpmaster.internal/ubuntu plucky/main armhf liblerc4 armhf 4.0.0+ds-5ubuntu1 [160 kB] 775s Get:71 http://ftpmaster.internal/ubuntu plucky/main armhf libncurses-dev armhf 6.5+20250216-2 [345 kB] 775s Get:72 http://ftpmaster.internal/ubuntu plucky/main armhf libthai-data all 0.1.29-2build1 [158 kB] 775s Get:73 http://ftpmaster.internal/ubuntu plucky/main armhf libthai0 armhf 0.1.29-2build1 [15.2 kB] 775s Get:74 http://ftpmaster.internal/ubuntu plucky/main armhf libpango-1.0-0 armhf 1.56.2-1 [216 kB] 775s Get:75 http://ftpmaster.internal/ubuntu plucky/main armhf libpangoft2-1.0-0 armhf 1.56.2-1 [43.6 kB] 775s Get:76 http://ftpmaster.internal/ubuntu plucky/main armhf libpangocairo-1.0-0 armhf 1.56.2-1 [25.1 kB] 775s Get:77 http://ftpmaster.internal/ubuntu plucky/main armhf libpaper2 armhf 2.2.5-0.3 [16.3 kB] 775s Get:78 http://ftpmaster.internal/ubuntu plucky/main armhf libpaper-utils armhf 2.2.5-0.3 [14.2 kB] 775s Get:79 http://ftpmaster.internal/ubuntu plucky/main armhf libpcre2-16-0 armhf 10.45-1 [207 kB] 776s Get:80 http://ftpmaster.internal/ubuntu plucky/main armhf libpcre2-32-0 armhf 10.45-1 [197 kB] 776s Get:81 http://ftpmaster.internal/ubuntu plucky/main armhf libpcre2-posix3 armhf 10.45-1 [6300 B] 776s Get:82 http://ftpmaster.internal/ubuntu plucky/main armhf libpcre2-dev armhf 10.45-1 [752 kB] 776s Get:83 http://ftpmaster.internal/ubuntu plucky/main armhf libpkgconf3 armhf 1.8.1-4 [26.6 kB] 776s Get:84 http://ftpmaster.internal/ubuntu plucky/main armhf zlib1g-dev armhf 1:1.3.dfsg+really1.3.1-1ubuntu1 [880 kB] 777s Get:85 http://ftpmaster.internal/ubuntu plucky/main armhf libpng-dev armhf 1.6.47-1 [251 kB] 778s Get:86 http://ftpmaster.internal/ubuntu plucky/main armhf libreadline-dev armhf 8.2-6 [153 kB] 778s Get:87 http://ftpmaster.internal/ubuntu plucky/main armhf libsharpyuv0 armhf 1.5.0-0.1 [16.4 kB] 778s Get:88 http://ftpmaster.internal/ubuntu plucky/main armhf libsm6 armhf 2:1.2.4-1 [15.1 kB] 778s Get:89 http://ftpmaster.internal/ubuntu plucky/main armhf libtcl8.6 armhf 8.6.16+dfsg-1 [909 kB] 779s Get:90 http://ftpmaster.internal/ubuntu plucky/main armhf libjbig0 armhf 2.1-6.1ubuntu2 [24.9 kB] 779s Get:91 http://ftpmaster.internal/ubuntu plucky/main armhf libwebp7 armhf 1.5.0-0.1 [188 kB] 779s Get:92 http://ftpmaster.internal/ubuntu plucky/main armhf libtiff6 armhf 4.5.1+git230720-4ubuntu4 [179 kB] 779s Get:93 http://ftpmaster.internal/ubuntu plucky/main armhf libxft2 armhf 2.3.6-1build1 [37.4 kB] 779s Get:94 http://ftpmaster.internal/ubuntu plucky/main armhf libxss1 armhf 1:1.2.3-1build3 [6500 B] 779s Get:95 http://ftpmaster.internal/ubuntu plucky/main armhf libtk8.6 armhf 8.6.16-1 [686 kB] 780s Get:96 http://ftpmaster.internal/ubuntu plucky/main armhf libxt6t64 armhf 1:1.2.1-1.2build1 [145 kB] 780s Get:97 http://ftpmaster.internal/ubuntu plucky/universe armhf node-normalize.css all 8.0.1-5 [10.8 kB] 780s Get:98 http://ftpmaster.internal/ubuntu plucky/main armhf zip armhf 3.0-14ubuntu2 [164 kB] 780s Get:99 http://ftpmaster.internal/ubuntu plucky/main armhf unzip armhf 6.0-28ubuntu6 [167 kB] 780s Get:100 http://ftpmaster.internal/ubuntu plucky/main armhf xdg-utils all 1.2.1-2ubuntu1 [66.0 kB] 780s Get:101 http://ftpmaster.internal/ubuntu plucky/universe armhf r-base-core armhf 4.4.3-1 [28.2 MB] 809s Get:102 http://ftpmaster.internal/ubuntu plucky/main armhf liblzma-dev armhf 5.6.4-1 [166 kB] 810s Get:103 http://ftpmaster.internal/ubuntu plucky/main armhf pkgconf-bin armhf 1.8.1-4 [21.2 kB] 810s Get:104 http://ftpmaster.internal/ubuntu plucky/main armhf pkgconf armhf 1.8.1-4 [16.8 kB] 810s Get:105 http://ftpmaster.internal/ubuntu plucky/main armhf libtirpc-dev armhf 1.3.4+ds-1.3 [184 kB] 810s Get:106 http://ftpmaster.internal/ubuntu plucky/universe armhf r-base-dev all 4.4.3-1 [4176 B] 810s Get:107 http://ftpmaster.internal/ubuntu plucky/universe armhf pkg-r-autopkgtest all 20231212ubuntu1 [6448 B] 810s Get:108 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-base64enc armhf 0.1-3-3 [27.3 kB] 810s Get:109 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-cli armhf 3.6.4-1 [1377 kB] 812s Get:110 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-colorspace armhf 2.1-1+dfsg-1 [1561 kB] 814s Get:111 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-commonmark armhf 1.9.2-2 [112 kB] 814s Get:112 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-evaluate all 1.0.3-1 [114 kB] 814s Get:113 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-fansi armhf 1.0.5-1 [611 kB] 814s Get:114 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-farver armhf 2.1.2-1 [1355 kB] 816s Get:115 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-glue armhf 1.8.0-1 [162 kB] 816s Get:116 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-rlang armhf 1.1.5-1 [1701 kB] 818s Get:117 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-lifecycle all 1.0.4+dfsg-1 [110 kB] 818s Get:118 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-gtable all 0.3.6+dfsg-1 [199 kB] 818s Get:119 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-isoband armhf 0.2.7-1 [1477 kB] 820s Get:120 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-mass armhf 7.3-64-1 [1105 kB] 821s Get:121 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-lattice armhf 0.22-6-1 [1363 kB] 823s Get:122 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-nlme armhf 3.1.167-1 [2306 kB] 825s Get:123 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-matrix armhf 1.7-3-1 [4039 kB] 829s Get:124 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-mgcv armhf 1.9-1-1 [3205 kB] 832s Get:125 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-labeling all 0.4.3-1 [62.1 kB] 832s Get:126 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-munsell all 0.5.1-1 [213 kB] 832s Get:127 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-r6 all 2.6.1-1 [101 kB] 833s Get:128 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-rcolorbrewer all 1.1-3-1build1 [55.4 kB] 833s Get:129 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-viridislite all 0.4.2-2 [1088 kB] 834s Get:130 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-scales all 1.3.0-1 [603 kB] 834s Get:131 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-magrittr armhf 2.0.3-1 [154 kB] 835s Get:132 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-utf8 armhf 1.2.4-1 [136 kB] 835s Get:133 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-vctrs armhf 0.6.5-1 [1310 kB] 836s Get:134 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-pillar all 1.10.1+dfsg-1 [453 kB] 836s Get:135 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-pkgconfig all 2.0.3-2build1 [19.7 kB] 836s Get:136 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-tibble armhf 3.2.1+dfsg-3 [420 kB] 837s Get:137 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-withr all 3.0.2+dfsg-1 [214 kB] 837s Get:138 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-ggplot2 all 3.5.1+dfsg-1 [3940 kB] 841s Get:139 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-xfun armhf 0.51+dfsg-1 [573 kB] 842s Get:140 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-highr all 0.11+dfsg-1 [38.5 kB] 842s Get:141 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-yaml armhf 2.3.10-1 [101 kB] 842s Get:142 http://ftpmaster.internal/ubuntu plucky/main armhf libjs-mathjax all 2.7.9+dfsg-1 [5665 kB] 848s Get:143 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-knitr all 1.49+dfsg-1 [859 kB] 848s Get:144 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-markdown all 1.13-1 [162 kB] 848s Get:145 http://ftpmaster.internal/ubuntu plucky/universe armhf r-cran-matrixstats armhf 1.5.0-1 [495 kB] 850s Preconfiguring packages ... 850s Fetched 157 MB in 2min 46s (945 kB/s) 850s Selecting previously unselected package libc-dev-bin. 850s (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 ... 64655 files and directories currently installed.) 850s Preparing to unpack .../000-libc-dev-bin_2.41-1ubuntu2_armhf.deb ... 850s Unpacking libc-dev-bin (2.41-1ubuntu2) ... 850s Selecting previously unselected package linux-libc-dev:armhf. 850s Preparing to unpack .../001-linux-libc-dev_6.14.0-10.10_armhf.deb ... 850s Unpacking linux-libc-dev:armhf (6.14.0-10.10) ... 850s Selecting previously unselected package libcrypt-dev:armhf. 850s Preparing to unpack .../002-libcrypt-dev_1%3a4.4.38-1_armhf.deb ... 850s Unpacking libcrypt-dev:armhf (1:4.4.38-1) ... 850s Selecting previously unselected package rpcsvc-proto. 851s Preparing to unpack .../003-rpcsvc-proto_1.4.2-0ubuntu7_armhf.deb ... 851s Unpacking rpcsvc-proto (1.4.2-0ubuntu7) ... 851s Selecting previously unselected package libc6-dev:armhf. 851s Preparing to unpack .../004-libc6-dev_2.41-1ubuntu2_armhf.deb ... 851s Unpacking libc6-dev:armhf (2.41-1ubuntu2) ... 851s Selecting previously unselected package libisl23:armhf. 851s Preparing to unpack .../005-libisl23_0.27-1_armhf.deb ... 851s Unpacking libisl23:armhf (0.27-1) ... 851s Selecting previously unselected package libmpc3:armhf. 851s Preparing to unpack .../006-libmpc3_1.3.1-1build2_armhf.deb ... 851s Unpacking libmpc3:armhf (1.3.1-1build2) ... 851s Selecting previously unselected package cpp-14-arm-linux-gnueabihf. 851s Preparing to unpack .../007-cpp-14-arm-linux-gnueabihf_14.2.0-17ubuntu3_armhf.deb ... 851s Unpacking cpp-14-arm-linux-gnueabihf (14.2.0-17ubuntu3) ... 851s Selecting previously unselected package cpp-14. 851s Preparing to unpack .../008-cpp-14_14.2.0-17ubuntu3_armhf.deb ... 851s Unpacking cpp-14 (14.2.0-17ubuntu3) ... 851s Selecting previously unselected package cpp-arm-linux-gnueabihf. 851s Preparing to unpack .../009-cpp-arm-linux-gnueabihf_4%3a14.2.0-1ubuntu1_armhf.deb ... 851s Unpacking cpp-arm-linux-gnueabihf (4:14.2.0-1ubuntu1) ... 851s Selecting previously unselected package cpp. 851s Preparing to unpack .../010-cpp_4%3a14.2.0-1ubuntu1_armhf.deb ... 851s Unpacking cpp (4:14.2.0-1ubuntu1) ... 851s Selecting previously unselected package libcc1-0:armhf. 851s Preparing to unpack .../011-libcc1-0_15-20250222-0ubuntu1_armhf.deb ... 851s Unpacking libcc1-0:armhf (15-20250222-0ubuntu1) ... 851s Selecting previously unselected package libgomp1:armhf. 851s Preparing to unpack .../012-libgomp1_15-20250222-0ubuntu1_armhf.deb ... 851s Unpacking libgomp1:armhf (15-20250222-0ubuntu1) ... 851s Selecting previously unselected package libasan8:armhf. 851s Preparing to unpack .../013-libasan8_15-20250222-0ubuntu1_armhf.deb ... 851s Unpacking libasan8:armhf (15-20250222-0ubuntu1) ... 852s Selecting previously unselected package libubsan1:armhf. 852s Preparing to unpack .../014-libubsan1_15-20250222-0ubuntu1_armhf.deb ... 852s Unpacking libubsan1:armhf (15-20250222-0ubuntu1) ... 852s Selecting previously unselected package libgcc-14-dev:armhf. 852s Preparing to unpack .../015-libgcc-14-dev_14.2.0-17ubuntu3_armhf.deb ... 852s Unpacking libgcc-14-dev:armhf (14.2.0-17ubuntu3) ... 852s Selecting previously unselected package gcc-14-arm-linux-gnueabihf. 852s Preparing to unpack .../016-gcc-14-arm-linux-gnueabihf_14.2.0-17ubuntu3_armhf.deb ... 852s Unpacking gcc-14-arm-linux-gnueabihf (14.2.0-17ubuntu3) ... 852s Selecting previously unselected package gcc-14. 852s Preparing to unpack .../017-gcc-14_14.2.0-17ubuntu3_armhf.deb ... 852s Unpacking gcc-14 (14.2.0-17ubuntu3) ... 852s Selecting previously unselected package gcc-arm-linux-gnueabihf. 852s Preparing to unpack .../018-gcc-arm-linux-gnueabihf_4%3a14.2.0-1ubuntu1_armhf.deb ... 852s Unpacking gcc-arm-linux-gnueabihf (4:14.2.0-1ubuntu1) ... 852s Selecting previously unselected package gcc. 852s Preparing to unpack .../019-gcc_4%3a14.2.0-1ubuntu1_armhf.deb ... 852s Unpacking gcc (4:14.2.0-1ubuntu1) ... 852s Selecting previously unselected package libstdc++-14-dev:armhf. 852s Preparing to unpack .../020-libstdc++-14-dev_14.2.0-17ubuntu3_armhf.deb ... 852s Unpacking libstdc++-14-dev:armhf (14.2.0-17ubuntu3) ... 853s Selecting previously unselected package g++-14-arm-linux-gnueabihf. 853s Preparing to unpack .../021-g++-14-arm-linux-gnueabihf_14.2.0-17ubuntu3_armhf.deb ... 853s Unpacking g++-14-arm-linux-gnueabihf (14.2.0-17ubuntu3) ... 853s Selecting previously unselected package g++-14. 853s Preparing to unpack .../022-g++-14_14.2.0-17ubuntu3_armhf.deb ... 853s Unpacking g++-14 (14.2.0-17ubuntu3) ... 853s Selecting previously unselected package g++-arm-linux-gnueabihf. 853s Preparing to unpack .../023-g++-arm-linux-gnueabihf_4%3a14.2.0-1ubuntu1_armhf.deb ... 853s Unpacking g++-arm-linux-gnueabihf (4:14.2.0-1ubuntu1) ... 853s Selecting previously unselected package g++. 853s Preparing to unpack .../024-g++_4%3a14.2.0-1ubuntu1_armhf.deb ... 853s Unpacking g++ (4:14.2.0-1ubuntu1) ... 853s Selecting previously unselected package build-essential. 853s Preparing to unpack .../025-build-essential_12.10ubuntu1_armhf.deb ... 853s Unpacking build-essential (12.10ubuntu1) ... 853s Selecting previously unselected package dctrl-tools. 853s Preparing to unpack .../026-dctrl-tools_2.24-3build3_armhf.deb ... 853s Unpacking dctrl-tools (2.24-3build3) ... 853s Selecting previously unselected package libfreetype6:armhf. 853s Preparing to unpack .../027-libfreetype6_2.13.3+dfsg-1_armhf.deb ... 853s Unpacking libfreetype6:armhf (2.13.3+dfsg-1) ... 853s Selecting previously unselected package fonts-dejavu-mono. 853s Preparing to unpack .../028-fonts-dejavu-mono_2.37-8_all.deb ... 853s Unpacking fonts-dejavu-mono (2.37-8) ... 853s Selecting previously unselected package fonts-dejavu-core. 853s Preparing to unpack .../029-fonts-dejavu-core_2.37-8_all.deb ... 853s Unpacking fonts-dejavu-core (2.37-8) ... 853s Selecting previously unselected package fontconfig-config. 854s Preparing to unpack .../030-fontconfig-config_2.15.0-2ubuntu1_armhf.deb ... 854s Unpacking fontconfig-config (2.15.0-2ubuntu1) ... 854s Selecting previously unselected package libfontconfig1:armhf. 854s Preparing to unpack .../031-libfontconfig1_2.15.0-2ubuntu1_armhf.deb ... 854s Unpacking libfontconfig1:armhf (2.15.0-2ubuntu1) ... 854s Selecting previously unselected package fontconfig. 854s Preparing to unpack .../032-fontconfig_2.15.0-2ubuntu1_armhf.deb ... 854s Unpacking fontconfig (2.15.0-2ubuntu1) ... 854s Selecting previously unselected package fonts-glyphicons-halflings. 854s Preparing to unpack .../033-fonts-glyphicons-halflings_1.009~3.4.1+dfsg-3_all.deb ... 854s Unpacking fonts-glyphicons-halflings (1.009~3.4.1+dfsg-3) ... 854s Selecting previously unselected package fonts-mathjax. 854s Preparing to unpack .../034-fonts-mathjax_2.7.9+dfsg-1_all.deb ... 854s Unpacking fonts-mathjax (2.7.9+dfsg-1) ... 854s Selecting previously unselected package libgfortran5:armhf. 854s Preparing to unpack .../035-libgfortran5_15-20250222-0ubuntu1_armhf.deb ... 854s Unpacking libgfortran5:armhf (15-20250222-0ubuntu1) ... 854s Selecting previously unselected package libgfortran-14-dev:armhf. 854s Preparing to unpack .../036-libgfortran-14-dev_14.2.0-17ubuntu3_armhf.deb ... 854s Unpacking libgfortran-14-dev:armhf (14.2.0-17ubuntu3) ... 854s Selecting previously unselected package gfortran-14-arm-linux-gnueabihf. 854s Preparing to unpack .../037-gfortran-14-arm-linux-gnueabihf_14.2.0-17ubuntu3_armhf.deb ... 854s Unpacking gfortran-14-arm-linux-gnueabihf (14.2.0-17ubuntu3) ... 855s Selecting previously unselected package gfortran-14. 855s Preparing to unpack .../038-gfortran-14_14.2.0-17ubuntu3_armhf.deb ... 855s Unpacking gfortran-14 (14.2.0-17ubuntu3) ... 855s Selecting previously unselected package gfortran-arm-linux-gnueabihf. 855s Preparing to unpack .../039-gfortran-arm-linux-gnueabihf_4%3a14.2.0-1ubuntu1_armhf.deb ... 855s Unpacking gfortran-arm-linux-gnueabihf (4:14.2.0-1ubuntu1) ... 855s Selecting previously unselected package gfortran. 855s Preparing to unpack .../040-gfortran_4%3a14.2.0-1ubuntu1_armhf.deb ... 855s Unpacking gfortran (4:14.2.0-1ubuntu1) ... 855s Selecting previously unselected package icu-devtools. 855s Preparing to unpack .../041-icu-devtools_76.1-1ubuntu2_armhf.deb ... 855s Unpacking icu-devtools (76.1-1ubuntu2) ... 855s Selecting previously unselected package libblas3:armhf. 855s Preparing to unpack .../042-libblas3_3.12.1-2_armhf.deb ... 855s Unpacking libblas3:armhf (3.12.1-2) ... 855s Selecting previously unselected package libblas-dev:armhf. 855s Preparing to unpack .../043-libblas-dev_3.12.1-2_armhf.deb ... 855s Unpacking libblas-dev:armhf (3.12.1-2) ... 855s Selecting previously unselected package libbz2-dev:armhf. 855s Preparing to unpack .../044-libbz2-dev_1.0.8-6_armhf.deb ... 855s Unpacking libbz2-dev:armhf (1.0.8-6) ... 855s Selecting previously unselected package libpixman-1-0:armhf. 855s Preparing to unpack .../045-libpixman-1-0_0.44.0-3_armhf.deb ... 855s Unpacking libpixman-1-0:armhf (0.44.0-3) ... 855s Selecting previously unselected package libxcb-render0:armhf. 855s Preparing to unpack .../046-libxcb-render0_1.17.0-2_armhf.deb ... 855s Unpacking libxcb-render0:armhf (1.17.0-2) ... 855s Selecting previously unselected package libxcb-shm0:armhf. 855s Preparing to unpack .../047-libxcb-shm0_1.17.0-2_armhf.deb ... 855s Unpacking libxcb-shm0:armhf (1.17.0-2) ... 855s Selecting previously unselected package libxrender1:armhf. 855s Preparing to unpack .../048-libxrender1_1%3a0.9.10-1.1build1_armhf.deb ... 855s Unpacking libxrender1:armhf (1:0.9.10-1.1build1) ... 855s Selecting previously unselected package libcairo2:armhf. 855s Preparing to unpack .../049-libcairo2_1.18.2-2_armhf.deb ... 855s Unpacking libcairo2:armhf (1.18.2-2) ... 855s Selecting previously unselected package libdatrie1:armhf. 855s Preparing to unpack .../050-libdatrie1_0.2.13-3build1_armhf.deb ... 855s Unpacking libdatrie1:armhf (0.2.13-3build1) ... 855s Selecting previously unselected package libdeflate0:armhf. 855s Preparing to unpack .../051-libdeflate0_1.23-1_armhf.deb ... 855s Unpacking libdeflate0:armhf (1.23-1) ... 855s Selecting previously unselected package libdeflate-dev:armhf. 855s Preparing to unpack .../052-libdeflate-dev_1.23-1_armhf.deb ... 855s Unpacking libdeflate-dev:armhf (1.23-1) ... 855s Selecting previously unselected package libgraphite2-3:armhf. 856s Preparing to unpack .../053-libgraphite2-3_1.3.14-2ubuntu1_armhf.deb ... 856s Unpacking libgraphite2-3:armhf (1.3.14-2ubuntu1) ... 856s Selecting previously unselected package libharfbuzz0b:armhf. 856s Preparing to unpack .../054-libharfbuzz0b_10.2.0-1_armhf.deb ... 856s Unpacking libharfbuzz0b:armhf (10.2.0-1) ... 856s Selecting previously unselected package x11-common. 856s Preparing to unpack .../055-x11-common_1%3a7.7+23ubuntu3_all.deb ... 856s Unpacking x11-common (1:7.7+23ubuntu3) ... 856s Selecting previously unselected package libice6:armhf. 856s Preparing to unpack .../056-libice6_2%3a1.1.1-1_armhf.deb ... 856s Unpacking libice6:armhf (2:1.1.1-1) ... 856s Selecting previously unselected package libicu-dev:armhf. 856s Preparing to unpack .../057-libicu-dev_76.1-1ubuntu2_armhf.deb ... 856s Unpacking libicu-dev:armhf (76.1-1ubuntu2) ... 856s Selecting previously unselected package libjpeg-turbo8:armhf. 856s Preparing to unpack .../058-libjpeg-turbo8_2.1.5-3ubuntu2_armhf.deb ... 856s Unpacking libjpeg-turbo8:armhf (2.1.5-3ubuntu2) ... 856s Selecting previously unselected package libjpeg-turbo8-dev:armhf. 856s Preparing to unpack .../059-libjpeg-turbo8-dev_2.1.5-3ubuntu2_armhf.deb ... 856s Unpacking libjpeg-turbo8-dev:armhf (2.1.5-3ubuntu2) ... 856s Selecting previously unselected package libjpeg8:armhf. 856s Preparing to unpack .../060-libjpeg8_8c-2ubuntu11_armhf.deb ... 856s Unpacking libjpeg8:armhf (8c-2ubuntu11) ... 856s Selecting previously unselected package libjpeg8-dev:armhf. 856s Preparing to unpack .../061-libjpeg8-dev_8c-2ubuntu11_armhf.deb ... 856s Unpacking libjpeg8-dev:armhf (8c-2ubuntu11) ... 856s Selecting previously unselected package libjpeg-dev:armhf. 856s Preparing to unpack .../062-libjpeg-dev_8c-2ubuntu11_armhf.deb ... 856s Unpacking libjpeg-dev:armhf (8c-2ubuntu11) ... 856s Selecting previously unselected package libjs-bootstrap. 856s Preparing to unpack .../063-libjs-bootstrap_3.4.1+dfsg-3_all.deb ... 856s Unpacking libjs-bootstrap (3.4.1+dfsg-3) ... 856s Selecting previously unselected package libjs-highlight.js. 857s Preparing to unpack .../064-libjs-highlight.js_9.18.5+dfsg1-2_all.deb ... 857s Unpacking libjs-highlight.js (9.18.5+dfsg1-2) ... 857s Selecting previously unselected package libjs-jquery. 857s Preparing to unpack .../065-libjs-jquery_3.6.1+dfsg+~3.5.14-1_all.deb ... 857s Unpacking libjs-jquery (3.6.1+dfsg+~3.5.14-1) ... 857s Selecting previously unselected package libjs-jquery-datatables. 857s Preparing to unpack .../066-libjs-jquery-datatables_1.11.5+dfsg-2_all.deb ... 857s Unpacking libjs-jquery-datatables (1.11.5+dfsg-2) ... 857s Selecting previously unselected package liblapack3:armhf. 857s Preparing to unpack .../067-liblapack3_3.12.1-2_armhf.deb ... 857s Unpacking liblapack3:armhf (3.12.1-2) ... 857s Selecting previously unselected package liblapack-dev:armhf. 857s Preparing to unpack .../068-liblapack-dev_3.12.1-2_armhf.deb ... 857s Unpacking liblapack-dev:armhf (3.12.1-2) ... 857s Selecting previously unselected package liblerc4:armhf. 857s Preparing to unpack .../069-liblerc4_4.0.0+ds-5ubuntu1_armhf.deb ... 857s Unpacking liblerc4:armhf (4.0.0+ds-5ubuntu1) ... 857s Selecting previously unselected package libncurses-dev:armhf. 857s Preparing to unpack .../070-libncurses-dev_6.5+20250216-2_armhf.deb ... 857s Unpacking libncurses-dev:armhf (6.5+20250216-2) ... 857s Selecting previously unselected package libthai-data. 857s Preparing to unpack .../071-libthai-data_0.1.29-2build1_all.deb ... 857s Unpacking libthai-data (0.1.29-2build1) ... 857s Selecting previously unselected package libthai0:armhf. 857s Preparing to unpack .../072-libthai0_0.1.29-2build1_armhf.deb ... 857s Unpacking libthai0:armhf (0.1.29-2build1) ... 857s Selecting previously unselected package libpango-1.0-0:armhf. 857s Preparing to unpack .../073-libpango-1.0-0_1.56.2-1_armhf.deb ... 857s Unpacking libpango-1.0-0:armhf (1.56.2-1) ... 857s Selecting previously unselected package libpangoft2-1.0-0:armhf. 857s Preparing to unpack .../074-libpangoft2-1.0-0_1.56.2-1_armhf.deb ... 857s Unpacking libpangoft2-1.0-0:armhf (1.56.2-1) ... 857s Selecting previously unselected package libpangocairo-1.0-0:armhf. 857s Preparing to unpack .../075-libpangocairo-1.0-0_1.56.2-1_armhf.deb ... 857s Unpacking libpangocairo-1.0-0:armhf (1.56.2-1) ... 857s Selecting previously unselected package libpaper2:armhf. 857s Preparing to unpack .../076-libpaper2_2.2.5-0.3_armhf.deb ... 857s Unpacking libpaper2:armhf (2.2.5-0.3) ... 857s Selecting previously unselected package libpaper-utils. 857s Preparing to unpack .../077-libpaper-utils_2.2.5-0.3_armhf.deb ... 857s Unpacking libpaper-utils (2.2.5-0.3) ... 857s Selecting previously unselected package libpcre2-16-0:armhf. 857s Preparing to unpack .../078-libpcre2-16-0_10.45-1_armhf.deb ... 857s Unpacking libpcre2-16-0:armhf (10.45-1) ... 858s Selecting previously unselected package libpcre2-32-0:armhf. 858s Preparing to unpack .../079-libpcre2-32-0_10.45-1_armhf.deb ... 858s Unpacking libpcre2-32-0:armhf (10.45-1) ... 858s Selecting previously unselected package libpcre2-posix3:armhf. 858s Preparing to unpack .../080-libpcre2-posix3_10.45-1_armhf.deb ... 858s Unpacking libpcre2-posix3:armhf (10.45-1) ... 858s Selecting previously unselected package libpcre2-dev:armhf. 858s Preparing to unpack .../081-libpcre2-dev_10.45-1_armhf.deb ... 858s Unpacking libpcre2-dev:armhf (10.45-1) ... 858s Selecting previously unselected package libpkgconf3:armhf. 858s Preparing to unpack .../082-libpkgconf3_1.8.1-4_armhf.deb ... 858s Unpacking libpkgconf3:armhf (1.8.1-4) ... 858s Selecting previously unselected package zlib1g-dev:armhf. 858s Preparing to unpack .../083-zlib1g-dev_1%3a1.3.dfsg+really1.3.1-1ubuntu1_armhf.deb ... 858s Unpacking zlib1g-dev:armhf (1:1.3.dfsg+really1.3.1-1ubuntu1) ... 858s Selecting previously unselected package libpng-dev:armhf. 858s Preparing to unpack .../084-libpng-dev_1.6.47-1_armhf.deb ... 858s Unpacking libpng-dev:armhf (1.6.47-1) ... 858s Selecting previously unselected package libreadline-dev:armhf. 858s Preparing to unpack .../085-libreadline-dev_8.2-6_armhf.deb ... 858s Unpacking libreadline-dev:armhf (8.2-6) ... 858s Selecting previously unselected package libsharpyuv0:armhf. 858s Preparing to unpack .../086-libsharpyuv0_1.5.0-0.1_armhf.deb ... 858s Unpacking libsharpyuv0:armhf (1.5.0-0.1) ... 858s Selecting previously unselected package libsm6:armhf. 858s Preparing to unpack .../087-libsm6_2%3a1.2.4-1_armhf.deb ... 858s Unpacking libsm6:armhf (2:1.2.4-1) ... 858s Selecting previously unselected package libtcl8.6:armhf. 858s Preparing to unpack .../088-libtcl8.6_8.6.16+dfsg-1_armhf.deb ... 858s Unpacking libtcl8.6:armhf (8.6.16+dfsg-1) ... 858s Selecting previously unselected package libjbig0:armhf. 858s Preparing to unpack .../089-libjbig0_2.1-6.1ubuntu2_armhf.deb ... 858s Unpacking libjbig0:armhf (2.1-6.1ubuntu2) ... 858s Selecting previously unselected package libwebp7:armhf. 858s Preparing to unpack .../090-libwebp7_1.5.0-0.1_armhf.deb ... 858s Unpacking libwebp7:armhf (1.5.0-0.1) ... 858s Selecting previously unselected package libtiff6:armhf. 858s Preparing to unpack .../091-libtiff6_4.5.1+git230720-4ubuntu4_armhf.deb ... 858s Unpacking libtiff6:armhf (4.5.1+git230720-4ubuntu4) ... 858s Selecting previously unselected package libxft2:armhf. 858s Preparing to unpack .../092-libxft2_2.3.6-1build1_armhf.deb ... 858s Unpacking libxft2:armhf (2.3.6-1build1) ... 858s Selecting previously unselected package libxss1:armhf. 858s Preparing to unpack .../093-libxss1_1%3a1.2.3-1build3_armhf.deb ... 858s Unpacking libxss1:armhf (1:1.2.3-1build3) ... 858s Selecting previously unselected package libtk8.6:armhf. 858s Preparing to unpack .../094-libtk8.6_8.6.16-1_armhf.deb ... 858s Unpacking libtk8.6:armhf (8.6.16-1) ... 859s Selecting previously unselected package libxt6t64:armhf. 859s Preparing to unpack .../095-libxt6t64_1%3a1.2.1-1.2build1_armhf.deb ... 859s Unpacking libxt6t64:armhf (1:1.2.1-1.2build1) ... 859s Selecting previously unselected package node-normalize.css. 859s Preparing to unpack .../096-node-normalize.css_8.0.1-5_all.deb ... 859s Unpacking node-normalize.css (8.0.1-5) ... 859s Selecting previously unselected package zip. 859s Preparing to unpack .../097-zip_3.0-14ubuntu2_armhf.deb ... 859s Unpacking zip (3.0-14ubuntu2) ... 859s Selecting previously unselected package unzip. 859s Preparing to unpack .../098-unzip_6.0-28ubuntu6_armhf.deb ... 859s Unpacking unzip (6.0-28ubuntu6) ... 859s Selecting previously unselected package xdg-utils. 859s Preparing to unpack .../099-xdg-utils_1.2.1-2ubuntu1_all.deb ... 859s Unpacking xdg-utils (1.2.1-2ubuntu1) ... 859s Selecting previously unselected package r-base-core. 859s Preparing to unpack .../100-r-base-core_4.4.3-1_armhf.deb ... 859s Unpacking r-base-core (4.4.3-1) ... 859s Selecting previously unselected package liblzma-dev:armhf. 859s Preparing to unpack .../101-liblzma-dev_5.6.4-1_armhf.deb ... 859s Unpacking liblzma-dev:armhf (5.6.4-1) ... 859s Selecting previously unselected package pkgconf-bin. 859s Preparing to unpack .../102-pkgconf-bin_1.8.1-4_armhf.deb ... 859s Unpacking pkgconf-bin (1.8.1-4) ... 859s Selecting previously unselected package pkgconf:armhf. 859s Preparing to unpack .../103-pkgconf_1.8.1-4_armhf.deb ... 859s Unpacking pkgconf:armhf (1.8.1-4) ... 860s Selecting previously unselected package libtirpc-dev:armhf. 860s Preparing to unpack .../104-libtirpc-dev_1.3.4+ds-1.3_armhf.deb ... 860s Unpacking libtirpc-dev:armhf (1.3.4+ds-1.3) ... 860s Selecting previously unselected package r-base-dev. 860s Preparing to unpack .../105-r-base-dev_4.4.3-1_all.deb ... 860s Unpacking r-base-dev (4.4.3-1) ... 860s Selecting previously unselected package pkg-r-autopkgtest. 860s Preparing to unpack .../106-pkg-r-autopkgtest_20231212ubuntu1_all.deb ... 860s Unpacking pkg-r-autopkgtest (20231212ubuntu1) ... 860s Selecting previously unselected package r-cran-base64enc. 860s Preparing to unpack .../107-r-cran-base64enc_0.1-3-3_armhf.deb ... 860s Unpacking r-cran-base64enc (0.1-3-3) ... 860s Selecting previously unselected package r-cran-cli. 860s Preparing to unpack .../108-r-cran-cli_3.6.4-1_armhf.deb ... 860s Unpacking r-cran-cli (3.6.4-1) ... 860s Selecting previously unselected package r-cran-colorspace. 860s Preparing to unpack .../109-r-cran-colorspace_2.1-1+dfsg-1_armhf.deb ... 860s Unpacking r-cran-colorspace (2.1-1+dfsg-1) ... 860s Selecting previously unselected package r-cran-commonmark. 860s Preparing to unpack .../110-r-cran-commonmark_1.9.2-2_armhf.deb ... 860s Unpacking r-cran-commonmark (1.9.2-2) ... 860s Selecting previously unselected package r-cran-evaluate. 860s Preparing to unpack .../111-r-cran-evaluate_1.0.3-1_all.deb ... 860s Unpacking r-cran-evaluate (1.0.3-1) ... 860s Selecting previously unselected package r-cran-fansi. 860s Preparing to unpack .../112-r-cran-fansi_1.0.5-1_armhf.deb ... 860s Unpacking r-cran-fansi (1.0.5-1) ... 860s Selecting previously unselected package r-cran-farver. 860s Preparing to unpack .../113-r-cran-farver_2.1.2-1_armhf.deb ... 860s Unpacking r-cran-farver (2.1.2-1) ... 860s Selecting previously unselected package r-cran-glue. 860s Preparing to unpack .../114-r-cran-glue_1.8.0-1_armhf.deb ... 860s Unpacking r-cran-glue (1.8.0-1) ... 860s Selecting previously unselected package r-cran-rlang. 860s Preparing to unpack .../115-r-cran-rlang_1.1.5-1_armhf.deb ... 860s Unpacking r-cran-rlang (1.1.5-1) ... 860s Selecting previously unselected package r-cran-lifecycle. 861s Preparing to unpack .../116-r-cran-lifecycle_1.0.4+dfsg-1_all.deb ... 861s Unpacking r-cran-lifecycle (1.0.4+dfsg-1) ... 861s Selecting previously unselected package r-cran-gtable. 861s Preparing to unpack .../117-r-cran-gtable_0.3.6+dfsg-1_all.deb ... 861s Unpacking r-cran-gtable (0.3.6+dfsg-1) ... 861s Selecting previously unselected package r-cran-isoband. 861s Preparing to unpack .../118-r-cran-isoband_0.2.7-1_armhf.deb ... 861s Unpacking r-cran-isoband (0.2.7-1) ... 861s Selecting previously unselected package r-cran-mass. 861s Preparing to unpack .../119-r-cran-mass_7.3-64-1_armhf.deb ... 861s Unpacking r-cran-mass (7.3-64-1) ... 861s Selecting previously unselected package r-cran-lattice. 861s Preparing to unpack .../120-r-cran-lattice_0.22-6-1_armhf.deb ... 861s Unpacking r-cran-lattice (0.22-6-1) ... 861s Selecting previously unselected package r-cran-nlme. 861s Preparing to unpack .../121-r-cran-nlme_3.1.167-1_armhf.deb ... 861s Unpacking r-cran-nlme (3.1.167-1) ... 861s Selecting previously unselected package r-cran-matrix. 861s Preparing to unpack .../122-r-cran-matrix_1.7-3-1_armhf.deb ... 861s Unpacking r-cran-matrix (1.7-3-1) ... 861s Selecting previously unselected package r-cran-mgcv. 861s Preparing to unpack .../123-r-cran-mgcv_1.9-1-1_armhf.deb ... 861s Unpacking r-cran-mgcv (1.9-1-1) ... 861s Selecting previously unselected package r-cran-labeling. 861s Preparing to unpack .../124-r-cran-labeling_0.4.3-1_all.deb ... 861s Unpacking r-cran-labeling (0.4.3-1) ... 861s Selecting previously unselected package r-cran-munsell. 861s Preparing to unpack .../125-r-cran-munsell_0.5.1-1_all.deb ... 861s Unpacking r-cran-munsell (0.5.1-1) ... 861s Selecting previously unselected package r-cran-r6. 861s Preparing to unpack .../126-r-cran-r6_2.6.1-1_all.deb ... 861s Unpacking r-cran-r6 (2.6.1-1) ... 861s Selecting previously unselected package r-cran-rcolorbrewer. 861s Preparing to unpack .../127-r-cran-rcolorbrewer_1.1-3-1build1_all.deb ... 861s Unpacking r-cran-rcolorbrewer (1.1-3-1build1) ... 861s Selecting previously unselected package r-cran-viridislite. 861s Preparing to unpack .../128-r-cran-viridislite_0.4.2-2_all.deb ... 861s Unpacking r-cran-viridislite (0.4.2-2) ... 861s Selecting previously unselected package r-cran-scales. 861s Preparing to unpack .../129-r-cran-scales_1.3.0-1_all.deb ... 861s Unpacking r-cran-scales (1.3.0-1) ... 861s Selecting previously unselected package r-cran-magrittr. 862s Preparing to unpack .../130-r-cran-magrittr_2.0.3-1_armhf.deb ... 862s Unpacking r-cran-magrittr (2.0.3-1) ... 862s Selecting previously unselected package r-cran-utf8. 862s Preparing to unpack .../131-r-cran-utf8_1.2.4-1_armhf.deb ... 862s Unpacking r-cran-utf8 (1.2.4-1) ... 862s Selecting previously unselected package r-cran-vctrs. 862s Preparing to unpack .../132-r-cran-vctrs_0.6.5-1_armhf.deb ... 862s Unpacking r-cran-vctrs (0.6.5-1) ... 862s Selecting previously unselected package r-cran-pillar. 862s Preparing to unpack .../133-r-cran-pillar_1.10.1+dfsg-1_all.deb ... 862s Unpacking r-cran-pillar (1.10.1+dfsg-1) ... 862s Selecting previously unselected package r-cran-pkgconfig. 862s Preparing to unpack .../134-r-cran-pkgconfig_2.0.3-2build1_all.deb ... 862s Unpacking r-cran-pkgconfig (2.0.3-2build1) ... 862s Selecting previously unselected package r-cran-tibble. 862s Preparing to unpack .../135-r-cran-tibble_3.2.1+dfsg-3_armhf.deb ... 862s Unpacking r-cran-tibble (3.2.1+dfsg-3) ... 862s Selecting previously unselected package r-cran-withr. 862s Preparing to unpack .../136-r-cran-withr_3.0.2+dfsg-1_all.deb ... 862s Unpacking r-cran-withr (3.0.2+dfsg-1) ... 862s Selecting previously unselected package r-cran-ggplot2. 862s Preparing to unpack .../137-r-cran-ggplot2_3.5.1+dfsg-1_all.deb ... 862s Unpacking r-cran-ggplot2 (3.5.1+dfsg-1) ... 862s Selecting previously unselected package r-cran-xfun. 862s Preparing to unpack .../138-r-cran-xfun_0.51+dfsg-1_armhf.deb ... 862s Unpacking r-cran-xfun (0.51+dfsg-1) ... 862s Selecting previously unselected package r-cran-highr. 862s Preparing to unpack .../139-r-cran-highr_0.11+dfsg-1_all.deb ... 862s Unpacking r-cran-highr (0.11+dfsg-1) ... 862s Selecting previously unselected package r-cran-yaml. 862s Preparing to unpack .../140-r-cran-yaml_2.3.10-1_armhf.deb ... 862s Unpacking r-cran-yaml (2.3.10-1) ... 862s Selecting previously unselected package libjs-mathjax. 862s Preparing to unpack .../141-libjs-mathjax_2.7.9+dfsg-1_all.deb ... 862s Unpacking libjs-mathjax (2.7.9+dfsg-1) ... 863s Selecting previously unselected package r-cran-knitr. 863s Preparing to unpack .../142-r-cran-knitr_1.49+dfsg-1_all.deb ... 863s Unpacking r-cran-knitr (1.49+dfsg-1) ... 863s Selecting previously unselected package r-cran-markdown. 863s Preparing to unpack .../143-r-cran-markdown_1.13-1_all.deb ... 863s Unpacking r-cran-markdown (1.13-1) ... 863s Selecting previously unselected package r-cran-matrixstats. 863s Preparing to unpack .../144-r-cran-matrixstats_1.5.0-1_armhf.deb ... 863s Unpacking r-cran-matrixstats (1.5.0-1) ... 864s Setting up libgraphite2-3:armhf (1.3.14-2ubuntu1) ... 864s Setting up libpixman-1-0:armhf (0.44.0-3) ... 864s Setting up libsharpyuv0:armhf (1.5.0-0.1) ... 864s Setting up fonts-mathjax (2.7.9+dfsg-1) ... 864s Setting up liblerc4:armhf (4.0.0+ds-5ubuntu1) ... 864s Setting up libjs-mathjax (2.7.9+dfsg-1) ... 864s Setting up libxrender1:armhf (1:0.9.10-1.1build1) ... 864s Setting up libdatrie1:armhf (0.2.13-3build1) ... 864s Setting up libxcb-render0:armhf (1.17.0-2) ... 864s Setting up fonts-glyphicons-halflings (1.009~3.4.1+dfsg-3) ... 864s Setting up unzip (6.0-28ubuntu6) ... 864s Setting up x11-common (1:7.7+23ubuntu3) ... 864s Setting up libdeflate0:armhf (1.23-1) ... 864s Setting up linux-libc-dev:armhf (6.14.0-10.10) ... 864s Setting up libxcb-shm0:armhf (1.17.0-2) ... 864s Setting up libgomp1:armhf (15-20250222-0ubuntu1) ... 864s Setting up libjbig0:armhf (2.1-6.1ubuntu2) ... 864s Setting up libpcre2-16-0:armhf (10.45-1) ... 864s Setting up zip (3.0-14ubuntu2) ... 864s Setting up libpcre2-32-0:armhf (10.45-1) ... 864s Setting up libblas3:armhf (3.12.1-2) ... 864s update-alternatives: using /usr/lib/arm-linux-gnueabihf/blas/libblas.so.3 to provide /usr/lib/arm-linux-gnueabihf/libblas.so.3 (libblas.so.3-arm-linux-gnueabihf) in auto mode 864s Setting up libtirpc-dev:armhf (1.3.4+ds-1.3) ... 864s Setting up libpkgconf3:armhf (1.8.1-4) ... 864s Setting up rpcsvc-proto (1.4.2-0ubuntu7) ... 864s Setting up libfreetype6:armhf (2.13.3+dfsg-1) ... 864s Setting up fonts-dejavu-mono (2.37-8) ... 864s Setting up libmpc3:armhf (1.3.1-1build2) ... 864s Setting up libtcl8.6:armhf (8.6.16+dfsg-1) ... 864s Setting up icu-devtools (76.1-1ubuntu2) ... 864s Setting up fonts-dejavu-core (2.37-8) ... 864s Setting up pkgconf-bin (1.8.1-4) ... 864s Setting up libjpeg-turbo8:armhf (2.1.5-3ubuntu2) ... 864s Setting up libgfortran5:armhf (15-20250222-0ubuntu1) ... 864s Setting up libwebp7:armhf (1.5.0-0.1) ... 864s Setting up liblzma-dev:armhf (5.6.4-1) ... 864s Setting up libubsan1:armhf (15-20250222-0ubuntu1) ... 864s Setting up libpcre2-posix3:armhf (10.45-1) ... 864s Setting up libjs-highlight.js (9.18.5+dfsg1-2) ... 864s Setting up libcrypt-dev:armhf (1:4.4.38-1) ... 864s Setting up libasan8:armhf (15-20250222-0ubuntu1) ... 864s Setting up libharfbuzz0b:armhf (10.2.0-1) ... 864s Setting up libthai-data (0.1.29-2build1) ... 864s Setting up libxss1:armhf (1:1.2.3-1build3) ... 864s Setting up libpaper2:armhf (2.2.5-0.3) ... 864s Setting up libjs-jquery (3.6.1+dfsg+~3.5.14-1) ... 864s Setting up libgcc-14-dev:armhf (14.2.0-17ubuntu3) ... 864s Setting up libisl23:armhf (0.27-1) ... 864s Setting up libc-dev-bin (2.41-1ubuntu2) ... 864s Setting up libdeflate-dev:armhf (1.23-1) ... 864s Setting up node-normalize.css (8.0.1-5) ... 864s Setting up xdg-utils (1.2.1-2ubuntu1) ... 864s update-alternatives: using /usr/bin/xdg-open to provide /usr/bin/open (open) in auto mode 864s Setting up libcc1-0:armhf (15-20250222-0ubuntu1) ... 864s Setting up libblas-dev:armhf (3.12.1-2) ... 864s update-alternatives: using /usr/lib/arm-linux-gnueabihf/blas/libblas.so to provide /usr/lib/arm-linux-gnueabihf/libblas.so (libblas.so-arm-linux-gnueabihf) in auto mode 864s Setting up dctrl-tools (2.24-3build3) ... 864s Setting up libjs-bootstrap (3.4.1+dfsg-3) ... 864s Setting up cpp-14-arm-linux-gnueabihf (14.2.0-17ubuntu3) ... 864s Setting up libjpeg8:armhf (8c-2ubuntu11) ... 864s Setting up libgfortran-14-dev:armhf (14.2.0-17ubuntu3) ... 864s Setting up libice6:armhf (2:1.1.1-1) ... 864s Setting up liblapack3:armhf (3.12.1-2) ... 864s update-alternatives: using /usr/lib/arm-linux-gnueabihf/lapack/liblapack.so.3 to provide /usr/lib/arm-linux-gnueabihf/liblapack.so.3 (liblapack.so.3-arm-linux-gnueabihf) in auto mode 864s Setting up fontconfig-config (2.15.0-2ubuntu1) ... 865s Setting up gcc-14-arm-linux-gnueabihf (14.2.0-17ubuntu3) ... 865s Setting up libpaper-utils (2.2.5-0.3) ... 865s Setting up libjs-jquery-datatables (1.11.5+dfsg-2) ... 865s Setting up pkgconf:armhf (1.8.1-4) ... 865s Setting up libthai0:armhf (0.1.29-2build1) ... 865s Setting up liblapack-dev:armhf (3.12.1-2) ... 865s update-alternatives: using /usr/lib/arm-linux-gnueabihf/lapack/liblapack.so to provide /usr/lib/arm-linux-gnueabihf/liblapack.so (liblapack.so-arm-linux-gnueabihf) in auto mode 865s Setting up cpp-14 (14.2.0-17ubuntu3) ... 865s Setting up libtiff6:armhf (4.5.1+git230720-4ubuntu4) ... 865s Setting up libc6-dev:armhf (2.41-1ubuntu2) ... 865s Setting up libfontconfig1:armhf (2.15.0-2ubuntu1) ... 865s Setting up libstdc++-14-dev:armhf (14.2.0-17ubuntu3) ... 865s Setting up libsm6:armhf (2:1.2.4-1) ... 865s Setting up libicu-dev:armhf (76.1-1ubuntu2) ... 865s Setting up cpp-arm-linux-gnueabihf (4:14.2.0-1ubuntu1) ... 865s Setting up gfortran-14-arm-linux-gnueabihf (14.2.0-17ubuntu3) ... 865s Setting up libbz2-dev:armhf (1.0.8-6) ... 865s Setting up gcc-arm-linux-gnueabihf (4:14.2.0-1ubuntu1) ... 865s Setting up g++-14-arm-linux-gnueabihf (14.2.0-17ubuntu3) ... 865s Setting up fontconfig (2.15.0-2ubuntu1) ... 867s Regenerating fonts cache... done. 867s Setting up libjpeg-turbo8-dev:armhf (2.1.5-3ubuntu2) ... 867s Setting up libxft2:armhf (2.3.6-1build1) ... 867s Setting up libncurses-dev:armhf (6.5+20250216-2) ... 867s Setting up libpcre2-dev:armhf (10.45-1) ... 867s Setting up libtk8.6:armhf (8.6.16-1) ... 867s Setting up libpango-1.0-0:armhf (1.56.2-1) ... 867s Setting up libreadline-dev:armhf (8.2-6) ... 867s Setting up libcairo2:armhf (1.18.2-2) ... 867s Setting up gcc-14 (14.2.0-17ubuntu3) ... 867s Setting up gfortran-arm-linux-gnueabihf (4:14.2.0-1ubuntu1) ... 867s Setting up libxt6t64:armhf (1:1.2.1-1.2build1) ... 867s Setting up zlib1g-dev:armhf (1:1.3.dfsg+really1.3.1-1ubuntu1) ... 867s Setting up cpp (4:14.2.0-1ubuntu1) ... 867s Setting up g++-14 (14.2.0-17ubuntu3) ... 867s Setting up libpangoft2-1.0-0:armhf (1.56.2-1) ... 867s Setting up libjpeg8-dev:armhf (8c-2ubuntu11) ... 867s Setting up gfortran-14 (14.2.0-17ubuntu3) ... 867s Setting up libpangocairo-1.0-0:armhf (1.56.2-1) ... 867s Setting up g++-arm-linux-gnueabihf (4:14.2.0-1ubuntu1) ... 867s Setting up libpng-dev:armhf (1.6.47-1) ... 867s Setting up libjpeg-dev:armhf (8c-2ubuntu11) ... 867s Setting up gcc (4:14.2.0-1ubuntu1) ... 867s Setting up r-base-core (4.4.3-1) ... 867s Creating config file /etc/R/Renviron with new version 867s Setting up r-cran-labeling (0.4.3-1) ... 867s Setting up r-cran-lattice (0.22-6-1) ... 867s Setting up r-cran-nlme (3.1.167-1) ... 867s Setting up r-cran-farver (2.1.2-1) ... 867s Setting up g++ (4:14.2.0-1ubuntu1) ... 867s update-alternatives: using /usr/bin/g++ to provide /usr/bin/c++ (c++) in auto mode 867s Setting up r-cran-viridislite (0.4.2-2) ... 867s Setting up build-essential (12.10ubuntu1) ... 867s Setting up r-cran-commonmark (1.9.2-2) ... 867s Setting up r-cran-r6 (2.6.1-1) ... 867s Setting up r-cran-magrittr (2.0.3-1) ... 867s Setting up r-cran-rlang (1.1.5-1) ... 867s Setting up r-cran-matrixstats (1.5.0-1) ... 867s Setting up r-cran-xfun (0.51+dfsg-1) ... 867s Setting up r-cran-withr (3.0.2+dfsg-1) ... 867s Setting up r-cran-base64enc (0.1-3-3) ... 867s Setting up r-cran-yaml (2.3.10-1) ... 867s Setting up r-cran-evaluate (1.0.3-1) ... 867s Setting up r-cran-highr (0.11+dfsg-1) ... 867s Setting up r-cran-fansi (1.0.5-1) ... 867s Setting up r-cran-mass (7.3-64-1) ... 867s Setting up r-cran-glue (1.8.0-1) ... 867s Setting up r-cran-cli (3.6.4-1) ... 867s Setting up gfortran (4:14.2.0-1ubuntu1) ... 867s update-alternatives: using /usr/bin/gfortran to provide /usr/bin/f95 (f95) in auto mode 867s 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 867s update-alternatives: using /usr/bin/gfortran to provide /usr/bin/f77 (f77) in auto mode 867s 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 867s Setting up r-cran-lifecycle (1.0.4+dfsg-1) ... 867s Setting up r-cran-pkgconfig (2.0.3-2build1) ... 867s Setting up r-cran-utf8 (1.2.4-1) ... 867s Setting up r-cran-colorspace (2.1-1+dfsg-1) ... 867s Setting up r-cran-markdown (1.13-1) ... 867s Setting up r-cran-rcolorbrewer (1.1-3-1build1) ... 867s Setting up r-cran-isoband (0.2.7-1) ... 867s Setting up r-cran-gtable (0.3.6+dfsg-1) ... 867s Setting up r-cran-matrix (1.7-3-1) ... 867s Setting up r-cran-knitr (1.49+dfsg-1) ... 867s Setting up r-cran-mgcv (1.9-1-1) ... 867s Setting up r-cran-vctrs (0.6.5-1) ... 867s Setting up r-cran-pillar (1.10.1+dfsg-1) ... 867s Setting up r-base-dev (4.4.3-1) ... 867s Setting up r-cran-munsell (0.5.1-1) ... 867s Setting up r-cran-tibble (3.2.1+dfsg-3) ... 867s Setting up r-cran-scales (1.3.0-1) ... 867s Setting up pkg-r-autopkgtest (20231212ubuntu1) ... 867s Setting up r-cran-ggplot2 (3.5.1+dfsg-1) ... 867s Processing triggers for man-db (2.13.0-1) ... 869s Processing triggers for install-info (7.1.1-1) ... 869s Processing triggers for libc-bin (2.41-1ubuntu2) ... 883s autopkgtest [16:34:14]: test pkg-r-autopkgtest: /usr/share/dh-r/pkg-r-autopkgtest 883s autopkgtest [16:34:14]: test pkg-r-autopkgtest: [----------------------- 885s Test: Try to load the R library matrixStats 885s 885s R version 4.4.3 (2025-02-28) -- "Trophy Case" 885s Copyright (C) 2025 The R Foundation for Statistical Computing 885s Platform: arm-unknown-linux-gnueabihf (32-bit) 885s 885s R is free software and comes with ABSOLUTELY NO WARRANTY. 885s You are welcome to redistribute it under certain conditions. 885s Type 'license()' or 'licence()' for distribution details. 885s 885s R is a collaborative project with many contributors. 885s Type 'contributors()' for more information and 885s 'citation()' on how to cite R or R packages in publications. 885s 885s Type 'demo()' for some demos, 'help()' for on-line help, or 885s 'help.start()' for an HTML browser interface to help. 885s Type 'q()' to quit R. 885s 886s > library('matrixStats') 886s > 886s > 886s Other tests are currently unsupported! 886s They will be progressively added. 886s autopkgtest [16:34:17]: test pkg-r-autopkgtest: -----------------------] 890s pkg-r-autopkgtest PASS 890s autopkgtest [16:34:21]: test pkg-r-autopkgtest: - - - - - - - - - - results - - - - - - - - - - 894s autopkgtest [16:34:25]: @@@@@@@@@@@@@@@@@@@@ summary 894s run-unit-test PASS 894s pkg-r-autopkgtest PASS