0s autopkgtest [15:39:49]: starting date and time: 2025-03-15 15:39:49+0000 0s autopkgtest [15:39:49]: git checkout: 325255d2 Merge branch 'pin-any-arch' into 'ubuntu/production' 0s autopkgtest [15:39:49]: host juju-7f2275-prod-proposed-migration-environment-20; command line: /home/ubuntu/autopkgtest/runner/autopkgtest --output-dir /tmp/autopkgtest-work.iyad_hxa/out --timeout-copy=6000 --setup-commands /home/ubuntu/autopkgtest-cloud/worker-config-production/setup-canonical.sh --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 -- ssh -s /home/ubuntu/autopkgtest/ssh-setup/nova -- --flavor autopkgtest --security-groups autopkgtest-juju-7f2275-prod-proposed-migration-environment-20@bos03-arm64-18.secgroup --name adt-plucky-arm64-r-cran-matrixstats-20250315-153949-juju-7f2275-prod-proposed-migration-environment-20-1887113b-412b-40db-85c4-4da79e0a4b43 --image adt/ubuntu-plucky-arm64-server --keyname testbed-juju-7f2275-prod-proposed-migration-environment-20 --net-id=net_prod-proposed-migration -e TERM=linux -e ''"'"'http_proxy=http://squid.internal:3128'"'"'' -e ''"'"'https_proxy=http://squid.internal:3128'"'"'' -e ''"'"'no_proxy=127.0.0.1,127.0.1.1,login.ubuntu.com,localhost,localdomain,novalocal,internal,archive.ubuntu.com,ports.ubuntu.com,security.ubuntu.com,ddebs.ubuntu.com,changelogs.ubuntu.com,keyserver.ubuntu.com,launchpadlibrarian.net,launchpadcontent.net,launchpad.net,10.24.0.0/24,keystone.ps5.canonical.com,objectstorage.prodstack5.canonical.com,radosgw.ps5.canonical.com'"'"'' --mirror=http://ftpmaster.internal/ubuntu/ 115s autopkgtest [15:41:44]: testbed dpkg architecture: arm64 116s autopkgtest [15:41:44]: testbed apt version: 2.9.33 116s autopkgtest [15:41:44]: @@@@@@@@@@@@@@@@@@@@ test bed setup 116s autopkgtest [15:41:44]: testbed release detected to be: None 116s autopkgtest [15:41:45]: updating testbed package index (apt update) 117s Get:1 http://ftpmaster.internal/ubuntu plucky-proposed InRelease [126 kB] 117s Hit:2 http://ftpmaster.internal/ubuntu plucky InRelease 117s Hit:3 http://ftpmaster.internal/ubuntu plucky-updates InRelease 117s Hit:4 http://ftpmaster.internal/ubuntu plucky-security InRelease 117s Get:5 http://ftpmaster.internal/ubuntu plucky-proposed/main Sources [99.7 kB] 117s Get:6 http://ftpmaster.internal/ubuntu plucky-proposed/universe Sources [379 kB] 118s Get:7 http://ftpmaster.internal/ubuntu plucky-proposed/multiverse Sources [15.8 kB] 118s Get:8 http://ftpmaster.internal/ubuntu plucky-proposed/main arm64 Packages [111 kB] 118s Get:9 http://ftpmaster.internal/ubuntu plucky-proposed/main arm64 c-n-f Metadata [1856 B] 118s Get:10 http://ftpmaster.internal/ubuntu plucky-proposed/restricted arm64 c-n-f Metadata [116 B] 118s Get:11 http://ftpmaster.internal/ubuntu plucky-proposed/universe arm64 Packages [324 kB] 118s Get:12 http://ftpmaster.internal/ubuntu plucky-proposed/universe arm64 c-n-f Metadata [14.7 kB] 118s Get:13 http://ftpmaster.internal/ubuntu plucky-proposed/multiverse arm64 Packages [4948 B] 118s Get:14 http://ftpmaster.internal/ubuntu plucky-proposed/multiverse arm64 c-n-f Metadata [268 B] 119s Fetched 1078 kB in 2s (616 kB/s) 120s Reading package lists... 121s Reading package lists... 122s Building dependency tree... 122s Reading state information... 123s Calculating upgrade... 123s Calculating upgrade... 124s The following packages will be upgraded: 124s pinentry-curses python3-jinja2 strace 124s 3 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 124s Need to get 647 kB of archives. 124s After this operation, 11.3 kB of additional disk space will be used. 124s Get:1 http://ftpmaster.internal/ubuntu plucky/main arm64 strace arm64 6.13+ds-1ubuntu1 [499 kB] 125s Get:2 http://ftpmaster.internal/ubuntu plucky/main arm64 pinentry-curses arm64 1.3.1-2ubuntu3 [39.2 kB] 125s Get:3 http://ftpmaster.internal/ubuntu plucky/main arm64 python3-jinja2 all 3.1.5-2ubuntu1 [109 kB] 126s Fetched 647 kB in 1s (587 kB/s) 126s (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 ... 117701 files and directories currently installed.) 126s Preparing to unpack .../strace_6.13+ds-1ubuntu1_arm64.deb ... 126s Unpacking strace (6.13+ds-1ubuntu1) over (6.11-0ubuntu1) ... 126s Preparing to unpack .../pinentry-curses_1.3.1-2ubuntu3_arm64.deb ... 126s Unpacking pinentry-curses (1.3.1-2ubuntu3) over (1.3.1-2ubuntu2) ... 126s Preparing to unpack .../python3-jinja2_3.1.5-2ubuntu1_all.deb ... 126s Unpacking python3-jinja2 (3.1.5-2ubuntu1) over (3.1.5-2) ... 127s Setting up pinentry-curses (1.3.1-2ubuntu3) ... 127s Setting up python3-jinja2 (3.1.5-2ubuntu1) ... 127s Setting up strace (6.13+ds-1ubuntu1) ... 127s Processing triggers for man-db (2.13.0-1) ... 128s Reading package lists... 129s Building dependency tree... 129s Reading state information... 129s Solving dependencies... 130s The following packages will be REMOVED: 130s libnsl2* libpython3.12-minimal* libpython3.12-stdlib* libpython3.12t64* 130s libunwind8* linux-headers-6.11.0-8* linux-headers-6.11.0-8-generic* 130s linux-image-6.11.0-8-generic* linux-modules-6.11.0-8-generic* 130s linux-tools-6.11.0-8* linux-tools-6.11.0-8-generic* 130s 0 upgraded, 0 newly installed, 11 to remove and 5 not upgraded. 130s After this operation, 267 MB disk space will be freed. 130s (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 ... 117701 files and directories currently installed.) 130s Removing linux-tools-6.11.0-8-generic (6.11.0-8.8) ... 130s Removing linux-tools-6.11.0-8 (6.11.0-8.8) ... 130s Removing libpython3.12t64:arm64 (3.12.9-1) ... 130s Removing libpython3.12-stdlib:arm64 (3.12.9-1) ... 130s Removing libnsl2:arm64 (1.3.0-3build3) ... 130s Removing libpython3.12-minimal:arm64 (3.12.9-1) ... 131s Removing libunwind8:arm64 (1.6.2-3.1) ... 131s Removing linux-headers-6.11.0-8-generic (6.11.0-8.8) ... 131s Removing linux-headers-6.11.0-8 (6.11.0-8.8) ... 133s Removing linux-image-6.11.0-8-generic (6.11.0-8.8) ... 134s I: /boot/vmlinuz.old is now a symlink to vmlinuz-6.14.0-10-generic 134s I: /boot/initrd.img.old is now a symlink to initrd.img-6.14.0-10-generic 134s /etc/kernel/postrm.d/initramfs-tools: 134s update-initramfs: Deleting /boot/initrd.img-6.11.0-8-generic 134s /etc/kernel/postrm.d/zz-flash-kernel: 134s flash-kernel: Kernel 6.11.0-8-generic has been removed. 134s flash-kernel: A higher version (6.14.0-10-generic) is still installed, no reflashing required. 134s /etc/kernel/postrm.d/zz-update-grub: 134s Sourcing file `/etc/default/grub' 134s Sourcing file `/etc/default/grub.d/50-cloudimg-settings.cfg' 134s Generating grub configuration file ... 134s Found linux image: /boot/vmlinuz-6.14.0-10-generic 134s Found initrd image: /boot/initrd.img-6.14.0-10-generic 135s Warning: os-prober will not be executed to detect other bootable partitions. 135s Systems on them will not be added to the GRUB boot configuration. 135s Check GRUB_DISABLE_OS_PROBER documentation entry. 135s Adding boot menu entry for UEFI Firmware Settings ... 135s done 135s Removing linux-modules-6.11.0-8-generic (6.11.0-8.8) ... 135s Processing triggers for libc-bin (2.41-1ubuntu1) ... 136s (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 ... 81650 files and directories currently installed.) 136s Purging configuration files for linux-image-6.11.0-8-generic (6.11.0-8.8) ... 136s Purging configuration files for libpython3.12-minimal:arm64 (3.12.9-1) ... 136s Purging configuration files for linux-modules-6.11.0-8-generic (6.11.0-8.8) ... 136s autopkgtest [15:42:05]: upgrading testbed (apt dist-upgrade and autopurge) 136s Reading package lists... 137s Building dependency tree... 137s Reading state information... 137s Calculating upgrade...Starting pkgProblemResolver with broken count: 0 138s Starting 2 pkgProblemResolver with broken count: 0 138s Done 139s Entering ResolveByKeep 139s 139s Calculating upgrade... 140s The following packages will be upgraded: 140s libc-bin libc-dev-bin libc6 libc6-dev locales 140s 5 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 140s Need to get 9530 kB of archives. 140s After this operation, 0 B of additional disk space will be used. 140s Get:1 http://ftpmaster.internal/ubuntu plucky-proposed/main arm64 libc6-dev arm64 2.41-1ubuntu2 [1750 kB] 142s Get:2 http://ftpmaster.internal/ubuntu plucky-proposed/main arm64 libc-dev-bin arm64 2.41-1ubuntu2 [24.0 kB] 142s Get:3 http://ftpmaster.internal/ubuntu plucky-proposed/main arm64 libc6 arm64 2.41-1ubuntu2 [2910 kB] 145s Get:4 http://ftpmaster.internal/ubuntu plucky-proposed/main arm64 libc-bin arm64 2.41-1ubuntu2 [600 kB] 146s Get:5 http://ftpmaster.internal/ubuntu plucky-proposed/main arm64 locales all 2.41-1ubuntu2 [4246 kB] 151s Preconfiguring packages ... 151s Fetched 9530 kB in 11s (903 kB/s) 151s (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 ... 81647 files and directories currently installed.) 151s Preparing to unpack .../libc6-dev_2.41-1ubuntu2_arm64.deb ... 151s Unpacking libc6-dev:arm64 (2.41-1ubuntu2) over (2.41-1ubuntu1) ... 151s Preparing to unpack .../libc-dev-bin_2.41-1ubuntu2_arm64.deb ... 151s Unpacking libc-dev-bin (2.41-1ubuntu2) over (2.41-1ubuntu1) ... 151s Preparing to unpack .../libc6_2.41-1ubuntu2_arm64.deb ... 151s Unpacking libc6:arm64 (2.41-1ubuntu2) over (2.41-1ubuntu1) ... 152s Setting up libc6:arm64 (2.41-1ubuntu2) ... 152s (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 ... 81647 files and directories currently installed.) 152s Preparing to unpack .../libc-bin_2.41-1ubuntu2_arm64.deb ... 152s Unpacking libc-bin (2.41-1ubuntu2) over (2.41-1ubuntu1) ... 152s Setting up libc-bin (2.41-1ubuntu2) ... 152s (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 ... 81647 files and directories currently installed.) 152s Preparing to unpack .../locales_2.41-1ubuntu2_all.deb ... 152s Unpacking locales (2.41-1ubuntu2) over (2.41-1ubuntu1) ... 152s Setting up locales (2.41-1ubuntu2) ... 153s Generating locales (this might take a while)... 155s en_US.UTF-8... done 155s Generation complete. 155s Setting up libc-dev-bin (2.41-1ubuntu2) ... 155s Setting up libc6-dev:arm64 (2.41-1ubuntu2) ... 155s Processing triggers for man-db (2.13.0-1) ... 156s Processing triggers for systemd (257.3-1ubuntu3) ... 157s Reading package lists... 158s Building dependency tree... 158s Reading state information... 158s Starting pkgProblemResolver with broken count: 0 158s Starting 2 pkgProblemResolver with broken count: 0 158s Done 159s Solving dependencies... 159s 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 160s autopkgtest [15:42:29]: rebooting testbed after setup commands that affected boot 185s autopkgtest [15:42:54]: testbed running kernel: Linux 6.14.0-10-generic #10-Ubuntu SMP PREEMPT_DYNAMIC Wed Mar 12 15:45:31 UTC 2025 188s autopkgtest [15:42:57]: @@@@@@@@@@@@@@@@@@@@ apt-source r-cran-matrixstats 191s Get:1 http://ftpmaster.internal/ubuntu plucky/universe r-cran-matrixstats 1.5.0-1 (dsc) [2228 B] 191s Get:2 http://ftpmaster.internal/ubuntu plucky/universe r-cran-matrixstats 1.5.0-1 (tar) [212 kB] 191s Get:3 http://ftpmaster.internal/ubuntu plucky/universe r-cran-matrixstats 1.5.0-1 (diff) [4864 B] 191s gpgv: Signature made Sat Jan 18 11:46:01 2025 UTC 191s gpgv: using RSA key 724D609337113C710550D7473C26763F6C67E6E2 191s gpgv: Can't check signature: No public key 191s dpkg-source: warning: cannot verify inline signature for ./r-cran-matrixstats_1.5.0-1.dsc: no acceptable signature found 191s autopkgtest [15:43:00]: testing package r-cran-matrixstats version 1.5.0-1 193s autopkgtest [15:43:02]: build not needed 199s autopkgtest [15:43:08]: test run-unit-test: preparing testbed 199s Reading package lists... 199s Building dependency tree... 199s Reading state information... 200s Starting pkgProblemResolver with broken count: 0 200s Starting 2 pkgProblemResolver with broken count: 0 200s Done 201s The following NEW packages will be installed: 201s fontconfig fontconfig-config fonts-dejavu-core fonts-dejavu-mono 201s fonts-glyphicons-halflings fonts-mathjax libblas3 libcairo2 libdatrie1 201s libdeflate0 libfontconfig1 libgfortran5 libgomp1 libgraphite2-3 201s libharfbuzz0b libice6 libjbig0 libjpeg-turbo8 libjpeg8 libjs-bootstrap 201s libjs-highlight.js libjs-jquery libjs-jquery-datatables libjs-mathjax 201s liblapack3 liblerc4 libpango-1.0-0 libpangocairo-1.0-0 libpangoft2-1.0-0 201s libpaper-utils libpaper2 libpixman-1-0 libsharpyuv0 libsm6 libtcl8.6 201s libthai-data libthai0 libtiff6 libtk8.6 libwebp7 libxcb-render0 libxcb-shm0 201s libxft2 libxrender1 libxss1 libxt6t64 node-normalize.css r-base-core 201s r-cran-base64enc r-cran-cli r-cran-colorspace r-cran-commonmark 201s r-cran-digest r-cran-evaluate r-cran-fansi r-cran-farver r-cran-ggplot2 201s r-cran-glue r-cran-gtable r-cran-highr r-cran-isoband r-cran-knitr 201s r-cran-labeling r-cran-lattice r-cran-lifecycle r-cran-magrittr 201s r-cran-markdown r-cran-mass r-cran-matrix r-cran-matrixstats r-cran-mgcv 201s r-cran-microbenchmark r-cran-munsell r-cran-nlme r-cran-pillar 201s r-cran-pkgconfig r-cran-r.cache r-cran-r.devices r-cran-r.methodss3 201s r-cran-r.oo r-cran-r.rsp r-cran-r.utils r-cran-r6 r-cran-rcolorbrewer 201s r-cran-rlang r-cran-scales r-cran-tibble r-cran-utf8 r-cran-vctrs 201s r-cran-viridislite r-cran-withr r-cran-xfun r-cran-yaml tcl tcl8.6 unzip 201s x11-common xdg-utils zip 201s 0 upgraded, 99 newly installed, 0 to remove and 0 not upgraded. 201s Need to get 84.0 MB of archives. 201s After this operation, 190 MB of additional disk space will be used. 201s Get:1 http://ftpmaster.internal/ubuntu plucky/main arm64 fonts-dejavu-mono all 2.37-8 [502 kB] 202s Get:2 http://ftpmaster.internal/ubuntu plucky/main arm64 fonts-dejavu-core all 2.37-8 [835 kB] 203s Get:3 http://ftpmaster.internal/ubuntu plucky/main arm64 fontconfig-config arm64 2.15.0-2ubuntu1 [37.5 kB] 203s Get:4 http://ftpmaster.internal/ubuntu plucky/main arm64 libfontconfig1 arm64 2.15.0-2ubuntu1 [144 kB] 203s Get:5 http://ftpmaster.internal/ubuntu plucky/main arm64 fontconfig arm64 2.15.0-2ubuntu1 [191 kB] 204s Get:6 http://ftpmaster.internal/ubuntu plucky/universe arm64 fonts-glyphicons-halflings all 1.009~3.4.1+dfsg-3 [118 kB] 204s Get:7 http://ftpmaster.internal/ubuntu plucky/main arm64 fonts-mathjax all 2.7.9+dfsg-1 [2208 kB] 207s Get:8 http://ftpmaster.internal/ubuntu plucky/main arm64 libblas3 arm64 3.12.1-2 [161 kB] 207s Get:9 http://ftpmaster.internal/ubuntu plucky/main arm64 libpixman-1-0 arm64 0.44.0-3 [197 kB] 207s Get:10 http://ftpmaster.internal/ubuntu plucky/main arm64 libxcb-render0 arm64 1.17.0-2 [16.6 kB] 207s Get:11 http://ftpmaster.internal/ubuntu plucky/main arm64 libxcb-shm0 arm64 1.17.0-2 [5884 B] 207s Get:12 http://ftpmaster.internal/ubuntu plucky/main arm64 libxrender1 arm64 1:0.9.10-1.1build1 [18.8 kB] 207s Get:13 http://ftpmaster.internal/ubuntu plucky/main arm64 libcairo2 arm64 1.18.2-2 [560 kB] 208s Get:14 http://ftpmaster.internal/ubuntu plucky/main arm64 libdatrie1 arm64 0.2.13-3build1 [19.2 kB] 208s Get:15 http://ftpmaster.internal/ubuntu plucky/main arm64 libdeflate0 arm64 1.23-1 [46.2 kB] 208s Get:16 http://ftpmaster.internal/ubuntu plucky/main arm64 libgfortran5 arm64 15-20250222-0ubuntu1 [444 kB] 208s Get:17 http://ftpmaster.internal/ubuntu plucky/main arm64 libgomp1 arm64 15-20250222-0ubuntu1 [146 kB] 208s Get:18 http://ftpmaster.internal/ubuntu plucky/main arm64 libgraphite2-3 arm64 1.3.14-2ubuntu1 [70.6 kB] 208s Get:19 http://ftpmaster.internal/ubuntu plucky/main arm64 libharfbuzz0b arm64 10.2.0-1 [490 kB] 209s Get:20 http://ftpmaster.internal/ubuntu plucky/main arm64 x11-common all 1:7.7+23ubuntu3 [21.7 kB] 209s Get:21 http://ftpmaster.internal/ubuntu plucky/main arm64 libice6 arm64 2:1.1.1-1 [42.3 kB] 209s Get:22 http://ftpmaster.internal/ubuntu plucky/main arm64 libjpeg-turbo8 arm64 2.1.5-3ubuntu2 [165 kB] 209s Get:23 http://ftpmaster.internal/ubuntu plucky/main arm64 libjpeg8 arm64 8c-2ubuntu11 [2148 B] 209s Get:24 http://ftpmaster.internal/ubuntu plucky/universe arm64 libjs-bootstrap all 3.4.1+dfsg-3 [129 kB] 209s Get:25 http://ftpmaster.internal/ubuntu plucky/universe arm64 libjs-highlight.js all 9.18.5+dfsg1-2 [385 kB] 210s Get:26 http://ftpmaster.internal/ubuntu plucky/main arm64 libjs-jquery all 3.6.1+dfsg+~3.5.14-1 [328 kB] 210s Get:27 http://ftpmaster.internal/ubuntu plucky/universe arm64 libjs-jquery-datatables all 1.11.5+dfsg-2 [146 kB] 210s Get:28 http://ftpmaster.internal/ubuntu plucky/main arm64 liblapack3 arm64 3.12.1-2 [2307 kB] 213s Get:29 http://ftpmaster.internal/ubuntu plucky/main arm64 liblerc4 arm64 4.0.0+ds-5ubuntu1 [167 kB] 213s Get:30 http://ftpmaster.internal/ubuntu plucky/main arm64 libthai-data all 0.1.29-2build1 [158 kB] 214s Get:31 http://ftpmaster.internal/ubuntu plucky/main arm64 libthai0 arm64 0.1.29-2build1 [18.2 kB] 214s Get:32 http://ftpmaster.internal/ubuntu plucky/main arm64 libpango-1.0-0 arm64 1.56.2-1 [237 kB] 214s Get:33 http://ftpmaster.internal/ubuntu plucky/main arm64 libpangoft2-1.0-0 arm64 1.56.2-1 [49.5 kB] 214s Get:34 http://ftpmaster.internal/ubuntu plucky/main arm64 libpangocairo-1.0-0 arm64 1.56.2-1 [27.6 kB] 214s Get:35 http://ftpmaster.internal/ubuntu plucky/main arm64 libpaper2 arm64 2.2.5-0.3 [17.3 kB] 214s Get:36 http://ftpmaster.internal/ubuntu plucky/main arm64 libpaper-utils arm64 2.2.5-0.3 [15.4 kB] 214s Get:37 http://ftpmaster.internal/ubuntu plucky/main arm64 libsharpyuv0 arm64 1.5.0-0.1 [16.9 kB] 214s Get:38 http://ftpmaster.internal/ubuntu plucky/main arm64 libsm6 arm64 2:1.2.4-1 [16.4 kB] 214s Get:39 http://ftpmaster.internal/ubuntu plucky/main arm64 libtcl8.6 arm64 8.6.16+dfsg-1 [987 kB] 215s Get:40 http://ftpmaster.internal/ubuntu plucky/main arm64 libjbig0 arm64 2.1-6.1ubuntu2 [29.3 kB] 215s Get:41 http://ftpmaster.internal/ubuntu plucky/main arm64 libwebp7 arm64 1.5.0-0.1 [194 kB] 215s Get:42 http://ftpmaster.internal/ubuntu plucky/main arm64 libtiff6 arm64 4.5.1+git230720-4ubuntu4 [193 kB] 216s Get:43 http://ftpmaster.internal/ubuntu plucky/main arm64 libxft2 arm64 2.3.6-1build1 [44.1 kB] 216s Get:44 http://ftpmaster.internal/ubuntu plucky/main arm64 libxss1 arm64 1:1.2.3-1build3 [7244 B] 216s Get:45 http://ftpmaster.internal/ubuntu plucky/main arm64 libtk8.6 arm64 8.6.16-1 [776 kB] 217s Get:46 http://ftpmaster.internal/ubuntu plucky/main arm64 libxt6t64 arm64 1:1.2.1-1.2build1 [168 kB] 217s Get:47 http://ftpmaster.internal/ubuntu plucky/universe arm64 node-normalize.css all 8.0.1-5 [10.8 kB] 217s Get:48 http://ftpmaster.internal/ubuntu plucky/main arm64 zip arm64 3.0-14ubuntu2 [173 kB] 217s Get:49 http://ftpmaster.internal/ubuntu plucky/main arm64 unzip arm64 6.0-28ubuntu6 [178 kB] 217s Get:50 http://ftpmaster.internal/ubuntu plucky/main arm64 xdg-utils all 1.2.1-2ubuntu1 [66.0 kB] 217s Get:51 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-base-core arm64 4.4.3-1 [28.4 MB] 250s Get:52 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-base64enc arm64 0.1-3-3 [27.4 kB] 250s Get:53 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-cli arm64 3.6.4-1 [1374 kB] 252s Get:54 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-colorspace arm64 2.1-1+dfsg-1 [1563 kB] 254s Get:55 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-commonmark arm64 1.9.2-2 [129 kB] 254s Get:56 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-digest arm64 0.6.37-1 [200 kB] 255s Get:57 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-evaluate all 1.0.3-1 [114 kB] 255s Get:58 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-fansi arm64 1.0.5-1 [616 kB] 255s Get:59 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-farver arm64 2.1.2-1 [1344 kB] 257s Get:60 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-glue arm64 1.8.0-1 [163 kB] 257s Get:61 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-rlang arm64 1.1.5-1 [1707 kB] 259s Get:62 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-lifecycle all 1.0.4+dfsg-1 [110 kB] 259s Get:63 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-gtable all 0.3.6+dfsg-1 [199 kB] 260s Get:64 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-isoband arm64 0.2.7-1 [1481 kB] 261s Get:65 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-mass arm64 7.3-64-1 [1110 kB] 262s Get:66 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-lattice arm64 0.22-6-1 [1363 kB] 264s Get:67 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-nlme arm64 3.1.167-1 [2311 kB] 267s Get:68 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-matrix arm64 1.7-3-1 [4045 kB] 272s Get:69 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-mgcv arm64 1.9-1-1 [3248 kB] 275s Get:70 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-labeling all 0.4.3-1 [62.1 kB] 275s Get:71 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-munsell all 0.5.1-1 [213 kB] 275s Get:72 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-r6 all 2.6.1-1 [101 kB] 276s Get:73 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-rcolorbrewer all 1.1-3-1build1 [55.4 kB] 276s Get:74 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-viridislite all 0.4.2-2 [1088 kB] 277s Get:75 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-scales all 1.3.0-1 [603 kB] 277s Get:76 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-magrittr arm64 2.0.3-1 [154 kB] 278s Get:77 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-utf8 arm64 1.2.4-1 [140 kB] 278s Get:78 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-vctrs arm64 0.6.5-1 [1327 kB] 279s Get:79 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-pillar all 1.10.1+dfsg-1 [453 kB] 280s Get:80 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-pkgconfig all 2.0.3-2build1 [19.7 kB] 280s Get:81 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-tibble arm64 3.2.1+dfsg-3 [420 kB] 280s Get:82 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-withr all 3.0.2+dfsg-1 [214 kB] 280s Get:83 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-ggplot2 all 3.5.1+dfsg-1 [3940 kB] 285s Get:84 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-xfun arm64 0.51+dfsg-1 [573 kB] 286s Get:85 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-highr all 0.11+dfsg-1 [38.5 kB] 286s Get:86 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-yaml arm64 2.3.10-1 [108 kB] 286s Get:87 http://ftpmaster.internal/ubuntu plucky/main arm64 libjs-mathjax all 2.7.9+dfsg-1 [5665 kB] 294s Get:88 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-knitr all 1.49+dfsg-1 [859 kB] 294s Get:89 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-markdown all 1.13-1 [162 kB] 294s Get:90 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-matrixstats arm64 1.5.0-1 [496 kB] 294s Get:91 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-microbenchmark arm64 1.5.0-1 [67.5 kB] 294s Get:92 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-r.methodss3 all 1.8.2-1 [84.0 kB] 294s Get:93 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-r.oo all 1.27.0-1 [979 kB] 296s Get:94 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-r.utils all 2.13.0-1 [1423 kB] 297s Get:95 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-r.cache all 0.16.0-1 [113 kB] 297s Get:96 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-r.devices all 2.17.2+ds-1 [398 kB] 298s Get:97 http://ftpmaster.internal/ubuntu plucky/main arm64 tcl8.6 arm64 8.6.16+dfsg-1 [14.8 kB] 298s Get:98 http://ftpmaster.internal/ubuntu plucky/main arm64 tcl arm64 8.6.14build1 [4124 B] 298s Get:99 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-r.rsp all 0.46.0+ds-1 [1412 kB] 300s Preconfiguring packages ... 300s Fetched 84.0 MB in 1min 38s (856 kB/s) 300s Selecting previously unselected package fonts-dejavu-mono. 300s (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 ... 81647 files and directories currently installed.) 300s Preparing to unpack .../00-fonts-dejavu-mono_2.37-8_all.deb ... 300s Unpacking fonts-dejavu-mono (2.37-8) ... 300s Selecting previously unselected package fonts-dejavu-core. 300s Preparing to unpack .../01-fonts-dejavu-core_2.37-8_all.deb ... 300s Unpacking fonts-dejavu-core (2.37-8) ... 300s Selecting previously unselected package fontconfig-config. 300s Preparing to unpack .../02-fontconfig-config_2.15.0-2ubuntu1_arm64.deb ... 300s Unpacking fontconfig-config (2.15.0-2ubuntu1) ... 300s Selecting previously unselected package libfontconfig1:arm64. 300s Preparing to unpack .../03-libfontconfig1_2.15.0-2ubuntu1_arm64.deb ... 300s Unpacking libfontconfig1:arm64 (2.15.0-2ubuntu1) ... 300s Selecting previously unselected package fontconfig. 301s Preparing to unpack .../04-fontconfig_2.15.0-2ubuntu1_arm64.deb ... 301s Unpacking fontconfig (2.15.0-2ubuntu1) ... 301s Selecting previously unselected package fonts-glyphicons-halflings. 301s Preparing to unpack .../05-fonts-glyphicons-halflings_1.009~3.4.1+dfsg-3_all.deb ... 301s Unpacking fonts-glyphicons-halflings (1.009~3.4.1+dfsg-3) ... 301s Selecting previously unselected package fonts-mathjax. 301s Preparing to unpack .../06-fonts-mathjax_2.7.9+dfsg-1_all.deb ... 301s Unpacking fonts-mathjax (2.7.9+dfsg-1) ... 301s Selecting previously unselected package libblas3:arm64. 301s Preparing to unpack .../07-libblas3_3.12.1-2_arm64.deb ... 301s Unpacking libblas3:arm64 (3.12.1-2) ... 301s Selecting previously unselected package libpixman-1-0:arm64. 301s Preparing to unpack .../08-libpixman-1-0_0.44.0-3_arm64.deb ... 301s Unpacking libpixman-1-0:arm64 (0.44.0-3) ... 301s Selecting previously unselected package libxcb-render0:arm64. 301s Preparing to unpack .../09-libxcb-render0_1.17.0-2_arm64.deb ... 301s Unpacking libxcb-render0:arm64 (1.17.0-2) ... 301s Selecting previously unselected package libxcb-shm0:arm64. 301s Preparing to unpack .../10-libxcb-shm0_1.17.0-2_arm64.deb ... 301s Unpacking libxcb-shm0:arm64 (1.17.0-2) ... 301s Selecting previously unselected package libxrender1:arm64. 301s Preparing to unpack .../11-libxrender1_1%3a0.9.10-1.1build1_arm64.deb ... 301s Unpacking libxrender1:arm64 (1:0.9.10-1.1build1) ... 301s Selecting previously unselected package libcairo2:arm64. 301s Preparing to unpack .../12-libcairo2_1.18.2-2_arm64.deb ... 301s Unpacking libcairo2:arm64 (1.18.2-2) ... 301s Selecting previously unselected package libdatrie1:arm64. 301s Preparing to unpack .../13-libdatrie1_0.2.13-3build1_arm64.deb ... 301s Unpacking libdatrie1:arm64 (0.2.13-3build1) ... 301s Selecting previously unselected package libdeflate0:arm64. 301s Preparing to unpack .../14-libdeflate0_1.23-1_arm64.deb ... 301s Unpacking libdeflate0:arm64 (1.23-1) ... 301s Selecting previously unselected package libgfortran5:arm64. 301s Preparing to unpack .../15-libgfortran5_15-20250222-0ubuntu1_arm64.deb ... 301s Unpacking libgfortran5:arm64 (15-20250222-0ubuntu1) ... 301s Selecting previously unselected package libgomp1:arm64. 301s Preparing to unpack .../16-libgomp1_15-20250222-0ubuntu1_arm64.deb ... 301s Unpacking libgomp1:arm64 (15-20250222-0ubuntu1) ... 301s Selecting previously unselected package libgraphite2-3:arm64. 301s Preparing to unpack .../17-libgraphite2-3_1.3.14-2ubuntu1_arm64.deb ... 301s Unpacking libgraphite2-3:arm64 (1.3.14-2ubuntu1) ... 301s Selecting previously unselected package libharfbuzz0b:arm64. 301s Preparing to unpack .../18-libharfbuzz0b_10.2.0-1_arm64.deb ... 301s Unpacking libharfbuzz0b:arm64 (10.2.0-1) ... 301s Selecting previously unselected package x11-common. 301s Preparing to unpack .../19-x11-common_1%3a7.7+23ubuntu3_all.deb ... 301s Unpacking x11-common (1:7.7+23ubuntu3) ... 301s Selecting previously unselected package libice6:arm64. 301s Preparing to unpack .../20-libice6_2%3a1.1.1-1_arm64.deb ... 301s Unpacking libice6:arm64 (2:1.1.1-1) ... 301s Selecting previously unselected package libjpeg-turbo8:arm64. 301s Preparing to unpack .../21-libjpeg-turbo8_2.1.5-3ubuntu2_arm64.deb ... 301s Unpacking libjpeg-turbo8:arm64 (2.1.5-3ubuntu2) ... 301s Selecting previously unselected package libjpeg8:arm64. 301s Preparing to unpack .../22-libjpeg8_8c-2ubuntu11_arm64.deb ... 301s Unpacking libjpeg8:arm64 (8c-2ubuntu11) ... 301s Selecting previously unselected package libjs-bootstrap. 301s Preparing to unpack .../23-libjs-bootstrap_3.4.1+dfsg-3_all.deb ... 301s Unpacking libjs-bootstrap (3.4.1+dfsg-3) ... 301s Selecting previously unselected package libjs-highlight.js. 301s Preparing to unpack .../24-libjs-highlight.js_9.18.5+dfsg1-2_all.deb ... 301s Unpacking libjs-highlight.js (9.18.5+dfsg1-2) ... 301s Selecting previously unselected package libjs-jquery. 301s Preparing to unpack .../25-libjs-jquery_3.6.1+dfsg+~3.5.14-1_all.deb ... 301s Unpacking libjs-jquery (3.6.1+dfsg+~3.5.14-1) ... 302s Selecting previously unselected package libjs-jquery-datatables. 302s Preparing to unpack .../26-libjs-jquery-datatables_1.11.5+dfsg-2_all.deb ... 302s Unpacking libjs-jquery-datatables (1.11.5+dfsg-2) ... 302s Selecting previously unselected package liblapack3:arm64. 302s Preparing to unpack .../27-liblapack3_3.12.1-2_arm64.deb ... 302s Unpacking liblapack3:arm64 (3.12.1-2) ... 302s Selecting previously unselected package liblerc4:arm64. 302s Preparing to unpack .../28-liblerc4_4.0.0+ds-5ubuntu1_arm64.deb ... 302s Unpacking liblerc4:arm64 (4.0.0+ds-5ubuntu1) ... 302s Selecting previously unselected package libthai-data. 302s Preparing to unpack .../29-libthai-data_0.1.29-2build1_all.deb ... 302s Unpacking libthai-data (0.1.29-2build1) ... 302s Selecting previously unselected package libthai0:arm64. 302s Preparing to unpack .../30-libthai0_0.1.29-2build1_arm64.deb ... 302s Unpacking libthai0:arm64 (0.1.29-2build1) ... 302s Selecting previously unselected package libpango-1.0-0:arm64. 302s Preparing to unpack .../31-libpango-1.0-0_1.56.2-1_arm64.deb ... 302s Unpacking libpango-1.0-0:arm64 (1.56.2-1) ... 302s Selecting previously unselected package libpangoft2-1.0-0:arm64. 302s Preparing to unpack .../32-libpangoft2-1.0-0_1.56.2-1_arm64.deb ... 302s Unpacking libpangoft2-1.0-0:arm64 (1.56.2-1) ... 302s Selecting previously unselected package libpangocairo-1.0-0:arm64. 302s Preparing to unpack .../33-libpangocairo-1.0-0_1.56.2-1_arm64.deb ... 302s Unpacking libpangocairo-1.0-0:arm64 (1.56.2-1) ... 302s Selecting previously unselected package libpaper2:arm64. 302s Preparing to unpack .../34-libpaper2_2.2.5-0.3_arm64.deb ... 302s Unpacking libpaper2:arm64 (2.2.5-0.3) ... 302s Selecting previously unselected package libpaper-utils. 302s Preparing to unpack .../35-libpaper-utils_2.2.5-0.3_arm64.deb ... 302s Unpacking libpaper-utils (2.2.5-0.3) ... 302s Selecting previously unselected package libsharpyuv0:arm64. 302s Preparing to unpack .../36-libsharpyuv0_1.5.0-0.1_arm64.deb ... 302s Unpacking libsharpyuv0:arm64 (1.5.0-0.1) ... 302s Selecting previously unselected package libsm6:arm64. 302s Preparing to unpack .../37-libsm6_2%3a1.2.4-1_arm64.deb ... 302s Unpacking libsm6:arm64 (2:1.2.4-1) ... 302s Selecting previously unselected package libtcl8.6:arm64. 302s Preparing to unpack .../38-libtcl8.6_8.6.16+dfsg-1_arm64.deb ... 302s Unpacking libtcl8.6:arm64 (8.6.16+dfsg-1) ... 302s Selecting previously unselected package libjbig0:arm64. 302s Preparing to unpack .../39-libjbig0_2.1-6.1ubuntu2_arm64.deb ... 302s Unpacking libjbig0:arm64 (2.1-6.1ubuntu2) ... 302s Selecting previously unselected package libwebp7:arm64. 302s Preparing to unpack .../40-libwebp7_1.5.0-0.1_arm64.deb ... 302s Unpacking libwebp7:arm64 (1.5.0-0.1) ... 302s Selecting previously unselected package libtiff6:arm64. 302s Preparing to unpack .../41-libtiff6_4.5.1+git230720-4ubuntu4_arm64.deb ... 302s Unpacking libtiff6:arm64 (4.5.1+git230720-4ubuntu4) ... 302s Selecting previously unselected package libxft2:arm64. 302s Preparing to unpack .../42-libxft2_2.3.6-1build1_arm64.deb ... 302s Unpacking libxft2:arm64 (2.3.6-1build1) ... 302s Selecting previously unselected package libxss1:arm64. 302s Preparing to unpack .../43-libxss1_1%3a1.2.3-1build3_arm64.deb ... 302s Unpacking libxss1:arm64 (1:1.2.3-1build3) ... 302s Selecting previously unselected package libtk8.6:arm64. 302s Preparing to unpack .../44-libtk8.6_8.6.16-1_arm64.deb ... 302s Unpacking libtk8.6:arm64 (8.6.16-1) ... 302s Selecting previously unselected package libxt6t64:arm64. 302s Preparing to unpack .../45-libxt6t64_1%3a1.2.1-1.2build1_arm64.deb ... 302s Unpacking libxt6t64:arm64 (1:1.2.1-1.2build1) ... 302s Selecting previously unselected package node-normalize.css. 302s Preparing to unpack .../46-node-normalize.css_8.0.1-5_all.deb ... 302s Unpacking node-normalize.css (8.0.1-5) ... 302s Selecting previously unselected package zip. 302s Preparing to unpack .../47-zip_3.0-14ubuntu2_arm64.deb ... 302s Unpacking zip (3.0-14ubuntu2) ... 302s Selecting previously unselected package unzip. 302s Preparing to unpack .../48-unzip_6.0-28ubuntu6_arm64.deb ... 302s Unpacking unzip (6.0-28ubuntu6) ... 302s Selecting previously unselected package xdg-utils. 302s Preparing to unpack .../49-xdg-utils_1.2.1-2ubuntu1_all.deb ... 302s Unpacking xdg-utils (1.2.1-2ubuntu1) ... 303s Selecting previously unselected package r-base-core. 303s Preparing to unpack .../50-r-base-core_4.4.3-1_arm64.deb ... 303s Unpacking r-base-core (4.4.3-1) ... 303s Selecting previously unselected package r-cran-base64enc. 303s Preparing to unpack .../51-r-cran-base64enc_0.1-3-3_arm64.deb ... 303s Unpacking r-cran-base64enc (0.1-3-3) ... 303s Selecting previously unselected package r-cran-cli. 303s Preparing to unpack .../52-r-cran-cli_3.6.4-1_arm64.deb ... 303s Unpacking r-cran-cli (3.6.4-1) ... 303s Selecting previously unselected package r-cran-colorspace. 303s Preparing to unpack .../53-r-cran-colorspace_2.1-1+dfsg-1_arm64.deb ... 303s Unpacking r-cran-colorspace (2.1-1+dfsg-1) ... 303s Selecting previously unselected package r-cran-commonmark. 303s Preparing to unpack .../54-r-cran-commonmark_1.9.2-2_arm64.deb ... 303s Unpacking r-cran-commonmark (1.9.2-2) ... 303s Selecting previously unselected package r-cran-digest. 303s Preparing to unpack .../55-r-cran-digest_0.6.37-1_arm64.deb ... 303s Unpacking r-cran-digest (0.6.37-1) ... 303s Selecting previously unselected package r-cran-evaluate. 303s Preparing to unpack .../56-r-cran-evaluate_1.0.3-1_all.deb ... 303s Unpacking r-cran-evaluate (1.0.3-1) ... 303s Selecting previously unselected package r-cran-fansi. 303s Preparing to unpack .../57-r-cran-fansi_1.0.5-1_arm64.deb ... 303s Unpacking r-cran-fansi (1.0.5-1) ... 303s Selecting previously unselected package r-cran-farver. 303s Preparing to unpack .../58-r-cran-farver_2.1.2-1_arm64.deb ... 303s Unpacking r-cran-farver (2.1.2-1) ... 303s Selecting previously unselected package r-cran-glue. 303s Preparing to unpack .../59-r-cran-glue_1.8.0-1_arm64.deb ... 303s Unpacking r-cran-glue (1.8.0-1) ... 303s Selecting previously unselected package r-cran-rlang. 303s Preparing to unpack .../60-r-cran-rlang_1.1.5-1_arm64.deb ... 303s Unpacking r-cran-rlang (1.1.5-1) ... 303s Selecting previously unselected package r-cran-lifecycle. 303s Preparing to unpack .../61-r-cran-lifecycle_1.0.4+dfsg-1_all.deb ... 303s Unpacking r-cran-lifecycle (1.0.4+dfsg-1) ... 303s Selecting previously unselected package r-cran-gtable. 303s Preparing to unpack .../62-r-cran-gtable_0.3.6+dfsg-1_all.deb ... 303s Unpacking r-cran-gtable (0.3.6+dfsg-1) ... 303s Selecting previously unselected package r-cran-isoband. 303s Preparing to unpack .../63-r-cran-isoband_0.2.7-1_arm64.deb ... 303s Unpacking r-cran-isoband (0.2.7-1) ... 303s Selecting previously unselected package r-cran-mass. 304s Preparing to unpack .../64-r-cran-mass_7.3-64-1_arm64.deb ... 304s Unpacking r-cran-mass (7.3-64-1) ... 304s Selecting previously unselected package r-cran-lattice. 304s Preparing to unpack .../65-r-cran-lattice_0.22-6-1_arm64.deb ... 304s Unpacking r-cran-lattice (0.22-6-1) ... 304s Selecting previously unselected package r-cran-nlme. 304s Preparing to unpack .../66-r-cran-nlme_3.1.167-1_arm64.deb ... 304s Unpacking r-cran-nlme (3.1.167-1) ... 304s Selecting previously unselected package r-cran-matrix. 304s Preparing to unpack .../67-r-cran-matrix_1.7-3-1_arm64.deb ... 304s Unpacking r-cran-matrix (1.7-3-1) ... 304s Selecting previously unselected package r-cran-mgcv. 304s Preparing to unpack .../68-r-cran-mgcv_1.9-1-1_arm64.deb ... 304s Unpacking r-cran-mgcv (1.9-1-1) ... 304s Selecting previously unselected package r-cran-labeling. 304s Preparing to unpack .../69-r-cran-labeling_0.4.3-1_all.deb ... 304s Unpacking r-cran-labeling (0.4.3-1) ... 304s Selecting previously unselected package r-cran-munsell. 304s Preparing to unpack .../70-r-cran-munsell_0.5.1-1_all.deb ... 304s Unpacking r-cran-munsell (0.5.1-1) ... 304s Selecting previously unselected package r-cran-r6. 304s Preparing to unpack .../71-r-cran-r6_2.6.1-1_all.deb ... 304s Unpacking r-cran-r6 (2.6.1-1) ... 304s Selecting previously unselected package r-cran-rcolorbrewer. 304s Preparing to unpack .../72-r-cran-rcolorbrewer_1.1-3-1build1_all.deb ... 304s Unpacking r-cran-rcolorbrewer (1.1-3-1build1) ... 304s Selecting previously unselected package r-cran-viridislite. 304s Preparing to unpack .../73-r-cran-viridislite_0.4.2-2_all.deb ... 304s Unpacking r-cran-viridislite (0.4.2-2) ... 304s Selecting previously unselected package r-cran-scales. 304s Preparing to unpack .../74-r-cran-scales_1.3.0-1_all.deb ... 304s Unpacking r-cran-scales (1.3.0-1) ... 304s Selecting previously unselected package r-cran-magrittr. 304s Preparing to unpack .../75-r-cran-magrittr_2.0.3-1_arm64.deb ... 304s Unpacking r-cran-magrittr (2.0.3-1) ... 304s Selecting previously unselected package r-cran-utf8. 304s Preparing to unpack .../76-r-cran-utf8_1.2.4-1_arm64.deb ... 304s Unpacking r-cran-utf8 (1.2.4-1) ... 304s Selecting previously unselected package r-cran-vctrs. 304s Preparing to unpack .../77-r-cran-vctrs_0.6.5-1_arm64.deb ... 304s Unpacking r-cran-vctrs (0.6.5-1) ... 304s Selecting previously unselected package r-cran-pillar. 304s Preparing to unpack .../78-r-cran-pillar_1.10.1+dfsg-1_all.deb ... 304s Unpacking r-cran-pillar (1.10.1+dfsg-1) ... 304s Selecting previously unselected package r-cran-pkgconfig. 304s Preparing to unpack .../79-r-cran-pkgconfig_2.0.3-2build1_all.deb ... 304s Unpacking r-cran-pkgconfig (2.0.3-2build1) ... 304s Selecting previously unselected package r-cran-tibble. 304s Preparing to unpack .../80-r-cran-tibble_3.2.1+dfsg-3_arm64.deb ... 304s Unpacking r-cran-tibble (3.2.1+dfsg-3) ... 304s Selecting previously unselected package r-cran-withr. 304s Preparing to unpack .../81-r-cran-withr_3.0.2+dfsg-1_all.deb ... 304s Unpacking r-cran-withr (3.0.2+dfsg-1) ... 304s Selecting previously unselected package r-cran-ggplot2. 304s Preparing to unpack .../82-r-cran-ggplot2_3.5.1+dfsg-1_all.deb ... 304s Unpacking r-cran-ggplot2 (3.5.1+dfsg-1) ... 304s Selecting previously unselected package r-cran-xfun. 305s Preparing to unpack .../83-r-cran-xfun_0.51+dfsg-1_arm64.deb ... 305s Unpacking r-cran-xfun (0.51+dfsg-1) ... 305s Selecting previously unselected package r-cran-highr. 305s Preparing to unpack .../84-r-cran-highr_0.11+dfsg-1_all.deb ... 305s Unpacking r-cran-highr (0.11+dfsg-1) ... 305s Selecting previously unselected package r-cran-yaml. 305s Preparing to unpack .../85-r-cran-yaml_2.3.10-1_arm64.deb ... 305s Unpacking r-cran-yaml (2.3.10-1) ... 305s Selecting previously unselected package libjs-mathjax. 305s Preparing to unpack .../86-libjs-mathjax_2.7.9+dfsg-1_all.deb ... 305s Unpacking libjs-mathjax (2.7.9+dfsg-1) ... 305s Selecting previously unselected package r-cran-knitr. 305s Preparing to unpack .../87-r-cran-knitr_1.49+dfsg-1_all.deb ... 305s Unpacking r-cran-knitr (1.49+dfsg-1) ... 305s Selecting previously unselected package r-cran-markdown. 305s Preparing to unpack .../88-r-cran-markdown_1.13-1_all.deb ... 305s Unpacking r-cran-markdown (1.13-1) ... 305s Selecting previously unselected package r-cran-matrixstats. 305s Preparing to unpack .../89-r-cran-matrixstats_1.5.0-1_arm64.deb ... 305s Unpacking r-cran-matrixstats (1.5.0-1) ... 305s Selecting previously unselected package r-cran-microbenchmark. 305s Preparing to unpack .../90-r-cran-microbenchmark_1.5.0-1_arm64.deb ... 305s Unpacking r-cran-microbenchmark (1.5.0-1) ... 305s Selecting previously unselected package r-cran-r.methodss3. 305s Preparing to unpack .../91-r-cran-r.methodss3_1.8.2-1_all.deb ... 305s Unpacking r-cran-r.methodss3 (1.8.2-1) ... 305s Selecting previously unselected package r-cran-r.oo. 306s Preparing to unpack .../92-r-cran-r.oo_1.27.0-1_all.deb ... 306s Unpacking r-cran-r.oo (1.27.0-1) ... 306s Selecting previously unselected package r-cran-r.utils. 306s Preparing to unpack .../93-r-cran-r.utils_2.13.0-1_all.deb ... 306s Unpacking r-cran-r.utils (2.13.0-1) ... 306s Selecting previously unselected package r-cran-r.cache. 306s Preparing to unpack .../94-r-cran-r.cache_0.16.0-1_all.deb ... 306s Unpacking r-cran-r.cache (0.16.0-1) ... 306s Selecting previously unselected package r-cran-r.devices. 306s Preparing to unpack .../95-r-cran-r.devices_2.17.2+ds-1_all.deb ... 306s Unpacking r-cran-r.devices (2.17.2+ds-1) ... 306s Selecting previously unselected package tcl8.6. 306s Preparing to unpack .../96-tcl8.6_8.6.16+dfsg-1_arm64.deb ... 306s Unpacking tcl8.6 (8.6.16+dfsg-1) ... 306s Selecting previously unselected package tcl. 306s Preparing to unpack .../97-tcl_8.6.14build1_arm64.deb ... 306s Unpacking tcl (8.6.14build1) ... 306s Selecting previously unselected package r-cran-r.rsp. 306s Preparing to unpack .../98-r-cran-r.rsp_0.46.0+ds-1_all.deb ... 306s Unpacking r-cran-r.rsp (0.46.0+ds-1) ... 306s Setting up libgraphite2-3:arm64 (1.3.14-2ubuntu1) ... 306s Setting up libpixman-1-0:arm64 (0.44.0-3) ... 306s Setting up libsharpyuv0:arm64 (1.5.0-0.1) ... 306s Setting up fonts-mathjax (2.7.9+dfsg-1) ... 306s Setting up liblerc4:arm64 (4.0.0+ds-5ubuntu1) ... 306s Setting up libjs-mathjax (2.7.9+dfsg-1) ... 306s Setting up libxrender1:arm64 (1:0.9.10-1.1build1) ... 306s Setting up libdatrie1:arm64 (0.2.13-3build1) ... 306s Setting up libxcb-render0:arm64 (1.17.0-2) ... 306s Setting up fonts-glyphicons-halflings (1.009~3.4.1+dfsg-3) ... 306s Setting up unzip (6.0-28ubuntu6) ... 306s Setting up x11-common (1:7.7+23ubuntu3) ... 306s Setting up libdeflate0:arm64 (1.23-1) ... 306s Setting up libxcb-shm0:arm64 (1.17.0-2) ... 306s Setting up libgomp1:arm64 (15-20250222-0ubuntu1) ... 306s Setting up libjbig0:arm64 (2.1-6.1ubuntu2) ... 306s Setting up zip (3.0-14ubuntu2) ... 306s Setting up libblas3:arm64 (3.12.1-2) ... 306s update-alternatives: using /usr/lib/aarch64-linux-gnu/blas/libblas.so.3 to provide /usr/lib/aarch64-linux-gnu/libblas.so.3 (libblas.so.3-aarch64-linux-gnu) in auto mode 306s Setting up fonts-dejavu-mono (2.37-8) ... 306s Setting up libtcl8.6:arm64 (8.6.16+dfsg-1) ... 306s Setting up fonts-dejavu-core (2.37-8) ... 306s Setting up libjpeg-turbo8:arm64 (2.1.5-3ubuntu2) ... 306s Setting up libgfortran5:arm64 (15-20250222-0ubuntu1) ... 306s Setting up libwebp7:arm64 (1.5.0-0.1) ... 306s Setting up libjs-highlight.js (9.18.5+dfsg1-2) ... 306s Setting up libharfbuzz0b:arm64 (10.2.0-1) ... 306s Setting up libthai-data (0.1.29-2build1) ... 306s Setting up libxss1:arm64 (1:1.2.3-1build3) ... 306s Setting up libpaper2:arm64 (2.2.5-0.3) ... 306s Setting up libjs-jquery (3.6.1+dfsg+~3.5.14-1) ... 306s Setting up node-normalize.css (8.0.1-5) ... 306s Setting up xdg-utils (1.2.1-2ubuntu1) ... 306s update-alternatives: using /usr/bin/xdg-open to provide /usr/bin/open (open) in auto mode 306s Setting up libjs-bootstrap (3.4.1+dfsg-3) ... 306s Setting up libjpeg8:arm64 (8c-2ubuntu11) ... 306s Setting up libice6:arm64 (2:1.1.1-1) ... 306s Setting up tcl8.6 (8.6.16+dfsg-1) ... 306s Setting up liblapack3:arm64 (3.12.1-2) ... 306s update-alternatives: using /usr/lib/aarch64-linux-gnu/lapack/liblapack.so.3 to provide /usr/lib/aarch64-linux-gnu/liblapack.so.3 (liblapack.so.3-aarch64-linux-gnu) in auto mode 306s Setting up fontconfig-config (2.15.0-2ubuntu1) ... 307s Setting up libpaper-utils (2.2.5-0.3) ... 307s Setting up libjs-jquery-datatables (1.11.5+dfsg-2) ... 307s Setting up libthai0:arm64 (0.1.29-2build1) ... 307s Setting up libtiff6:arm64 (4.5.1+git230720-4ubuntu4) ... 307s Setting up tcl (8.6.14build1) ... 307s Setting up libfontconfig1:arm64 (2.15.0-2ubuntu1) ... 307s Setting up libsm6:arm64 (2:1.2.4-1) ... 307s Setting up fontconfig (2.15.0-2ubuntu1) ... 309s Regenerating fonts cache... done. 309s Setting up libxft2:arm64 (2.3.6-1build1) ... 309s Setting up libtk8.6:arm64 (8.6.16-1) ... 309s Setting up libpango-1.0-0:arm64 (1.56.2-1) ... 309s Setting up libcairo2:arm64 (1.18.2-2) ... 309s Setting up libxt6t64:arm64 (1:1.2.1-1.2build1) ... 309s Setting up libpangoft2-1.0-0:arm64 (1.56.2-1) ... 309s Setting up libpangocairo-1.0-0:arm64 (1.56.2-1) ... 309s Setting up r-base-core (4.4.3-1) ... 309s Creating config file /etc/R/Renviron with new version 309s Setting up r-cran-labeling (0.4.3-1) ... 309s Setting up r-cran-lattice (0.22-6-1) ... 309s Setting up r-cran-nlme (3.1.167-1) ... 309s Setting up r-cran-farver (2.1.2-1) ... 309s Setting up r-cran-viridislite (0.4.2-2) ... 309s Setting up r-cran-commonmark (1.9.2-2) ... 309s Setting up r-cran-r6 (2.6.1-1) ... 309s Setting up r-cran-magrittr (2.0.3-1) ... 309s Setting up r-cran-microbenchmark (1.5.0-1) ... 309s Setting up r-cran-rlang (1.1.5-1) ... 309s Setting up r-cran-matrixstats (1.5.0-1) ... 309s Setting up r-cran-xfun (0.51+dfsg-1) ... 309s Setting up r-cran-withr (3.0.2+dfsg-1) ... 309s Setting up r-cran-base64enc (0.1-3-3) ... 309s Setting up r-cran-digest (0.6.37-1) ... 309s Setting up r-cran-yaml (2.3.10-1) ... 309s Setting up r-cran-evaluate (1.0.3-1) ... 309s Setting up r-cran-highr (0.11+dfsg-1) ... 309s Setting up r-cran-fansi (1.0.5-1) ... 309s Setting up r-cran-mass (7.3-64-1) ... 309s Setting up r-cran-glue (1.8.0-1) ... 309s Setting up r-cran-cli (3.6.4-1) ... 309s Setting up r-cran-lifecycle (1.0.4+dfsg-1) ... 309s Setting up r-cran-r.methodss3 (1.8.2-1) ... 309s Setting up r-cran-pkgconfig (2.0.3-2build1) ... 309s Setting up r-cran-utf8 (1.2.4-1) ... 309s Setting up r-cran-colorspace (2.1-1+dfsg-1) ... 309s Setting up r-cran-markdown (1.13-1) ... 309s Setting up r-cran-rcolorbrewer (1.1-3-1build1) ... 309s Setting up r-cran-isoband (0.2.7-1) ... 309s Setting up r-cran-gtable (0.3.6+dfsg-1) ... 309s Setting up r-cran-matrix (1.7-3-1) ... 309s Setting up r-cran-knitr (1.49+dfsg-1) ... 309s Setting up r-cran-mgcv (1.9-1-1) ... 309s Setting up r-cran-vctrs (0.6.5-1) ... 309s Setting up r-cran-pillar (1.10.1+dfsg-1) ... 309s Setting up r-cran-munsell (0.5.1-1) ... 309s Setting up r-cran-tibble (3.2.1+dfsg-3) ... 309s Setting up r-cran-r.oo (1.27.0-1) ... 309s Setting up r-cran-scales (1.3.0-1) ... 309s Setting up r-cran-r.utils (2.13.0-1) ... 309s Setting up r-cran-ggplot2 (3.5.1+dfsg-1) ... 309s Setting up r-cran-r.devices (2.17.2+ds-1) ... 309s Setting up r-cran-r.cache (0.16.0-1) ... 309s Setting up r-cran-r.rsp (0.46.0+ds-1) ... 309s Processing triggers for libc-bin (2.41-1ubuntu2) ... 309s Processing triggers for man-db (2.13.0-1) ... 311s Processing triggers for install-info (7.1.1-1) ... 313s autopkgtest [15:45:02]: test run-unit-test: [----------------------- 314s 314s R version 4.4.3 (2025-02-28) -- "Trophy Case" 314s Copyright (C) 2025 The R Foundation for Statistical Computing 314s Platform: aarch64-unknown-linux-gnu 314s 314s R is free software and comes with ABSOLUTELY NO WARRANTY. 314s You are welcome to redistribute it under certain conditions. 314s Type 'license()' or 'licence()' for distribution details. 314s 314s R is a collaborative project with many contributors. 314s Type 'contributors()' for more information and 314s 'citation()' on how to cite R or R packages in publications. 314s 314s Type 'demo()' for some demos, 'help()' for on-line help, or 314s 'help.start()' for an HTML browser interface to help. 314s Type 'q()' to quit R. 314s 314s > library("matrixStats") 314s > 314s > allocArray_R <- function(nrow, ncol, value = NA) { 314s + array(data = value, dim = dim) 314s + } 314s > 314s > values <- list( 314s + -1L, 0L, +1L, NA_integer_, .Machine$integer.max, 314s + -1, 0, +1, NA_real_, NaN, -Inf, +Inf, 314s + .Machine$double.xmin, .Machine$double.xmax, 314s + .Machine$double.eps, .Machine$double.neg.eps, 314s + FALSE, TRUE, NA 314s + ) 314s > 314s > dim <- c(2L, 4L, 3L) 314s > for (value in values) { 314s + x0 <- allocArray_R(dim, value = value) 314s + x <- allocArray(dim, value = value) 314s + if (!identical(x, x0)) { 314s + str(list(dim = dim, value = value, x = x, x0 = x0)) 314s + stopifnot(identical(x, x0)) 314s + } 314s + } 314s > 314s 314s R version 4.4.3 (2025-02-28) -- "Trophy Case" 314s Copyright (C) 2025 The R Foundation for Statistical Computing 314s Platform: aarch64-unknown-linux-gnu 314s 314s R is free software and comes with ABSOLUTELY NO WARRANTY. 314s You are welcome to redistribute it under certain conditions. 314s Type 'license()' or 'licence()' for distribution details. 314s 314s R is a collaborative project with many contributors. 314s Type 'contributors()' for more information and 314s 'citation()' on how to cite R or R packages in publications. 314s 314s Type 'demo()' for some demos, 'help()' for on-line help, or 314s 'help.start()' for an HTML browser interface to help. 314s Type 'q()' to quit R. 314s 314s > library("matrixStats") 314s > 314s > allocMatrix_R <- function(nrow, ncol, value = NA) { 314s + matrix(data = value, nrow = nrow, ncol = ncol) 314s + } 314s > 314s > values <- list( 314s + -1L, 0L, +1L, NA_integer_, .Machine$integer.max, 314s + -1, 0, +1, NA_real_, NaN, -Inf, +Inf, 314s + .Machine$double.xmin, .Machine$double.xmax, 314s + .Machine$double.eps, .Machine$double.neg.eps, 314s + FALSE, TRUE, NA 314s + ) 314s > 314s > nrow <- 2L 314s > ncol <- 3L 314s > for (value in values) { 314s + x0 <- allocMatrix_R(nrow, ncol, value = value) 314s + x <- allocMatrix(nrow, ncol, value = value) 314s + if (!identical(x, x0)) { 314s + str(list(nrow = nrow, ncol = ncol, value = value, x = x, x0 = x0)) 314s + stopifnot(identical(x, x0)) 314s + } 314s + } 314s > 314s 314s R version 4.4.3 (2025-02-28) -- "Trophy Case" 314s Copyright (C) 2025 The R Foundation for Statistical Computing 314s Platform: aarch64-unknown-linux-gnu 314s 314s R is free software and comes with ABSOLUTELY NO WARRANTY. 314s You are welcome to redistribute it under certain conditions. 314s Type 'license()' or 'licence()' for distribution details. 314s 314s R is a collaborative project with many contributors. 314s Type 'contributors()' for more information and 314s 'citation()' on how to cite R or R packages in publications. 314s 314s Type 'demo()' for some demos, 'help()' for on-line help, or 314s 'help.start()' for an HTML browser interface to help. 314s Type 'q()' to quit R. 314s 314s > library("matrixStats") 314s > 314s > allocVector_R <- function(length, value = NA) { 314s + x <- vector(mode = typeof(value), length = length) 314s + if (!is.finite(value) || value != 0) x[] <- value 314s + x 314s + } 314s > 314s > values <- list( 314s + -1L, 0L, +1L, NA_integer_, .Machine$integer.max, 314s + -1, 0, +1, NA_real_, NaN, -Inf, +Inf, 314s + .Machine$double.xmin, .Machine$double.xmax, 314s + .Machine$double.eps, .Machine$double.neg.eps, 314s + FALSE, TRUE, NA 314s + ) 314s > 314s > n <- 10L 314s > for (value in values) { 314s + x0 <- allocVector_R(n, value = value) 314s + x <- allocVector(n, value = value) 314s + if (!identical(x, x0)) { 314s + str(list(n = n, value = value, x = x, x0 = x0)) 314s + stopifnot(identical(x, x0)) 314s + } 314s + } 314s > 315s 315s R version 4.4.3 (2025-02-28) -- "Trophy Case" 315s Copyright (C) 2025 The R Foundation for Statistical Computing 315s Platform: aarch64-unknown-linux-gnu 315s 315s R is free software and comes with ABSOLUTELY NO WARRANTY. 315s You are welcome to redistribute it under certain conditions. 315s Type 'license()' or 'licence()' for distribution details. 315s 315s R is a collaborative project with many contributors. 315s Type 'contributors()' for more information and 315s 'citation()' on how to cite R or R packages in publications. 315s 315s Type 'demo()' for some demos, 'help()' for on-line help, or 315s 'help.start()' for an HTML browser interface to help. 315s Type 'q()' to quit R. 315s 315s > library("matrixStats") 315s > 315s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 315s > # Setup 315s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 315s > data <- data.frame( 315s + logical = c(TRUE, FALSE, TRUE), 315s + integer = 1:3, 315s + double = seq(from = 1.0, to = 3.0, by = 1.0), 315s + complex = seq(from = 1.0, to = 3.0, by = 1.0) + 1.0i, 315s + character = letters[1:3], 315s + stringsAsFactors = FALSE 315s + ) 315s > 315s > modes <- names(data) 315s > 315s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 315s > # Special cases 315s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 315s > cat("NULL...\n") 315s NULL... 315s > stopifnot(identical(anyMissing(NULL), FALSE)) 315s > cat("NULL...done\n") 315s NULL...done 315s > 315s > cat("raw...\n") 315s raw... 315s > stopifnot(identical(anyMissing(as.raw(0:2)), FALSE)) 315s > cat("raw...done\n") 315s raw...done 315s > 315s > cat("list(NULL)...\n") 315s list(NULL)... 315s > stopifnot(identical(anyMissing(list(NULL)), FALSE)) 315s > cat("list(NULL)...done\n") 315s list(NULL)...done 315s > 315s > 315s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 315s > # Scalars, vectors, and matrices of various modes 315s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 315s > for (mode in modes) { 315s + cat(sprintf("Mode: %s...\n", mode)) 315s + values <- data[[mode]] 315s + 315s + # Scalars 315s + cat(" scalar\n") 315s + x <- values[1L] 315s + print(x) 315s + stopifnot(identical(anyMissing(x), FALSE)) 315s + is.na(x) <- TRUE 315s + print(x) 315s + stopifnot(identical(anyMissing(x), TRUE)) 315s + 315s + # Vectors 315s + cat(" vector\n") 315s + x <- values 315s + print(x) 315s + stopifnot(identical(anyMissing(x), FALSE)) 315s + is.na(x)[2L] <- TRUE 315s + print(x) 315s + stopifnot(identical(anyMissing(x), TRUE)) 315s + 315s + # Matrices 315s + cat(" matrix\n") 315s + x <- matrix(c(values, values), ncol = 2L) 315s + print(x) 315s + stopifnot(identical(anyMissing(x), FALSE)) 315s + is.na(x)[2L] <- TRUE 315s + print(x) 315s + stopifnot(identical(anyMissing(x), TRUE)) 315s + 315s + cat(sprintf("Mode: %s...done\n", mode)) 315s + } # for (mode ...) 315s Mode: logical... 315s scalar 315s [1] TRUE 315s [1] NA 315s vector 315s [1] TRUE FALSE TRUE 315s [1] TRUE NA TRUE 315s matrix 315s [,1] [,2] 315s [1,] TRUE TRUE 315s [2,] FALSE FALSE 315s [3,] TRUE TRUE 315s [,1] [,2] 315s [1,] TRUE TRUE 315s [2,] NA FALSE 315s [3,] TRUE TRUE 315s Mode: logical...done 315s Mode: integer... 315s scalar 315s [1] 1 315s [1] NA 315s vector 315s [1] 1 2 3 315s [1] 1 NA 3 315s matrix 315s [,1] [,2] 315s [1,] 1 1 315s [2,] 2 2 315s [3,] 3 3 315s [,1] [,2] 315s [1,] 1 1 315s [2,] NA 2 315s [3,] 3 3 315s Mode: integer...done 315s Mode: double... 315s scalar 315s [1] 1 315s [1] NA 315s vector 315s [1] 1 2 3 315s [1] 1 NA 3 315s matrix 315s [,1] [,2] 315s [1,] 1 1 315s [2,] 2 2 315s [3,] 3 3 315s [,1] [,2] 315s [1,] 1 1 315s [2,] NA 2 315s [3,] 3 3 315s Mode: double...done 315s Mode: complex... 315s scalar 315s [1] 1+1i 315s [1] NA 315s vector 315s [1] 1+1i 2+1i 3+1i 315s [1] 1+1i NA 3+1i 315s matrix 315s [,1] [,2] 315s [1,] 1+1i 1+1i 315s [2,] 2+1i 2+1i 315s [3,] 3+1i 3+1i 315s [,1] [,2] 315s [1,] 1+1i 1+1i 315s [2,] NA 2+1i 315s [3,] 3+1i 3+1i 315s Mode: complex...done 315s Mode: character... 315s scalar 315s [1] "a" 315s [1] NA 315s vector 315s [1] "a" "b" "c" 315s [1] "a" NA "c" 315s matrix 315s [,1] [,2] 315s [1,] "a" "a" 315s [2,] "b" "b" 315s [3,] "c" "c" 315s [,1] [,2] 315s [1,] "a" "a" 315s [2,] NA "b" 315s [3,] "c" "c" 315s Mode: character...done 315s > 315s > 315s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 315s > # Data frames 315s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 315s > cat("data.frame...\n") 315s data.frame... 315s > x <- data 315s > stopifnot(identical(anyMissing(x), FALSE)) 315s > for (mode in modes) { 315s + x <- data 315s + is.na(x[[mode]])[2L] <- TRUE 315s + print(x) 315s + stopifnot(identical(anyMissing(x), TRUE)) 315s + } # for (mode ...) 315s logical integer double complex character 315s 1 TRUE 1 1 1+1i a 315s 2 NA 2 2 2+1i b 315s 3 TRUE 3 3 3+1i c 315s logical integer double complex character 315s 1 TRUE 1 1 1+1i a 315s 2 FALSE NA 2 2+1i b 315s 3 TRUE 3 3 3+1i c 315s logical integer double complex character 315s 1 TRUE 1 1 1+1i a 315s 2 FALSE 2 NA 2+1i b 315s 3 TRUE 3 3 3+1i c 315s logical integer double complex character 315s 1 TRUE 1 1 1+1i a 315s 2 FALSE 2 2 NA b 315s 3 TRUE 3 3 3+1i c 315s logical integer double complex character 315s 1 TRUE 1 1 1+1i a 315s 2 FALSE 2 2 2+1i 315s 3 TRUE 3 3 3+1i c 315s > cat("data.frame...done\n") 315s data.frame...done 315s > 315s > 315s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 315s > # Lists 315s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 315s > cat("list...\n") 315s list... 315s > x <- as.list(data) 315s > stopifnot(identical(anyMissing(x), FALSE)) 315s > for (mode in modes) { 315s + x <- as.list(data) 315s + is.na(x[[mode]])[2L] <- TRUE 315s + print(x) 315s + stopifnot(identical(anyMissing(x), TRUE)) 315s + } # for (mode ...) 315s $logical 315s [1] TRUE NA TRUE 315s 315s $integer 315s [1] 1 2 3 315s 315s $double 315s [1] 1 2 3 315s 315s $complex 315s [1] 1+1i 2+1i 3+1i 315s 315s $character 315s [1] "a" "b" "c" 315s 315s $logical 315s [1] TRUE FALSE TRUE 315s 315s $integer 315s [1] 1 NA 3 315s 315s $double 315s [1] 1 2 3 315s 315s $complex 315s [1] 1+1i 2+1i 3+1i 315s 315s $character 315s [1] "a" "b" "c" 315s 315s $logical 315s [1] TRUE FALSE TRUE 315s 315s $integer 315s [1] 1 2 3 315s 315s $double 315s [1] 1 NA 3 315s 315s $complex 315s [1] 1+1i 2+1i 3+1i 315s 315s $character 315s [1] "a" "b" "c" 315s 315s $logical 315s [1] TRUE FALSE TRUE 315s 315s $integer 315s [1] 1 2 3 315s 315s $double 315s [1] 1 2 3 315s 315s $complex 315s [1] 1+1i NA 3+1i 315s 315s $character 315s [1] "a" "b" "c" 315s 315s $logical 315s [1] TRUE FALSE TRUE 315s 315s $integer 315s [1] 1 2 3 315s 315s $double 315s [1] 1 2 3 315s 315s $complex 315s [1] 1+1i 2+1i 3+1i 315s 315s $character 315s [1] "a" NA "c" 315s 315s > cat("list...done\n") 315s list...done 315s > 315s 315s R version 4.4.3 (2025-02-28) -- "Trophy Case" 315s Copyright (C) 2025 The R Foundation for Statistical Computing 315s Platform: aarch64-unknown-linux-gnu 315s 315s R is free software and comes with ABSOLUTELY NO WARRANTY. 315s You are welcome to redistribute it under certain conditions. 315s Type 'license()' or 'licence()' for distribution details. 315s 315s R is a collaborative project with many contributors. 315s Type 'contributors()' for more information and 315s 'citation()' on how to cite R or R packages in publications. 315s 315s Type 'demo()' for some demos, 'help()' for on-line help, or 315s 'help.start()' for an HTML browser interface to help. 315s Type 'q()' to quit R. 315s 315s > library("matrixStats") 315s > 315s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 315s > # Subsetted tests 315s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 315s > source("utils/validateIndicesFramework.R") 315s > x <- runif(4, min = -3, max = 3) 315s > x[2] <- NA 315s > for (mode in c("integer", "numeric")) { 315s + storage.mode(x) <- mode 315s + for (idxs in index_cases) { 315s + validateIndicesTestVector(x, idxs, 315s + ftest = anyMissing, fsure = function(x, ...) { 315s + anyValue(x, value = NA) 315s + }) 315s + } 315s + } 315s > 315s 315s R version 4.4.3 (2025-02-28) -- "Trophy Case" 315s Copyright (C) 2025 The R Foundation for Statistical Computing 315s Platform: aarch64-unknown-linux-gnu 315s 315s R is free software and comes with ABSOLUTELY NO WARRANTY. 315s You are welcome to redistribute it under certain conditions. 315s Type 'license()' or 'licence()' for distribution details. 315s 315s R is a collaborative project with many contributors. 315s Type 'contributors()' for more information and 315s 'citation()' on how to cite R or R packages in publications. 315s 315s Type 'demo()' for some demos, 'help()' for on-line help, or 315s 'help.start()' for an HTML browser interface to help. 315s Type 'q()' to quit R. 315s 315s > ## Don't test with valgrind 315s > if (Sys.getenv("_R_CHECK_USE_VALGRIND_") == "") { 315s + 315s + ## 3. Make sure all suggested packages are installed / can be loaded 315s + pkgs <- c("base64enc", "ggplot2", "knitr", "markdown", "microbenchmark", 315s + "R.devices", "R.rsp") 315s + if (all(unlist(lapply(pkgs, FUN = requireNamespace)))) { 315s + html <- matrixStats:::benchmark("binCounts") 315s + print(html) 315s + } 315s + 315s + rm(list = "pkgs") 315s + 315s + } 315s Loading required namespace: base64enc 315s Loading required namespace: ggplot2 316s Loading required namespace: knitr 319s Loading required namespace: markdown 319s Loading required namespace: microbenchmark 319s Loading required namespace: R.devices 319s Loading required namespace: R.rsp 319s integer: unsorted 320s integer: sorted 321s double: unsorted 324s double: sorted 326s RspFileProduct: 326s Pathname: /tmp/autopkgtest.3lxAxM/autopkgtest_tmp/reports/binCounts.html 326s File size: 74.00 kB (75771 bytes) 326s Content type: text/html 326s Metadata 'author': 'Henrik Bengtsson' 326s Metadata 'title': 'binCounts() benchmarks' 326s Metadata 'date': '2014-05-25' 326s Has processor: FALSEWarning message: 326s In par(parT) : argument 1 does not name a graphical parameter 326s 326s > 326s 326s R version 4.4.3 (2025-02-28) -- "Trophy Case" 326s Copyright (C) 2025 The R Foundation for Statistical Computing 326s Platform: aarch64-unknown-linux-gnu 326s 326s R is free software and comes with ABSOLUTELY NO WARRANTY. 326s You are welcome to redistribute it under certain conditions. 326s Type 'license()' or 'licence()' for distribution details. 326s 326s R is a collaborative project with many contributors. 326s Type 'contributors()' for more information and 326s 'citation()' on how to cite R or R packages in publications. 326s 326s Type 'demo()' for some demos, 'help()' for on-line help, or 326s 'help.start()' for an HTML browser interface to help. 326s Type 'q()' to quit R. 326s 326s > library("matrixStats") 326s > library("stats") 326s > 326s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 326s > # Local functions 326s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 326s > binCounts_hist <- function(x, bx, right = FALSE, ...) { 326s + n0 <- graphics::hist(x, breaks = bx, right = right, 326s + include.lowest = TRUE, plot = FALSE)$counts 326s + } 326s > 326s > 326s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 326s > # Non-sorted and sorted positions 326s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 326s > nx <- 1000L # Number of data points 326s > nb <- 200L # Number of bins 326s > 326s > # Uniformely distributed bins 326s > bx <- seq(from = 0, to = 1, length.out = nb + 1L) 326s > bx <- c(-1, bx, 2) 326s > 326s > # Sample data points 326s > set.seed(0xBEEF) 326s > x <- runif(nx, min = 0, max = 1) 326s > 326s > for (kk in 1:2) { 326s + n0 <- binCounts_hist(x, bx = bx) 326s + n1 <- binCounts(x, bx = bx) 326s + # Sanity check 326s + stopifnot(identical(n1, n0)) 326s + 326s + # Check reversed 326s + n1r <- rev(binCounts(-x, bx = rev(-bx), right = TRUE)) 326s + stopifnot(identical(n1r, n1)) 326s + 326s + # Retry with a sorted vector 326s + x <- sort(x) 326s + } # for (kk in 1:2) 326s > 326s > 326s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 326s > # Missing values 326s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 326s > x <- 1:40 326s > x[20] <- NA_integer_ 326s > nx <- length(x) 326s > 326s > # Bins 326s > bx <- c(0.5, 50.5, 100.5, 150.5, 200.5) 326s > 326s > y_smooth0 <- binCounts_hist(x, bx = bx) 326s > y_smooth <- binCounts(x, bx = bx) 326s > # Sanity check 326s > stopifnot(all.equal(y_smooth, y_smooth0)) 326s > 326s > 326s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 326s > # Border cases 326s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 326s > x <- 1:10 326s > bx <- min(x) - c(10, 1) 326s > y_smooth <- binCounts(x, bx = bx) 326s > stopifnot(all.equal(y_smooth, 0L)) 326s > bx <- range(x) 326s > y_smooth <- binCounts(x, bx = bx) 326s > stopifnot(all.equal(y_smooth, length(x) - 1L)) 326s > bx <- max(x) + c(1, 10) 326s > y_smooth <- binCounts(x, bx = bx) 326s > stopifnot(all.equal(y_smooth, 0L)) 326s > 326s > # Every second empty 326s > x <- 1:10 326s > bx <- rep(x, each = 2L) 326s > y_smooth <- binCounts(x, bx = bx) 326s > stopifnot(all.equal(y_smooth, rep(c(0L, 1L), length.out = length(bx) - 1L))) 326s > ## NOTE: binCounts_hist() does not give the same last bin count 326s > 326s > 326s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 326s > # Exception handling 326s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 326s > # Zero bin boundaries (invalid bin definition) 326s > bx <- double(0L) 326s > res <- try(y_smooth <- binCounts(1:10, bx = bx), silent = TRUE) 326s > stopifnot(inherits(res, "try-error")) 326s > 326s > # One bin boundary (invalid bin definition) 326s > bx <- double(1L) 326s > res <- try(y_smooth <- binCounts(1:10, bx = bx), silent = TRUE) 326s > stopifnot(inherits(res, "try-error")) 326s > 326s 326s R version 4.4.3 (2025-02-28) -- "Trophy Case" 326s Copyright (C) 2025 The R Foundation for Statistical Computing 326s Platform: aarch64-unknown-linux-gnu 326s 326s R is free software and comes with ABSOLUTELY NO WARRANTY. 326s You are welcome to redistribute it under certain conditions. 326s Type 'license()' or 'licence()' for distribution details. 326s 326s R is a collaborative project with many contributors. 326s Type 'contributors()' for more information and 326s 'citation()' on how to cite R or R packages in publications. 326s 326s Type 'demo()' for some demos, 'help()' for on-line help, or 326s 'help.start()' for an HTML browser interface to help. 326s Type 'q()' to quit R. 326s 326s > library("matrixStats") 326s > 326s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 326s > # Local functions 326s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 326s > binCounts_hist <- function(x, bx, right = FALSE, ...) { 326s + n0 <- graphics::hist(x, breaks = bx, right = right, 326s + include.lowest = TRUE, plot = FALSE)$counts 326s + } 326s > 326s > 326s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 326s > # Subsetted tests 326s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 326s > source("utils/validateIndicesFramework.R") 326s > x <- runif(6, min = -6, max = 6) 326s > storage.mode(x) <- "integer" 326s > bx <- c(-6, 0, 3, 4, 10) 326s > for (idxs in index_cases) { 326s + validateIndicesTestVector(x, idxs, 326s + ftest = binCounts, fsure = binCounts_hist, 326s + bx = bx, right = FALSE) 326s + validateIndicesTestVector(x, idxs, 326s + ftest = binCounts, fsure = binCounts_hist, 326s + bx = bx, right = TRUE) 326s + } 326s > 327s 327s R version 4.4.3 (2025-02-28) -- "Trophy Case" 327s Copyright (C) 2025 The R Foundation for Statistical Computing 327s Platform: aarch64-unknown-linux-gnu 327s 327s R is free software and comes with ABSOLUTELY NO WARRANTY. 327s You are welcome to redistribute it under certain conditions. 327s Type 'license()' or 'licence()' for distribution details. 327s 327s R is a collaborative project with many contributors. 327s Type 'contributors()' for more information and 327s 'citation()' on how to cite R or R packages in publications. 327s 327s Type 'demo()' for some demos, 'help()' for on-line help, or 327s 'help.start()' for an HTML browser interface to help. 327s Type 'q()' to quit R. 327s 327s > library("matrixStats") 327s > library("stats") 327s > 327s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 327s > # Naive R implementation of binMeans() 327s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 327s > binMeans0 <- function(y, x, bx, na.rm = TRUE, count = TRUE, right = FALSE) { 327s + n_smooth <- length(bx) - 1L 327s + res <- double(n_smooth) 327s + counts <- rep(NaN, times = n_smooth) 327s + 327s + if (na.rm) { 327s + keep <- !is.na(x) & !is.na(y) 327s + x <- x[keep] 327s + y <- y[keep] 327s + } 327s + 327s + # For each bin... 327s + for (kk in seq_len(n_smooth)) { 327s + if (right) { 327s + idxs <- which(bx[kk] < x & x <= bx[kk + 1L]) 327s + } else { 327s + idxs <- which(bx[kk] <= x & x < bx[kk + 1L]) 327s + } 327s + y_kk <- y[idxs] 327s + res[kk] <- mean(y_kk) 327s + counts[kk] <- length(idxs) 327s + } # for (kk ...) 327s + 327s + if (count) attr(res, "count") <- counts 327s + res 327s + } 327s > 327s > 327s > 327s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 327s > # Case #1 327s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 327s > x <- 1:100 327s > nx <- length(x) 327s > y <- double(nx) 327s > y[1:25] <- 5 327s > y[51:75] <- -5 327s > y <- y + rnorm(nx) 327s > 327s > # Bins 327s > bx <- c(0.5, 25.5, 50.5, 75.5, 100.5) 327s > 327s > y_smooth0 <- binMeans0(y, x = x, bx = bx) 327s > y_smooth <- binMeans(y, x = x, bx = bx) 327s > n_smooth <- binCounts(x, bx = bx) 327s > # Sanity check 327s > stopifnot(all.equal(y_smooth, y_smooth0)) 327s > stopifnot(all.equal(attr(y_smooth, "count"), n_smooth)) 327s > 327s > y_smooth0r <- rev(binMeans0(y, x = -x, bx = rev(-bx), 327s + count = FALSE, right = TRUE)) 327s > y_smoothr <- rev(binMeans(y, x = -x, bx = rev(-bx), 327s + count = FALSE, right = TRUE)) 327s > # Sanity check 327s > stopifnot(all.equal(y_smooth0r, y_smooth0, check.attributes = FALSE)) 327s > stopifnot(all.equal(y_smoothr, y_smooth0r)) 327s > 327s > 327s > # Integer input 327s > y <- as.integer(y) 327s > y_smooth0 <- binMeans0(y, x = x, bx = bx) 327s > y_smooth <- binMeans(y, x = x, bx = bx) 327s > n_smooth <- binCounts(x, bx = bx) 327s > # Sanity check 327s > stopifnot(is.integer(y), 327s + all.equal(y_smooth, y_smooth0), 327s + all.equal(attr(y_smooth, "count"), n_smooth)) 327s > 327s > # Logical input 327s > y <- as.logical(y) 327s > y_smooth0 <- binMeans0(y, x = x, bx = bx) 327s > y_smooth <- binMeans(y, x = x, bx = bx) 327s > n_smooth <- binCounts(x, bx = bx) 327s > # Sanity check 327s > stopifnot(is.logical(y), 327s + all.equal(y_smooth, y_smooth0), 327s + all.equal(attr(y_smooth, "count"), n_smooth)) 327s > 327s > 327s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 327s > # Case #2 327s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 327s > nx <- 1e3 327s > x <- runif(nx) 327s > y <- runif(nx) 327s > 327s > nb <- 10 327s > bx <- do.call(seq, c(as.list(range(x)), length.out = nb)) 327s > bx1 <- c(bx[-1], bx[nb] + 1) 327s > 327s > y_smooth0 <- binMeans0(y, x = x, bx = bx1) 327s > y_smooth <- binMeans(y, x = x, bx = bx1) 327s > n_smooth <- binCounts(x, bx = bx1) 327s > y_smoothr <- rev(binMeans(y, x = -x, bx = rev(-bx1), right = TRUE)) 327s > 327s > # Sanity check 327s > stopifnot(all.equal(y_smooth, y_smooth0)) 327s > stopifnot(all.equal(attr(y_smooth, "count"), n_smooth)) 327s > stopifnot(all.equal(y_smoothr, y_smooth, check.attributes = FALSE)) 327s > 327s > 327s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 327s > # Empty bins 327s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 327s > x <- c(6:8, 16:19) 327s > nx <- length(x) 327s > y <- runif(nx) 327s > bx <- c(0, 5, 10, 15, 20, 25) 327s > y_smooth0 <- binMeans0(y, x = x, bx = bx) 327s > y_smooth <- binMeans(y, x = x, bx = bx) 327s > n_smooth <- binCounts(x, bx = bx) 327s > stopifnot(all.equal(attr(y_smooth, "count"), n_smooth)) 327s > stopifnot(all.equal(y_smooth, y_smooth0)) 327s > 327s > 327s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 327s > # Missing values 327s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 327s > x <- 1:100 327s > x[50] <- NA_integer_ 327s > nx <- length(x) 327s > y <- double(nx) 327s > y[1:25] <- 5 327s > y[51:75] <- -5 327s > y[82:92] <- NA_real_ 327s > y <- y + rnorm(nx) 327s > 327s > # Bins 327s > bx <- c(0.5, 25.5, 75.5, 82.5, 100.5) 327s > 327s > y_smooth0 <- binMeans0(y, x = x, bx = bx) 327s > y_smooth <- binMeans(y, x = x, bx = bx) 327s > # Sanity check 327s > stopifnot(all.equal(y_smooth, y_smooth0)) 327s > 327s > 327s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 327s > # Exception handling 327s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 327s > # Zero bin boundaries (invalid bin definition) 327s > bx <- double(0L) 327s > res <- try(y_smooth <- binMeans(x = 1:5, y = 1:5, bx = bx), silent = TRUE) 327s > stopifnot(inherits(res, "try-error")) 327s > 327s > # One bin boundary (invalid bin definition) 327s > bx <- double(1L) 327s > res <- try(y_smooth <- binMeans(x = 1:5, y = 1:5, bx = bx), silent = TRUE) 327s > stopifnot(inherits(res, "try-error")) 327s > 327s 327s R version 4.4.3 (2025-02-28) -- "Trophy Case" 327s Copyright (C) 2025 The R Foundation for Statistical Computing 327s Platform: aarch64-unknown-linux-gnu 327s 327s R is free software and comes with ABSOLUTELY NO WARRANTY. 327s You are welcome to redistribute it under certain conditions. 327s Type 'license()' or 'licence()' for distribution details. 327s 327s R is a collaborative project with many contributors. 327s Type 'contributors()' for more information and 327s 'citation()' on how to cite R or R packages in publications. 327s 327s Type 'demo()' for some demos, 'help()' for on-line help, or 327s 'help.start()' for an HTML browser interface to help. 327s Type 'q()' to quit R. 327s 327s > library("matrixStats") 327s > 327s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 327s > # Naive R implementation of binMeans() 327s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 327s > binMeans0 <- function(y, x, bx, na.rm = TRUE, count = TRUE, right = FALSE) { 327s + n_smooth <- length(bx) - 1L 327s + res <- double(n_smooth) 327s + counts <- rep(NaN, times = n_smooth) 327s + 327s + if (na.rm) { 327s + keep <- !is.na(x) & !is.na(y) 327s + x <- x[keep] 327s + y <- y[keep] 327s + } 327s + 327s + # For each bin... 327s + for (kk in seq_len(n_smooth)) { 327s + if (right) { 327s + idxs <- which(bx[kk] < x & x <= bx[kk + 1L]) 327s + } else { 327s + idxs <- which(bx[kk] <= x & x < bx[kk + 1L]) 327s + } 327s + y_kk <- y[idxs] 327s + res[kk] <- mean(y_kk) 327s + counts[kk] <- length(idxs) 327s + } # for (kk ...) 327s + 327s + if (count) attr(res, "count") <- counts 327s + res 327s + } 327s > 327s > 327s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 327s > # Subsetted tests 327s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 327s > source("utils/validateIndicesFramework.R") 327s > y <- runif(6, min = -6, max = 6) 327s > x <- runif(6, min = -6, max = 6) 327s > storage.mode(x) <- "integer" 327s > bx <- c(-6, 0, 3, 4, 10) 327s > for (idxs in index_cases) { 327s + for (na.rm in c(TRUE, FALSE)) { 327s + validateIndicesTestVector_w(y, x, idxs, 327s + ftest = binMeans, fsure = binMeans0, 327s + bx = bx, na.rm = na.rm, 327s + count = TRUE, right = FALSE) 327s + validateIndicesTestVector_w(y, x, idxs, 327s + ftest = binMeans, fsure = binMeans0, 327s + bx = bx, na.rm = na.rm, 327s + count = TRUE, right = TRUE) 327s + } 327s + } 327s > 327s 327s R version 4.4.3 (2025-02-28) -- "Trophy Case" 327s Copyright (C) 2025 The R Foundation for Statistical Computing 327s Platform: aarch64-unknown-linux-gnu 327s 327s R is free software and comes with ABSOLUTELY NO WARRANTY. 327s You are welcome to redistribute it under certain conditions. 327s Type 'license()' or 'licence()' for distribution details. 327s 327s R is a collaborative project with many contributors. 327s Type 'contributors()' for more information and 327s 'citation()' on how to cite R or R packages in publications. 327s 327s Type 'demo()' for some demos, 'help()' for on-line help, or 327s 'help.start()' for an HTML browser interface to help. 327s Type 'q()' to quit R. 327s 327s > library("matrixStats") 327s > 327s > count_R <- function(x, value = TRUE, na.rm = FALSE, ...) { 327s + if (is.na(value)) { 327s + counts <- sum(is.na(x)) 327s + } else { 327s + counts <- sum(x == value, na.rm = na.rm) 327s + } 327s + as.integer(counts) 327s + } 327s > 327s > 327s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 327s > # Data type: integer and numeric 327s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 327s > for (mode in c("integer", "double")) { 327s + x <- runif(20 * 5, min = -3, max = 3) 327s + x[sample.int(length(x), size = 7)] <- 0 327s + storage.mode(x) <- mode 327s + 327s + for (na.rm in c(FALSE, TRUE)) { 327s + # Count zeros 327s + n0 <- count_R(x, value = 0, na.rm = na.rm) 327s + n1 <- count(x, value = 0, na.rm = na.rm) 327s + stopifnot(identical(n1, n0)) 327s + all <- allValue(x, value = 0, na.rm = na.rm) 327s + any <- anyValue(x, value = 0, na.rm = na.rm) 327s + 327s + # Count NAs 327s + n0 <- count_R(x, value = NA, na.rm = na.rm) 327s + n1 <- count(x, value = NA, na.rm = na.rm) 327s + stopifnot(identical(n1, n0)) 327s + all <- allValue(x, value = NA, na.rm = na.rm) 327s + any <- anyValue(x, value = NA, na.rm = na.rm) 327s + 327s + if (mode == "integer") { 327s + ux <- unique(as.vector(x)) 327s + n0 <- n1 <- integer(length(x)) 327s + for (value in ux) { 327s + n0 <- n0 + count_R(x, value = value, na.rm = na.rm) 327s + n1 <- n1 + count(x, value = value, na.rm = na.rm) 327s + stopifnot(identical(n1, n0)) 327s + } 327s + stopifnot(all(n0 == ncol(x))) 327s + } # if (mode == "integer") 327s + 327s + } # for (na.rm ...) 327s + } # for (mode ...) 327s > 327s > # All NAs 327s > na_list <- list(NA_integer_, NA_real_, NaN) 327s > for (na_value in na_list) { 327s + x <- rep(na_value, times = 10L) 327s + for (na.rm in c(FALSE, TRUE)) { 327s + n0 <- count_R(x, na.rm = na.rm) 327s + n1 <- count(x, na.rm = na.rm) 327s + stopifnot(identical(n1, n0)) 327s + 327s + # Count NAs 327s + n0 <- count_R(x, value = NA, na.rm = na.rm) 327s + n1 <- count(x, value = NA, na.rm = na.rm) 327s + stopifnot(identical(n1, n0)) 327s + any <- anyValue(x, value = NA, na.rm = na.rm) 327s + all <- allValue(x, value = NA, na.rm = na.rm) 327s + stopifnot(any) 327s + stopifnot(all) 327s + } 327s + } # for (na_value ...) 327s > 327s > 327s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 327s > # Data type: logical 327s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 327s > x <- logical(length = 10L) 327s > x[3:7] <- TRUE 327s > 327s > # Row/column counts 327s > for (na.rm in c(FALSE, TRUE)) { 327s + n0 <- count_R(x, na.rm = na.rm) 327s + n1 <- count(x, na.rm = na.rm) 327s + stopifnot(identical(n1, n0)) 327s + 327s + n_true <- count(x, value = TRUE, na.rm = na.rm) 327s + n_false <- count(x, value = FALSE, na.rm = na.rm) 327s + stopifnot(n_true + n_false == ncol(x)) 327s + 327s + # Count NAs 327s + n0 <- count_R(x, value = NA, na.rm = na.rm) 327s + n1 <- count(x, value = NA, na.rm = na.rm) 327s + stopifnot(identical(n1, n0)) 327s + } 327s > 327s 327s R version 4.4.3 (2025-02-28) -- "Trophy Case" 327s Copyright (C) 2025 The R Foundation for Statistical Computing 327s Platform: aarch64-unknown-linux-gnu 327s 327s R is free software and comes with ABSOLUTELY NO WARRANTY. 327s You are welcome to redistribute it under certain conditions. 327s Type 'license()' or 'licence()' for distribution details. 327s 327s R is a collaborative project with many contributors. 327s Type 'contributors()' for more information and 327s 'citation()' on how to cite R or R packages in publications. 327s 327s Type 'demo()' for some demos, 'help()' for on-line help, or 327s 'help.start()' for an HTML browser interface to help. 327s Type 'q()' to quit R. 327s 328s > library("matrixStats") 328s > 328s > count_R <- function(x, value = TRUE, na.rm = FALSE, ...) { 328s + if (is.na(value)) { 328s + counts <- sum(is.na(x)) 328s + } else { 328s + counts <- sum(x == value, na.rm = na.rm) 328s + } 328s + as.integer(counts) 328s + } 328s > 328s > 328s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 328s > # Subsetted tests 328s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 328s > source("utils/validateIndicesFramework.R") 328s > x <- runif(6, min = -3, max = 3) 328s > storage.mode(x) <- "integer" 328s > for (idxs in index_cases) { 328s + validateIndicesTestVector(x, idxs, 328s + ftest = count, fsure = count_R, 328s + value = 0, na.rm = TRUE) 328s + validateIndicesTestVector(x, idxs, 328s + ftest = count, fsure = count_R, 328s + value = 0, na.rm = FALSE) 328s + validateIndicesTestVector(x, idxs, 328s + ftest = count, fsure = count_R, 328s + value = NA_integer_) 328s + } 328s > 328s 328s R version 4.4.3 (2025-02-28) -- "Trophy Case" 328s Copyright (C) 2025 The R Foundation for Statistical Computing 328s Platform: aarch64-unknown-linux-gnu 328s 328s R is free software and comes with ABSOLUTELY NO WARRANTY. 328s You are welcome to redistribute it under certain conditions. 328s Type 'license()' or 'licence()' for distribution details. 328s 328s R is a collaborative project with many contributors. 328s Type 'contributors()' for more information and 328s 'citation()' on how to cite R or R packages in publications. 328s 328s Type 'demo()' for some demos, 'help()' for on-line help, or 328s 'help.start()' for an HTML browser interface to help. 328s Type 'q()' to quit R. 328s 328s > library("matrixStats") 328s > 328s > diff2_R <- function(..., useNames = TRUE){ 328s + res <- diff(...) 328s + if (!useNames) names(res) <- NULL 328s + res 328s + } 328s > 328s > set.seed(0x42) 328s > 328s > for (mode in c("integer", "double")) { 328s + x <- rnorm(10, sd = 5) 328s + storage.mode(x) <- mode 328s + str(x) 328s + 328s + for (has_na in c(FALSE, TRUE)) { 328s + for (setNames in c(TRUE, FALSE)) { 328s + for (useNames in c(TRUE, FALSE)) { 328s + if (has_na) { 328s + x[sample(1:10, size = 3)] <- NA 328s + } 328s + if (setNames) { 328s + names(x) <- LETTERS[1:10] 328s + } 328s + for (l in 1:3) { 328s + for (d in 1:4) { 328s + cat(sprintf("%s: NAs = %s, lag = %d, differences = %d, setNames = %d, useNames = %d\n", 328s + mode, has_na, l, d, setNames, useNames)) 328s + y0 <- diff2_R(x, lag = l, differences = d, useNames = useNames) 328s + str(y0) 328s + y1 <- diff2(x, lag = l, differences = d, useNames = useNames) 328s + str(y1) 328s + stopifnot(identical(y1, y0)) 328s + } 328s + } 328s + } 328s + } 328s + } # for (has_na ...) 328s + } 328s int [1:10] 11 1 2 0 -1 -3 -3 6 0 0 328s integer: NAs = FALSE, lag = 1, differences = 1, setNames = 1, useNames = 1 328s Named int [1:9] -10 1 -2 -1 -2 0 9 -6 0 328s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 328s Named int [1:9] -10 1 -2 -1 -2 0 9 -6 0 328s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 328s integer: NAs = FALSE, lag = 1, differences = 2, setNames = 1, useNames = 1 328s Named int [1:8] 11 -3 1 -1 2 9 -15 6 328s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 328s Named int [1:8] 11 -3 1 -1 2 9 -15 6 328s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 328s integer: NAs = FALSE, lag = 1, differences = 3, setNames = 1, useNames = 1 328s Named int [1:7] -14 4 -2 3 7 -24 21 328s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 328s Named int [1:7] -14 4 -2 3 7 -24 21 328s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 328s integer: NAs = FALSE, lag = 1, differences = 4, setNames = 1, useNames = 1 328s Named int [1:6] 18 -6 5 4 -31 45 328s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 328s Named int [1:6] 18 -6 5 4 -31 45 328s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 328s integer: NAs = FALSE, lag = 2, differences = 1, setNames = 1, useNames = 1 328s Named int [1:8] -9 -1 -3 -3 -2 9 3 -6 328s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 328s Named int [1:8] -9 -1 -3 -3 -2 9 3 -6 328s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 328s integer: NAs = FALSE, lag = 2, differences = 2, setNames = 1, useNames = 1 328s Named int [1:6] 6 -2 1 12 5 -15 328s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 328s Named int [1:6] 6 -2 1 12 5 -15 328s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 328s integer: NAs = FALSE, lag = 2, differences = 3, setNames = 1, useNames = 1 328s Named int [1:4] -5 14 4 -27 328s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 328s Named int [1:4] -5 14 4 -27 328s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 328s integer: NAs = FALSE, lag = 2, differences = 4, setNames = 1, useNames = 1 328s Named int [1:2] 9 -41 328s - attr(*, "names")= chr [1:2] "I" "J" 328s Named int [1:2] 9 -41 328s - attr(*, "names")= chr [1:2] "I" "J" 328s integer: NAs = FALSE, lag = 3, differences = 1, setNames = 1, useNames = 1 328s Named int [1:7] -11 -2 -5 -3 7 3 3 328s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 328s Named int [1:7] -11 -2 -5 -3 7 3 3 328s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 328s integer: NAs = FALSE, lag = 3, differences = 2, setNames = 1, useNames = 1 328s Named int [1:4] 8 9 8 6 328s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 328s Named int [1:4] 8 9 8 6 328s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 328s integer: NAs = FALSE, lag = 3, differences = 3, setNames = 1, useNames = 1 328s Named int -2 328s - attr(*, "names")= chr "J" 328s Named int -2 328s - attr(*, "names")= chr "J" 328s integer: NAs = FALSE, lag = 3, differences = 4, setNames = 1, useNames = 1 328s Named int(0) 328s - attr(*, "names")= chr(0) 328s Named int(0) 328s - attr(*, "names")= chr(0) 328s integer: NAs = FALSE, lag = 1, differences = 1, setNames = 1, useNames = 0 328s int [1:9] -10 1 -2 -1 -2 0 9 -6 0 328s int [1:9] -10 1 -2 -1 -2 0 9 -6 0 328s integer: NAs = FALSE, lag = 1, differences = 2, setNames = 1, useNames = 0 328s int [1:8] 11 -3 1 -1 2 9 -15 6 328s int [1:8] 11 -3 1 -1 2 9 -15 6 328s integer: NAs = FALSE, lag = 1, differences = 3, setNames = 1, useNames = 0 328s int [1:7] -14 4 -2 3 7 -24 21 328s int [1:7] -14 4 -2 3 7 -24 21 328s integer: NAs = FALSE, lag = 1, differences = 4, setNames = 1, useNames = 0 328s int [1:6] 18 -6 5 4 -31 45 328s int [1:6] 18 -6 5 4 -31 45 328s integer: NAs = FALSE, lag = 2, differences = 1, setNames = 1, useNames = 0 328s int [1:8] -9 -1 -3 -3 -2 9 3 -6 328s int [1:8] -9 -1 -3 -3 -2 9 3 -6 328s integer: NAs = FALSE, lag = 2, differences = 2, setNames = 1, useNames = 0 328s int [1:6] 6 -2 1 12 5 -15 328s int [1:6] 6 -2 1 12 5 -15 328s integer: NAs = FALSE, lag = 2, differences = 3, setNames = 1, useNames = 0 328s int [1:4] -5 14 4 -27 328s int [1:4] -5 14 4 -27 328s integer: NAs = FALSE, lag = 2, differences = 4, setNames = 1, useNames = 0 328s int [1:2] 9 -41 328s int [1:2] 9 -41 328s integer: NAs = FALSE, lag = 3, differences = 1, setNames = 1, useNames = 0 328s int [1:7] -11 -2 -5 -3 7 3 3 328s int [1:7] -11 -2 -5 -3 7 3 3 328s integer: NAs = FALSE, lag = 3, differences = 2, setNames = 1, useNames = 0 328s int [1:4] 8 9 8 6 328s int [1:4] 8 9 8 6 328s integer: NAs = FALSE, lag = 3, differences = 3, setNames = 1, useNames = 0 328s int -2 328s int -2 328s integer: NAs = FALSE, lag = 3, differences = 4, setNames = 1, useNames = 0 328s int(0) 328s int(0) 328s integer: NAs = FALSE, lag = 1, differences = 1, setNames = 0, useNames = 1 328s Named int [1:9] -10 1 -2 -1 -2 0 9 -6 0 328s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 328s Named int [1:9] -10 1 -2 -1 -2 0 9 -6 0 328s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 328s integer: NAs = FALSE, lag = 1, differences = 2, setNames = 0, useNames = 1 328s Named int [1:8] 11 -3 1 -1 2 9 -15 6 328s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 328s Named int [1:8] 11 -3 1 -1 2 9 -15 6 328s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 328s integer: NAs = FALSE, lag = 1, differences = 3, setNames = 0, useNames = 1 328s Named int [1:7] -14 4 -2 3 7 -24 21 328s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 328s Named int [1:7] -14 4 -2 3 7 -24 21 328s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 328s integer: NAs = FALSE, lag = 1, differences = 4, setNames = 0, useNames = 1 328s Named int [1:6] 18 -6 5 4 -31 45 328s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 328s Named int [1:6] 18 -6 5 4 -31 45 328s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 328s integer: NAs = FALSE, lag = 2, differences = 1, setNames = 0, useNames = 1 328s Named int [1:8] -9 -1 -3 -3 -2 9 3 -6 328s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 328s Named int [1:8] -9 -1 -3 -3 -2 9 3 -6 328s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 328s integer: NAs = FALSE, lag = 2, differences = 2, setNames = 0, useNames = 1 328s Named int [1:6] 6 -2 1 12 5 -15 328s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 328s Named int [1:6] 6 -2 1 12 5 -15 328s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 328s integer: NAs = FALSE, lag = 2, differences = 3, setNames = 0, useNames = 1 328s Named int [1:4] -5 14 4 -27 328s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 328s Named int [1:4] -5 14 4 -27 328s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 328s integer: NAs = FALSE, lag = 2, differences = 4, setNames = 0, useNames = 1 328s Named int [1:2] 9 -41 328s - attr(*, "names")= chr [1:2] "I" "J" 328s Named int [1:2] 9 -41 328s - attr(*, "names")= chr [1:2] "I" "J" 328s integer: NAs = FALSE, lag = 3, differences = 1, setNames = 0, useNames = 1 328s Named int [1:7] -11 -2 -5 -3 7 3 3 328s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 328s Named int [1:7] -11 -2 -5 -3 7 3 3 328s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 328s integer: NAs = FALSE, lag = 3, differences = 2, setNames = 0, useNames = 1 328s Named int [1:4] 8 9 8 6 328s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 328s Named int [1:4] 8 9 8 6 328s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 328s integer: NAs = FALSE, lag = 3, differences = 3, setNames = 0, useNames = 1 328s Named int -2 328s - attr(*, "names")= chr "J" 328s Named int -2 328s - attr(*, "names")= chr "J" 328s integer: NAs = FALSE, lag = 3, differences = 4, setNames = 0, useNames = 1 328s Named int(0) 328s - attr(*, "names")= chr(0) 328s Named int(0) 328s - attr(*, "names")= chr(0) 328s integer: NAs = FALSE, lag = 1, differences = 1, setNames = 0, useNames = 0 328s int [1:9] -10 1 -2 -1 -2 0 9 -6 0 328s int [1:9] -10 1 -2 -1 -2 0 9 -6 0 328s integer: NAs = FALSE, lag = 1, differences = 2, setNames = 0, useNames = 0 328s int [1:8] 11 -3 1 -1 2 9 -15 6 328s int [1:8] 11 -3 1 -1 2 9 -15 6 328s integer: NAs = FALSE, lag = 1, differences = 3, setNames = 0, useNames = 0 328s int [1:7] -14 4 -2 3 7 -24 21 328s int [1:7] -14 4 -2 3 7 -24 21 328s integer: NAs = FALSE, lag = 1, differences = 4, setNames = 0, useNames = 0 328s int [1:6] 18 -6 5 4 -31 45 328s int [1:6] 18 -6 5 4 -31 45 328s integer: NAs = FALSE, lag = 2, differences = 1, setNames = 0, useNames = 0 328s int [1:8] -9 -1 -3 -3 -2 9 3 -6 328s int [1:8] -9 -1 -3 -3 -2 9 3 -6 328s integer: NAs = FALSE, lag = 2, differences = 2, setNames = 0, useNames = 0 328s int [1:6] 6 -2 1 12 5 -15 328s int [1:6] 6 -2 1 12 5 -15 328s integer: NAs = FALSE, lag = 2, differences = 3, setNames = 0, useNames = 0 328s int [1:4] -5 14 4 -27 328s int [1:4] -5 14 4 -27 328s integer: NAs = FALSE, lag = 2, differences = 4, setNames = 0, useNames = 0 328s int [1:2] 9 -41 328s int [1:2] 9 -41 328s integer: NAs = FALSE, lag = 3, differences = 1, setNames = 0, useNames = 0 328s int [1:7] -11 -2 -5 -3 7 3 3 328s int [1:7] -11 -2 -5 -3 7 3 3 328s integer: NAs = FALSE, lag = 3, differences = 2, setNames = 0, useNames = 0 328s int [1:4] 8 9 8 6 328s int [1:4] 8 9 8 6 328s integer: NAs = FALSE, lag = 3, differences = 3, setNames = 0, useNames = 0 328s int -2 328s int -2 328s integer: NAs = FALSE, lag = 3, differences = 4, setNames = 0, useNames = 0 328s int(0) 328s int(0) 328s integer: NAs = TRUE, lag = 1, differences = 1, setNames = 1, useNames = 1 328s Named int [1:9] NA NA NA NA NA 0 9 -6 0 328s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 328s Named int [1:9] NA NA NA NA NA 0 9 -6 0 328s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 328s integer: NAs = TRUE, lag = 1, differences = 2, setNames = 1, useNames = 1 328s Named int [1:8] NA NA NA NA NA 9 -15 6 328s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 328s Named int [1:8] NA NA NA NA NA 9 -15 6 328s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 328s integer: NAs = TRUE, lag = 1, differences = 3, setNames = 1, useNames = 1 328s Named int [1:7] NA NA NA NA NA -24 21 328s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 328s Named int [1:7] NA NA NA NA NA -24 21 328s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 328s integer: NAs = TRUE, lag = 1, differences = 4, setNames = 1, useNames = 1 328s Named int [1:6] NA NA NA NA NA 45 328s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 328s Named int [1:6] NA NA NA NA NA 45 328s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 328s integer: NAs = TRUE, lag = 2, differences = 1, setNames = 1, useNames = 1 328s Named int [1:8] -9 NA NA NA NA 9 3 -6 328s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 328s Named int [1:8] -9 NA NA NA NA 9 3 -6 328s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 328s integer: NAs = TRUE, lag = 2, differences = 2, setNames = 1, useNames = 1 328s Named int [1:6] NA NA NA NA NA -15 328s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 328s Named int [1:6] NA NA NA NA NA -15 328s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 328s integer: NAs = TRUE, lag = 2, differences = 3, setNames = 1, useNames = 1 328s Named int [1:4] NA NA NA NA 328s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 328s Named int [1:4] NA NA NA NA 328s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 328s integer: NAs = TRUE, lag = 2, differences = 4, setNames = 1, useNames = 1 328s Named int [1:2] NA NA 328s - attr(*, "names")= chr [1:2] "I" "J" 328s Named int [1:2] NA NA 328s - attr(*, "names")= chr [1:2] "I" "J" 328s integer: NAs = TRUE, lag = 3, differences = 1, setNames = 1, useNames = 1 328s Named int [1:7] NA NA -5 NA NA 3 3 328s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 328s Named int [1:7] NA NA -5 NA NA 3 3 328s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 328s integer: NAs = TRUE, lag = 3, differences = 2, setNames = 1, useNames = 1 328s Named int [1:4] NA NA 8 NA 328s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 328s Named int [1:4] NA NA 8 NA 328s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 328s integer: NAs = TRUE, lag = 3, differences = 3, setNames = 1, useNames = 1 328s Named int NA 328s - attr(*, "names")= chr "J" 328s Named int NA 328s - attr(*, "names")= chr "J" 328s integer: NAs = TRUE, lag = 3, differences = 4, setNames = 1, useNames = 1 328s Named int(0) 328s - attr(*, "names")= chr(0) 328s Named int(0) 328s - attr(*, "names")= chr(0) 328s integer: NAs = TRUE, lag = 1, differences = 1, setNames = 1, useNames = 0 328s int [1:9] NA NA NA NA NA 0 9 NA NA 328s int [1:9] NA NA NA NA NA 0 9 NA NA 328s integer: NAs = TRUE, lag = 1, differences = 2, setNames = 1, useNames = 0 328s int [1:8] NA NA NA NA NA 9 NA NA 328s int [1:8] NA NA NA NA NA 9 NA NA 328s integer: NAs = TRUE, lag = 1, differences = 3, setNames = 1, useNames = 0 328s int [1:7] NA NA NA NA NA NA NA 328s int [1:7] NA NA NA NA NA NA NA 328s integer: NAs = TRUE, lag = 1, differences = 4, setNames = 1, useNames = 0 328s int [1:6] NA NA NA NA NA NA 328s int [1:6] NA NA NA NA NA NA 328s integer: NAs = TRUE, lag = 2, differences = 1, setNames = 1, useNames = 0 328s int [1:8] NA NA NA NA NA 9 NA -6 328s int [1:8] NA NA NA NA NA 9 NA -6 328s integer: NAs = TRUE, lag = 2, differences = 2, setNames = 1, useNames = 0 328s int [1:6] NA NA NA NA NA -15 328s int [1:6] NA NA NA NA NA -15 328s integer: NAs = TRUE, lag = 2, differences = 3, setNames = 1, useNames = 0 328s int [1:4] NA NA NA NA 328s int [1:4] NA NA NA NA 328s integer: NAs = TRUE, lag = 2, differences = 4, setNames = 1, useNames = 0 328s int [1:2] NA NA 328s int [1:2] NA NA 328s integer: NAs = TRUE, lag = 3, differences = 1, setNames = 1, useNames = 0 328s int [1:7] NA NA NA NA NA NA 3 328s int [1:7] NA NA NA NA NA NA 3 328s integer: NAs = TRUE, lag = 3, differences = 2, setNames = 1, useNames = 0 328s int [1:4] NA NA NA NA 328s int [1:4] NA NA NA NA 328s integer: NAs = TRUE, lag = 3, differences = 3, setNames = 1, useNames = 0 328s int NA 328s int NA 328s integer: NAs = TRUE, lag = 3, differences = 4, setNames = 1, useNames = 0 328s int(0) 328s int(0) 328s integer: NAs = TRUE, lag = 1, differences = 1, setNames = 0, useNames = 1 328s Named int [1:9] NA NA NA NA NA NA NA NA NA 328s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 328s Named int [1:9] NA NA NA NA NA NA NA NA NA 328s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 328s integer: NAs = TRUE, lag = 1, differences = 2, setNames = 0, useNames = 1 328s Named int [1:8] NA NA NA NA NA NA NA NA 328s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 328s Named int [1:8] NA NA NA NA NA NA NA NA 328s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 328s integer: NAs = TRUE, lag = 1, differences = 3, setNames = 0, useNames = 1 328s Named int [1:7] NA NA NA NA NA NA NA 328s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 328s Named int [1:7] NA NA NA NA NA NA NA 328s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 328s integer: NAs = TRUE, lag = 1, differences = 4, setNames = 0, useNames = 1 328s Named int [1:6] NA NA NA NA NA NA 328s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 328s Named int [1:6] NA NA NA NA NA NA 328s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 328s integer: NAs = TRUE, lag = 2, differences = 1, setNames = 0, useNames = 1 328s Named int [1:8] NA NA NA NA NA NA NA NA 328s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 328s Named int [1:8] NA NA NA NA NA NA NA NA 328s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 328s integer: NAs = TRUE, lag = 2, differences = 2, setNames = 0, useNames = 1 328s Named int [1:6] NA NA NA NA NA NA 328s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 328s Named int [1:6] NA NA NA NA NA NA 328s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 328s integer: NAs = TRUE, lag = 2, differences = 3, setNames = 0, useNames = 1 328s Named int [1:4] NA NA NA NA 328s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 328s Named int [1:4] NA NA NA NA 328s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 328s integer: NAs = TRUE, lag = 2, differences = 4, setNames = 0, useNames = 1 328s Named int [1:2] NA NA 328s - attr(*, "names")= chr [1:2] "I" "J" 328s Named int [1:2] NA NA 328s - attr(*, "names")= chr [1:2] "I" "J" 328s integer: NAs = TRUE, lag = 3, differences = 1, setNames = 0, useNames = 1 328s Named int [1:7] NA NA NA NA NA NA 3 328s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 328s Named int [1:7] NA NA NA NA NA NA 3 328s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 328s integer: NAs = TRUE, lag = 3, differences = 2, setNames = 0, useNames = 1 328s Named int [1:4] NA NA NA NA 328s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 328s Named int [1:4] NA NA NA NA 328s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 328s integer: NAs = TRUE, lag = 3, differences = 3, setNames = 0, useNames = 1 328s Named int NA 328s - attr(*, "names")= chr "J" 328s Named int NA 328s - attr(*, "names")= chr "J" 328s integer: NAs = TRUE, lag = 3, differences = 4, setNames = 0, useNames = 1 328s Named int(0) 328s - attr(*, "names")= chr(0) 328s Named int(0) 328s - attr(*, "names")= chr(0) 328s integer: NAs = TRUE, lag = 1, differences = 1, setNames = 0, useNames = 0 328s int [1:9] NA NA NA NA NA NA NA NA NA 328s int [1:9] NA NA NA NA NA NA NA NA NA 328s integer: NAs = TRUE, lag = 1, differences = 2, setNames = 0, useNames = 0 328s int [1:8] NA NA NA NA NA NA NA NA 328s int [1:8] NA NA NA NA NA NA NA NA 328s integer: NAs = TRUE, lag = 1, differences = 3, setNames = 0, useNames = 0 328s int [1:7] NA NA NA NA NA NA NA 328s int [1:7] NA NA NA NA NA NA NA 328s integer: NAs = TRUE, lag = 1, differences = 4, setNames = 0, useNames = 0 328s int [1:6] NA NA NA NA NA NA 328s int [1:6] NA NA NA NA NA NA 328s integer: NAs = TRUE, lag = 2, differences = 1, setNames = 0, useNames = 0 328s int [1:8] NA NA NA NA NA NA NA NA 328s int [1:8] NA NA NA NA NA NA NA NA 328s integer: NAs = TRUE, lag = 2, differences = 2, setNames = 0, useNames = 0 328s int [1:6] NA NA NA NA NA NA 328s int [1:6] NA NA NA NA NA NA 328s integer: NAs = TRUE, lag = 2, differences = 3, setNames = 0, useNames = 0 328s int [1:4] NA NA NA NA 328s int [1:4] NA NA NA NA 328s integer: NAs = TRUE, lag = 2, differences = 4, setNames = 0, useNames = 0 328s int [1:2] NA NA 328s int [1:2] NA NA 328s integer: NAs = TRUE, lag = 3, differences = 1, setNames = 0, useNames = 0 328s int [1:7] NA NA NA NA NA NA 3 328s int [1:7] NA NA NA NA NA NA 3 328s integer: NAs = TRUE, lag = 3, differences = 2, setNames = 0, useNames = 0 328s int [1:4] NA NA NA NA 328s int [1:4] NA NA NA NA 328s integer: NAs = TRUE, lag = 3, differences = 3, setNames = 0, useNames = 0 328s int NA 328s int NA 328s integer: NAs = TRUE, lag = 3, differences = 4, setNames = 0, useNames = 0 328s int(0) 328s int(0) 328s num [1:10] 2.586 -0.344 0.33 9.155 -3.254 ... 328s double: NAs = FALSE, lag = 1, differences = 1, setNames = 1, useNames = 1 328s Named num [1:9] -2.929 0.673 8.826 -12.409 -1.221 ... 328s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 328s Named num [1:9] -2.929 0.673 8.826 -12.409 -1.221 ... 328s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 328s double: NAs = FALSE, lag = 1, differences = 2, setNames = 1, useNames = 1 328s Named num [1:8] 3.6 8.15 -21.23 11.19 -2.1 ... 328s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 328s Named num [1:8] 3.6 8.15 -21.23 11.19 -2.1 ... 328s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 328s double: NAs = FALSE, lag = 1, differences = 3, setNames = 1, useNames = 1 328s Named num [1:7] 4.55 -29.39 32.42 -13.29 14.97 ... 328s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 328s Named num [1:7] 4.55 -29.39 32.42 -13.29 14.97 ... 328s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 328s double: NAs = FALSE, lag = 1, differences = 4, setNames = 1, useNames = 1 328s Named num [1:6] -33.9 61.8 -45.7 28.3 -37 ... 328s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 328s Named num [1:6] -33.9 61.8 -45.7 28.3 -37 ... 328s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 328s double: NAs = FALSE, lag = 2, differences = 1, setNames = 1, useNames = 1 328s Named num [1:8] -2.26 9.5 -3.58 -13.63 -4.54 ... 328s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 328s Named num [1:8] -2.26 9.5 -3.58 -13.63 -4.54 ... 328s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 328s double: NAs = FALSE, lag = 2, differences = 2, setNames = 1, useNames = 1 328s Named num [1:6] -1.33 -23.13 -0.96 19.86 14.44 ... 328s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 328s Named num [1:6] -1.33 -23.13 -0.96 19.86 14.44 ... 328s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 328s double: NAs = FALSE, lag = 2, differences = 3, setNames = 1, useNames = 1 328s Named num [1:4] 0.368 42.988 15.396 -29.313 328s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 328s Named num [1:4] 0.368 42.988 15.396 -29.313 328s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 328s double: NAs = FALSE, lag = 2, differences = 4, setNames = 1, useNames = 1 328s Named num [1:2] 15 -72.3 328s - attr(*, "names")= chr [1:2] "I" "J" 328s Named num [1:2] 15 -72.3 328s - attr(*, "names")= chr [1:2] "I" "J" 328s double: NAs = FALSE, lag = 3, differences = 1, setNames = 1, useNames = 1 328s Named num [1:7] 6.57 -2.91 -4.81 -16.95 5.01 ... 328s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 328s Named num [1:7] 6.57 -2.91 -4.81 -16.95 5.01 ... 328s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 328s double: NAs = FALSE, lag = 3, differences = 2, setNames = 1, useNames = 1 328s Named num [1:4] -23.52 7.92 11.38 23.27 328s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 328s Named num [1:4] -23.52 7.92 11.38 23.27 328s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 328s double: NAs = FALSE, lag = 3, differences = 3, setNames = 1, useNames = 1 328s Named num 46.8 328s - attr(*, "names")= chr "J" 328s Named num 46.8 328s - attr(*, "names")= chr "J" 328s double: NAs = FALSE, lag = 3, differences = 4, setNames = 1, useNames = 1 328s Named num(0) 328s - attr(*, "names")= chr(0) 328s Named num(0) 328s - attr(*, "names")= chr(0) 328s double: NAs = FALSE, lag = 1, differences = 1, setNames = 1, useNames = 0 328s num [1:9] -2.929 0.673 8.826 -12.409 -1.221 ... 328s num [1:9] -2.929 0.673 8.826 -12.409 -1.221 ... 328s double: NAs = FALSE, lag = 1, differences = 2, setNames = 1, useNames = 0 328s num [1:8] 3.6 8.15 -21.23 11.19 -2.1 ... 328s num [1:8] 3.6 8.15 -21.23 11.19 -2.1 ... 328s double: NAs = FALSE, lag = 1, differences = 3, setNames = 1, useNames = 0 328s num [1:7] 4.55 -29.39 32.42 -13.29 14.97 ... 328s num [1:7] 4.55 -29.39 32.42 -13.29 14.97 ... 328s double: NAs = FALSE, lag = 1, differences = 4, setNames = 1, useNames = 0 328s num [1:6] -33.9 61.8 -45.7 28.3 -37 ... 328s num [1:6] -33.9 61.8 -45.7 28.3 -37 ... 328s double: NAs = FALSE, lag = 2, differences = 1, setNames = 1, useNames = 0 328s num [1:8] -2.26 9.5 -3.58 -13.63 -4.54 ... 328s num [1:8] -2.26 9.5 -3.58 -13.63 -4.54 ... 328s double: NAs = FALSE, lag = 2, differences = 2, setNames = 1, useNames = 0 328s num [1:6] -1.33 -23.13 -0.96 19.86 14.44 ... 328s num [1:6] -1.33 -23.13 -0.96 19.86 14.44 ... 328s double: NAs = FALSE, lag = 2, differences = 3, setNames = 1, useNames = 0 328s num [1:4] 0.368 42.988 15.396 -29.313 328s num [1:4] 0.368 42.988 15.396 -29.313 328s double: NAs = FALSE, lag = 2, differences = 4, setNames = 1, useNames = 0 328s num [1:2] 15 -72.3 328s num [1:2] 15 -72.3 328s double: NAs = FALSE, lag = 3, differences = 1, setNames = 1, useNames = 0 328s num [1:7] 6.57 -2.91 -4.81 -16.95 5.01 ... 328s num [1:7] 6.57 -2.91 -4.81 -16.95 5.01 ... 328s double: NAs = FALSE, lag = 3, differences = 2, setNames = 1, useNames = 0 328s num [1:4] -23.52 7.92 11.38 23.27 328s num [1:4] -23.52 7.92 11.38 23.27 328s double: NAs = FALSE, lag = 3, differences = 3, setNames = 1, useNames = 0 328s num 46.8 328s num 46.8 328s double: NAs = FALSE, lag = 3, differences = 4, setNames = 1, useNames = 0 328s num(0) 328s num(0) 328s double: NAs = FALSE, lag = 1, differences = 1, setNames = 0, useNames = 1 328s Named num [1:9] -2.929 0.673 8.826 -12.409 -1.221 ... 328s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 328s Named num [1:9] -2.929 0.673 8.826 -12.409 -1.221 ... 328s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 328s double: NAs = FALSE, lag = 1, differences = 2, setNames = 0, useNames = 1 328s Named num [1:8] 3.6 8.15 -21.23 11.19 -2.1 ... 328s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 328s Named num [1:8] 3.6 8.15 -21.23 11.19 -2.1 ... 328s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 328s double: NAs = FALSE, lag = 1, differences = 3, setNames = 0, useNames = 1 328s Named num [1:7] 4.55 -29.39 32.42 -13.29 14.97 ... 328s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 328s Named num [1:7] 4.55 -29.39 32.42 -13.29 14.97 ... 328s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 328s double: NAs = FALSE, lag = 1, differences = 4, setNames = 0, useNames = 1 328s Named num [1:6] -33.9 61.8 -45.7 28.3 -37 ... 328s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 328s Named num [1:6] -33.9 61.8 -45.7 28.3 -37 ... 328s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 328s double: NAs = FALSE, lag = 2, differences = 1, setNames = 0, useNames = 1 328s Named num [1:8] -2.26 9.5 -3.58 -13.63 -4.54 ... 328s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 328s Named num [1:8] -2.26 9.5 -3.58 -13.63 -4.54 ... 328s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 328s double: NAs = FALSE, lag = 2, differences = 2, setNames = 0, useNames = 1 328s Named num [1:6] -1.33 -23.13 -0.96 19.86 14.44 ... 328s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 328s Named num [1:6] -1.33 -23.13 -0.96 19.86 14.44 ... 328s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 328s double: NAs = FALSE, lag = 2, differences = 3, setNames = 0, useNames = 1 328s Named num [1:4] 0.368 42.988 15.396 -29.313 328s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 328s Named num [1:4] 0.368 42.988 15.396 -29.313 328s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 328s double: NAs = FALSE, lag = 2, differences = 4, setNames = 0, useNames = 1 328s Named num [1:2] 15 -72.3 328s - attr(*, "names")= chr [1:2] "I" "J" 328s Named num [1:2] 15 -72.3 328s - attr(*, "names")= chr [1:2] "I" "J" 328s double: NAs = FALSE, lag = 3, differences = 1, setNames = 0, useNames = 1 328s Named num [1:7] 6.57 -2.91 -4.81 -16.95 5.01 ... 328s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 328s Named num [1:7] 6.57 -2.91 -4.81 -16.95 5.01 ... 328s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 328s double: NAs = FALSE, lag = 3, differences = 2, setNames = 0, useNames = 1 328s Named num [1:4] -23.52 7.92 11.38 23.27 328s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 328s Named num [1:4] -23.52 7.92 11.38 23.27 328s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 328s double: NAs = FALSE, lag = 3, differences = 3, setNames = 0, useNames = 1 328s Named num 46.8 328s - attr(*, "names")= chr "J" 328s Named num 46.8 328s - attr(*, "names")= chr "J" 328s double: NAs = FALSE, lag = 3, differences = 4, setNames = 0, useNames = 1 328s Named num(0) 328s - attr(*, "names")= chr(0) 328s Named num(0) 328s - attr(*, "names")= chr(0) 328s double: NAs = FALSE, lag = 1, differences = 1, setNames = 0, useNames = 0 328s num [1:9] -2.929 0.673 8.826 -12.409 -1.221 ... 328s num [1:9] -2.929 0.673 8.826 -12.409 -1.221 ... 328s double: NAs = FALSE, lag = 1, differences = 2, setNames = 0, useNames = 0 328s num [1:8] 3.6 8.15 -21.23 11.19 -2.1 ... 328s num [1:8] 3.6 8.15 -21.23 11.19 -2.1 ... 328s double: NAs = FALSE, lag = 1, differences = 3, setNames = 0, useNames = 0 328s num [1:7] 4.55 -29.39 32.42 -13.29 14.97 ... 328s num [1:7] 4.55 -29.39 32.42 -13.29 14.97 ... 328s double: NAs = FALSE, lag = 1, differences = 4, setNames = 0, useNames = 0 328s num [1:6] -33.9 61.8 -45.7 28.3 -37 ... 328s num [1:6] -33.9 61.8 -45.7 28.3 -37 ... 328s double: NAs = FALSE, lag = 2, differences = 1, setNames = 0, useNames = 0 328s num [1:8] -2.26 9.5 -3.58 -13.63 -4.54 ... 328s num [1:8] -2.26 9.5 -3.58 -13.63 -4.54 ... 328s double: NAs = FALSE, lag = 2, differences = 2, setNames = 0, useNames = 0 328s num [1:6] -1.33 -23.13 -0.96 19.86 14.44 ... 328s num [1:6] -1.33 -23.13 -0.96 19.86 14.44 ... 328s double: NAs = FALSE, lag = 2, differences = 3, setNames = 0, useNames = 0 328s num [1:4] 0.368 42.988 15.396 -29.313 328s num [1:4] 0.368 42.988 15.396 -29.313 328s double: NAs = FALSE, lag = 2, differences = 4, setNames = 0, useNames = 0 328s num [1:2] 15 -72.3 328s num [1:2] 15 -72.3 328s double: NAs = FALSE, lag = 3, differences = 1, setNames = 0, useNames = 0 328s num [1:7] 6.57 -2.91 -4.81 -16.95 5.01 ... 328s num [1:7] 6.57 -2.91 -4.81 -16.95 5.01 ... 328s double: NAs = FALSE, lag = 3, differences = 2, setNames = 0, useNames = 0 328s num [1:4] -23.52 7.92 11.38 23.27 328s num [1:4] -23.52 7.92 11.38 23.27 328s double: NAs = FALSE, lag = 3, differences = 3, setNames = 0, useNames = 0 328s num 46.8 328s num 46.8 328s double: NAs = FALSE, lag = 3, differences = 4, setNames = 0, useNames = 0 328s num(0) 328s num(0) 328s double: NAs = TRUE, lag = 1, differences = 1, setNames = 1, useNames = 1 328s Named num [1:9] -2.929 0.673 8.826 NA NA ... 328s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 328s Named num [1:9] -2.929 0.673 8.826 NA NA ... 328s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 328s double: NAs = TRUE, lag = 1, differences = 2, setNames = 1, useNames = 1 328s Named num [1:8] 3.6 8.15 NA NA NA ... 328s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 328s Named num [1:8] 3.6 8.15 NA NA NA ... 328s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 328s double: NAs = TRUE, lag = 1, differences = 3, setNames = 1, useNames = 1 328s Named num [1:7] 4.55 NA NA NA NA ... 328s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 328s Named num [1:7] 4.55 NA NA NA NA ... 328s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 328s double: NAs = TRUE, lag = 1, differences = 4, setNames = 1, useNames = 1 328s Named num [1:6] NA NA NA NA NA NA 328s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 328s Named num [1:6] NA NA NA NA NA NA 328s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 328s double: NAs = TRUE, lag = 2, differences = 1, setNames = 1, useNames = 1 328s Named num [1:8] -2.26 9.5 NA NA NA ... 328s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 328s Named num [1:8] -2.26 9.5 NA NA NA ... 328s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 328s double: NAs = TRUE, lag = 2, differences = 2, setNames = 1, useNames = 1 328s Named num [1:6] NA NA NA NA NA NA 328s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 328s Named num [1:6] NA NA NA NA NA NA 328s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 328s double: NAs = TRUE, lag = 2, differences = 3, setNames = 1, useNames = 1 328s Named num [1:4] NA NA NA NA 328s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 328s Named num [1:4] NA NA NA NA 328s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 328s double: NAs = TRUE, lag = 2, differences = 4, setNames = 1, useNames = 1 328s Named num [1:2] NA NA 328s - attr(*, "names")= chr [1:2] "I" "J" 328s Named num [1:2] NA NA 328s - attr(*, "names")= chr [1:2] "I" "J" 328s double: NAs = TRUE, lag = 3, differences = 1, setNames = 1, useNames = 1 328s Named num [1:7] 6.57 NA NA -16.95 NA ... 328s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 328s Named num [1:7] 6.57 NA NA -16.95 NA ... 328s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 328s double: NAs = TRUE, lag = 3, differences = 2, setNames = 1, useNames = 1 328s Named num [1:4] -23.5 NA NA 23.3 328s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 328s Named num [1:4] -23.5 NA NA 23.3 328s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 328s double: NAs = TRUE, lag = 3, differences = 3, setNames = 1, useNames = 1 328s Named num 46.8 328s - attr(*, "names")= chr "J" 328s Named num 46.8 328s - attr(*, "names")= chr "J" 328s double: NAs = TRUE, lag = 3, differences = 4, setNames = 1, useNames = 1 328s Named num(0) 328s - attr(*, "names")= chr(0) 328s Named num(0) 328s - attr(*, "names")= chr(0) 328s double: NAs = TRUE, lag = 1, differences = 1, setNames = 1, useNames = 0 328s num [1:9] NA 0.673 8.826 NA NA ... 328s num [1:9] NA 0.673 8.826 NA NA ... 328s double: NAs = TRUE, lag = 1, differences = 2, setNames = 1, useNames = 0 328s num [1:8] NA 8.15 NA NA NA ... 328s num [1:8] NA 8.15 NA NA NA ... 328s double: NAs = TRUE, lag = 1, differences = 3, setNames = 1, useNames = 0 328s num [1:7] NA NA NA NA NA NA NA 328s num [1:7] NA NA NA NA NA NA NA 328s double: NAs = TRUE, lag = 1, differences = 4, setNames = 1, useNames = 0 328s num [1:6] NA NA NA NA NA NA 328s num [1:6] NA NA NA NA NA NA 328s double: NAs = TRUE, lag = 2, differences = 1, setNames = 1, useNames = 0 328s num [1:8] NA 9.5 NA NA NA ... 328s num [1:8] NA 9.5 NA NA NA ... 328s double: NAs = TRUE, lag = 2, differences = 2, setNames = 1, useNames = 0 328s num [1:6] NA NA NA NA NA NA 328s num [1:6] NA NA NA NA NA NA 328s double: NAs = TRUE, lag = 2, differences = 3, setNames = 1, useNames = 0 328s num [1:4] NA NA NA NA 328s num [1:4] NA NA NA NA 328s double: NAs = TRUE, lag = 2, differences = 4, setNames = 1, useNames = 0 328s num [1:2] NA NA 328s num [1:2] NA NA 328s double: NAs = TRUE, lag = 3, differences = 1, setNames = 1, useNames = 0 328s num [1:7] NA NA NA NA NA NA NA 328s num [1:7] NA NA NA NA NA NA NA 328s double: NAs = TRUE, lag = 3, differences = 2, setNames = 1, useNames = 0 328s num [1:4] NA NA NA NA 328s num [1:4] NA NA NA NA 328s double: NAs = TRUE, lag = 3, differences = 3, setNames = 1, useNames = 0 328s num NA 328s num NA 328s double: NAs = TRUE, lag = 3, differences = 4, setNames = 1, useNames = 0 328s num(0) 328s num(0) 328s double: NAs = TRUE, lag = 1, differences = 1, setNames = 0, useNames = 1 328s Named num [1:9] NA 0.673 8.826 NA NA ... 328s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 328s Named num [1:9] NA 0.673 8.826 NA NA ... 328s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 328s double: NAs = TRUE, lag = 1, differences = 2, setNames = 0, useNames = 1 328s Named num [1:8] NA 8.15 NA NA NA ... 328s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 328s Named num [1:8] NA 8.15 NA NA NA ... 328s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 328s double: NAs = TRUE, lag = 1, differences = 3, setNames = 0, useNames = 1 328s Named num [1:7] NA NA NA NA NA NA NA 328s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 328s Named num [1:7] NA NA NA NA NA NA NA 328s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 328s double: NAs = TRUE, lag = 1, differences = 4, setNames = 0, useNames = 1 328s Named num [1:6] NA NA NA NA NA NA 328s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 328s Named num [1:6] NA NA NA NA NA NA 328s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 328s double: NAs = TRUE, lag = 2, differences = 1, setNames = 0, useNames = 1 328s Named num [1:8] NA 9.5 NA NA NA ... 328s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 328s Named num [1:8] NA 9.5 NA NA NA ... 328s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 328s double: NAs = TRUE, lag = 2, differences = 2, setNames = 0, useNames = 1 328s Named num [1:6] NA NA NA NA NA NA 328s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 328s Named num [1:6] NA NA NA NA NA NA 328s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 328s double: NAs = TRUE, lag = 2, differences = 3, setNames = 0, useNames = 1 328s Named num [1:4] NA NA NA NA 328s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 328s Named num [1:4] NA NA NA NA 328s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 328s double: NAs = TRUE, lag = 2, differences = 4, setNames = 0, useNames = 1 328s Named num [1:2] NA NA 328s - attr(*, "names")= chr [1:2] "I" "J" 328s Named num [1:2] NA NA 328s - attr(*, "names")= chr [1:2] "I" "J" 328s double: NAs = TRUE, lag = 3, differences = 1, setNames = 0, useNames = 1 328s Named num [1:7] NA NA NA NA NA NA NA 328s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 328s Named num [1:7] NA NA NA NA NA NA NA 328s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 328s double: NAs = TRUE, lag = 3, differences = 2, setNames = 0, useNames = 1 328s Named num [1:4] NA NA NA NA 328s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 328s Named num [1:4] NA NA NA NA 328s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 328s double: NAs = TRUE, lag = 3, differences = 3, setNames = 0, useNames = 1 328s Named num NA 328s - attr(*, "names")= chr "J" 328s Named num NA 328s - attr(*, "names")= chr "J" 328s double: NAs = TRUE, lag = 3, differences = 4, setNames = 0, useNames = 1 328s Named num(0) 328s - attr(*, "names")= chr(0) 328s Named num(0) 328s - attr(*, "names")= chr(0) 328s double: NAs = TRUE, lag = 1, differences = 1, setNames = 0, useNames = 0 328s num [1:9] NA 0.673 8.826 NA NA ... 328s num [1:9] NA 0.673 8.826 NA NA ... 328s double: NAs = TRUE, lag = 1, differences = 2, setNames = 0, useNames = 0 328s num [1:8] NA 8.15 NA NA NA ... 328s num [1:8] NA 8.15 NA NA NA ... 328s double: NAs = TRUE, lag = 1, differences = 3, setNames = 0, useNames = 0 328s num [1:7] NA NA NA NA NA NA NA 328s num [1:7] NA NA NA NA NA NA NA 328s double: NAs = TRUE, lag = 1, differences = 4, setNames = 0, useNames = 0 328s num [1:6] NA NA NA NA NA NA 328s num [1:6] NA NA NA NA NA NA 328s double: NAs = TRUE, lag = 2, differences = 1, setNames = 0, useNames = 0 328s num [1:8] NA 9.5 NA NA NA ... 328s num [1:8] NA 9.5 NA NA NA ... 328s double: NAs = TRUE, lag = 2, differences = 2, setNames = 0, useNames = 0 328s num [1:6] NA NA NA NA NA NA 328s num [1:6] NA NA NA NA NA NA 328s double: NAs = TRUE, lag = 2, differences = 3, setNames = 0, useNames = 0 328s num [1:4] NA NA NA NA 328s num [1:4] NA NA NA NA 328s double: NAs = TRUE, lag = 2, differences = 4, setNames = 0, useNames = 0 328s num [1:2] NA NA 328s num [1:2] NA NA 328s double: NAs = TRUE, lag = 3, differences = 1, setNames = 0, useNames = 0 328s num [1:7] NA NA NA NA NA NA NA 328s num [1:7] NA NA NA NA NA NA NA 328s double: NAs = TRUE, lag = 3, differences = 2, setNames = 0, useNames = 0 328s num [1:4] NA NA NA NA 328s num [1:4] NA NA NA NA 328s double: NAs = TRUE, lag = 3, differences = 3, setNames = 0, useNames = 0 328s num NA 328s num NA 328s double: NAs = TRUE, lag = 3, differences = 4, setNames = 0, useNames = 0 328s num(0) 328s num(0) 328s > 328s 328s R version 4.4.3 (2025-02-28) -- "Trophy Case" 328s Copyright (C) 2025 The R Foundation for Statistical Computing 328s Platform: aarch64-unknown-linux-gnu 328s 328s R is free software and comes with ABSOLUTELY NO WARRANTY. 328s You are welcome to redistribute it under certain conditions. 328s Type 'license()' or 'licence()' for distribution details. 328s 328s R is a collaborative project with many contributors. 328s Type 'contributors()' for more information and 328s 'citation()' on how to cite R or R packages in publications. 328s 328s Type 'demo()' for some demos, 'help()' for on-line help, or 328s 'help.start()' for an HTML browser interface to help. 328s Type 'q()' to quit R. 328s 328s > library("matrixStats") 328s > 328s > diff2_R <- function(..., useNames=NA){ 328s + res <- diff(...) 328s + if (!useNames) names(res) <- NULL 328s + res 328s + } 328s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 328s > # Subsetted tests 328s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 328s > source("utils/validateIndicesFramework.R") 328s > x <- runif(6, min = -6, max = 6) 328s > for (setNames in c(TRUE, FALSE)) { 328s + if (setNames) names(x) <- LETTERS[1:6] 328s + else names(x) <- NULL 328s + for (l in 1:2) { 328s + for (d in 1:2) { 328s + for (idxs in index_cases) { 328s + for (useNames in c(TRUE, FALSE)) { 328s + validateIndicesTestVector(x, idxs, 328s + ftest = diff2, fsure = diff2_R, 328s + lag = l, differences = d, useNames = useNames) 328s + } 328s + } 328s + } 328s + } 328s + } 328s > 328s 328s R version 4.4.3 (2025-02-28) -- "Trophy Case" 328s Copyright (C) 2025 The R Foundation for Statistical Computing 328s Platform: aarch64-unknown-linux-gnu 328s 328s R is free software and comes with ABSOLUTELY NO WARRANTY. 328s You are welcome to redistribute it under certain conditions. 328s Type 'license()' or 'licence()' for distribution details. 328s 328s R is a collaborative project with many contributors. 328s Type 'contributors()' for more information and 328s 'citation()' on how to cite R or R packages in publications. 328s 328s Type 'demo()' for some demos, 'help()' for on-line help, or 328s 'help.start()' for an HTML browser interface to help. 328s Type 'q()' to quit R. 328s 329s > library("matrixStats") 329s > 329s > indexByRow_R1 <- function(dim, idxs = NULL, ...) { 329s + n <- prod(dim) 329s + x <- matrix(seq_len(n), nrow = dim[2L], ncol = dim[1L], byrow = TRUE) 329s + if (!is.null(idxs)) 329s + x <- x[idxs] 329s + as.vector(x) 329s + } 329s > 329s > 329s > indexByRow_R2 <- function(dim, idxs = NULL, ...) { 329s + n <- prod(dim) 329s + if (is.null(idxs)) { 329s + x <- matrix(seq_len(n), nrow = dim[2L], ncol = dim[1L], byrow = TRUE) 329s + as.vector(x) 329s + } else { 329s + idxs <- idxs - 1L 329s + cols <- idxs %/% dim[2L] 329s + rows <- idxs %% dim[2L] 329s + cols + dim[1L] * rows + 1L 329s + } 329s + } 329s > 329s > 329s > dim <- c(5L, 4L) 329s > x <- matrix(NA_integer_, nrow = dim[1L], ncol = dim[2L]) 329s > y <- t(x) 329s > idxs_by_cols <- seq_along(x) 329s > 329s > # Assign by columns 329s > x[idxs_by_cols] <- idxs_by_cols 329s > print(x) 329s [,1] [,2] [,3] [,4] 329s [1,] 1 6 11 16 329s [2,] 2 7 12 17 329s [3,] 3 8 13 18 329s [4,] 4 9 14 19 329s [5,] 5 10 15 20 329s > 329s > # Truth 329s > y0 <- t(x) 329s > idxs_by_rows <- as.vector(y0) 329s > 329s > # Assert 329s > idxs <- indexByRow(dim) 329s > stopifnot(all.equal(idxs, idxs_by_rows)) 329s > y <- x 329s > y[idxs_by_rows] <- idxs 329s > print(y) 329s [,1] [,2] [,3] [,4] 329s [1,] 1 6 11 16 329s [2,] 2 7 12 17 329s [3,] 3 8 13 18 329s [4,] 4 9 14 19 329s [5,] 5 10 15 20 329s > stopifnot(all(as.vector(y) == as.vector(x))) 329s > 329s > idxs_R1 <- indexByRow_R1(dim) 329s > stopifnot(all.equal(idxs_R1, idxs_by_rows)) 329s > 329s > idxs_R2 <- indexByRow_R2(dim) 329s > stopifnot(all.equal(idxs_R2, idxs_by_rows)) 329s > 329s > # Assert 329s > idxs_by_cols <- seq(from = 1, to = length(x), by = 3L) 329s > idxs_by_rows <- as.vector(t(x)[idxs_by_cols]) 329s > 329s > idxs <- indexByRow(dim, idxs = idxs_by_cols) 329s > stopifnot(all(idxs == idxs_by_rows)) 329s > 329s > idxs_R1 <- indexByRow_R1(dim, idxs = idxs_by_cols) 329s > stopifnot(all(idxs_R1 == idxs_by_rows)) 329s > 329s > idxs_R2 <- indexByRow_R2(dim, idxs = idxs_by_cols) 329s > stopifnot(all(idxs_R2 == idxs_by_rows)) 329s > 329s > 329s > ## DEFUNCT: Backward compatibility 329s > res <- tryCatch({ 329s + idxs1 <- indexByRow(x) 329s + }, error = identity) 329s > stopifnot(inherits(res, "error")) 329s > 329s > 329s > ## Exceptions: 329s > ## Too large matrices are not supported, which happens 329s > ## when prod(dim) > .Machine$integer.max 329s > dim_too_large <- c(.Machine$integer.max, 2L) 329s > res <- tryCatch({ 329s + idxs <- indexByRow(dim_too_large, idxs = 1L) 329s + }, error = identity) 329s > stopifnot(inherits(res, "error")) 329s > 329s > ## Non-positive indices are not supported 329s > res <- tryCatch({ 329s + idxs <- indexByRow(c(1,1), idxs = 0L) 329s + }, error = identity) 329s > stopifnot(inherits(res, "error")) 329s > 329s > res <- tryCatch({ 329s + idxs <- indexByRow(c(1,1), idxs = -1L) 329s + }, error = identity) 329s > stopifnot(inherits(res, "error")) 329s > 329s 329s R version 4.4.3 (2025-02-28) -- "Trophy Case" 329s Copyright (C) 2025 The R Foundation for Statistical Computing 329s Platform: aarch64-unknown-linux-gnu 329s 329s R is free software and comes with ABSOLUTELY NO WARRANTY. 329s You are welcome to redistribute it under certain conditions. 329s Type 'license()' or 'licence()' for distribution details. 329s 329s R is a collaborative project with many contributors. 329s Type 'contributors()' for more information and 329s 'citation()' on how to cite R or R packages in publications. 329s 329s Type 'demo()' for some demos, 'help()' for on-line help, or 329s 'help.start()' for an HTML browser interface to help. 329s Type 'q()' to quit R. 329s 329s > library("matrixStats") 329s > library("stats") 329s > 329s > logSumExp_R <- function(lx, na.rm = FALSE) { 329s + log(sum(exp(lx), na.rm = na.rm)) 329s + } 329s > 329s > ## R-help thread \emph{'[R] Beyond double-precision?'} on May 9, 2009. 329s > 329s > for (mode in c("integer", "double")) { 329s + cat("mode: ", mode, "\n", sep = "") 329s + 329s + set.seed(1) 329s + x <- runif(20, min = 1.0, max = 3.0) 329s + storage.mode(x) <- mode 329s + str(x) 329s + 329s + ## The logarithm of the harmonic mean 329s + y0 <- log(1 / mean(1 / x)) 329s + print(y0) ## -1.600885 329s + 329s + lx <- log(x) 329s + y1 <- log(length(x)) - logSumExp(-lx) 329s + print(y1) ## [1] -1.600885 329s + 329s + # Sanity check 329s + stopifnot(all.equal(y1, y0)) 329s + 329s + y2 <- log(length(x)) - logSumExp_R(-lx) 329s + # Sanity check 329s + stopifnot(all.equal(y2, y0)) 329s + } # for (mode ...) 329s mode: integer 329s int [1:20] 1 1 2 2 1 2 2 2 2 1 ... 329s [1] 0.3215836 329s [1] 0.3215836 329s mode: double 329s num [1:20] 1.53 1.74 2.15 2.82 1.4 ... 329s [1] 0.6673156 329s [1] 0.6673156 329s > 329s > 329s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 329s > # Missing values 329s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 329s > ## NA values 329s > lx <- c(1, 2, 3) 329s > lx[2] <- NA_real_ 329s > y0 <- logSumExp_R(lx, na.rm = FALSE) 329s > y <- logSumExp(lx, na.rm = FALSE) 329s > print(y) 329s [1] NA 329s > stopifnot(identical(y, NA_real_)) 329s > stopifnot(all.equal(y, y0)) 329s > 329s > y0 <- logSumExp_R(lx, na.rm = TRUE) 329s > y <- logSumExp(lx, na.rm = TRUE) 329s > print(y) 329s [1] 3.126928 329s > stopifnot(all.equal(y, y0)) 329s > 329s > ## NaN values 329s > lx <- c(1, 2, 3) 329s > lx[2] <- NaN 329s > y0 <- logSumExp_R(lx, na.rm = FALSE) 329s > y <- logSumExp(lx, na.rm = FALSE) 329s > print(y) 329s [1] NA 329s > stopifnot(identical(y, NA_real_)) 329s > stopifnot(all.equal(y, y0)) 329s > 329s > y0 <- logSumExp_R(lx, na.rm = TRUE) 329s > y <- logSumExp(lx, na.rm = TRUE) 329s > print(y) 329s [1] 3.126928 329s > stopifnot(all.equal(y, y0)) 329s > 329s > 329s > 329s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 329s > # Corner cases 329s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 329s > ## Zero-length vectors 329s > lx <- numeric(0L) 329s > y0 <- logSumExp_R(lx) 329s > y <- logSumExp(lx) 329s > print(y) 329s [1] -Inf 329s > stopifnot(identical(y, -Inf)) 329s > stopifnot(all.equal(y, y0)) 329s > 329s > ## Vectors of length one 329s > lx <- 1.0 329s > y0 <- logSumExp_R(lx) 329s > y <- logSumExp(lx) 329s > print(y) 329s [1] 1 329s > stopifnot(identical(y, lx)) 329s > stopifnot(all.equal(y, y0)) 329s > 329s > lx <- NA_real_ 329s > y0 <- logSumExp_R(lx, na.rm = TRUE) 329s > y <- logSumExp(lx, na.rm = TRUE) 329s > print(y) 329s [1] -Inf 329s > stopifnot(identical(y, -Inf)) 329s > stopifnot(all.equal(y, y0)) 329s > 329s > ## All missing values 329s > lx <- c(NA_real_, NA_real_) 329s > y0 <- logSumExp_R(lx, na.rm = TRUE) 329s > y <- logSumExp(lx, na.rm = TRUE) 329s > print(y) 329s [1] -Inf 329s > stopifnot(identical(y, -Inf)) 329s > stopifnot(all.equal(y, y0)) 329s > 329s > lx <- c(NA_real_, NA_real_) 329s > y0 <- logSumExp_R(lx, na.rm = FALSE) 329s > y <- logSumExp(lx, na.rm = FALSE) 329s > print(y) 329s [1] NA 329s > stopifnot(identical(y, NA_real_)) 329s > stopifnot(all.equal(y, y0)) 329s > 329s > 329s > ## +Inf values 329s > lx <- c(1, 2, +Inf) 329s > y0 <- logSumExp_R(lx) 329s > y <- logSumExp(lx) 329s > print(y) 329s [1] Inf 329s > stopifnot(identical(y, +Inf)) 329s > stopifnot(all.equal(y, y0)) 329s > 329s > ## First element is a missing value, cf. PR #33 329s > lx <- c(NA_real_, 1) 329s > y0 <- logSumExp_R(lx) 329s > print(y0) 329s [1] NA 329s > y <- logSumExp(lx, na.rm = FALSE) 329s > print(y) 329s [1] NA 329s > stopifnot(identical(y, NA_real_)) 329s > stopifnot(all.equal(y, y0)) 329s > 329s > y0 <- logSumExp_R(lx, na.rm = TRUE) 329s > print(y0) 329s [1] 1 329s > y <- logSumExp(lx, na.rm = TRUE) 329s > print(y) 329s [1] 1 329s > stopifnot(identical(y, 1)) 329s > stopifnot(all.equal(y, y0)) 329s > 329s > ## Multiple -Inf values, cf. issue #84 329s > lx <- c(-Inf, -Inf) 329s > y0 <- logSumExp_R(lx) 329s > y <- logSumExp(lx) 329s > print(y) 329s [1] -Inf 329s > stopifnot(identical(y, -Inf)) 329s > stopifnot(all.equal(y, y0)) 329s > 329s > lx <- c(-Inf, 5, -Inf) 329s > y0 <- logSumExp_R(lx) 329s > y <- logSumExp(lx) 329s > print(y) 329s [1] 5 329s > stopifnot(identical(y, 5)) 329s > stopifnot(all.equal(y, y0)) 329s > 329s 329s R version 4.4.3 (2025-02-28) -- "Trophy Case" 329s Copyright (C) 2025 The R Foundation for Statistical Computing 329s Platform: aarch64-unknown-linux-gnu 329s 329s R is free software and comes with ABSOLUTELY NO WARRANTY. 329s You are welcome to redistribute it under certain conditions. 329s Type 'license()' or 'licence()' for distribution details. 329s 329s R is a collaborative project with many contributors. 329s Type 'contributors()' for more information and 329s 'citation()' on how to cite R or R packages in publications. 329s 329s Type 'demo()' for some demos, 'help()' for on-line help, or 329s 'help.start()' for an HTML browser interface to help. 329s Type 'q()' to quit R. 329s 329s > library("matrixStats") 329s > 329s > logSumExp_R <- function(lx, na.rm = FALSE) { 329s + log(sum(exp(lx), na.rm = na.rm)) 329s + } 329s > 329s > 329s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 329s > # Subsetted tests 329s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 329s > source("utils/validateIndicesFramework.R") 329s > x <- runif(6, min = -6, max = 6) 329s > for (idxs in index_cases) { 329s + validateIndicesTestVector(x, idxs, 329s + ftest = logSumExp, fsure = logSumExp_R, 329s + na.rm = FALSE) 329s + validateIndicesTestVector(x, idxs, 329s + ftest = logSumExp, fsure = logSumExp_R, 329s + na.rm = TRUE) 329s + } 329s > 329s 329s R version 4.4.3 (2025-02-28) -- "Trophy Case" 329s Copyright (C) 2025 The R Foundation for Statistical Computing 329s Platform: aarch64-unknown-linux-gnu 329s 329s R is free software and comes with ABSOLUTELY NO WARRANTY. 329s You are welcome to redistribute it under certain conditions. 329s Type 'license()' or 'licence()' for distribution details. 329s 329s R is a collaborative project with many contributors. 329s Type 'contributors()' for more information and 329s 'citation()' on how to cite R or R packages in publications. 329s 329s Type 'demo()' for some demos, 'help()' for on-line help, or 329s 'help.start()' for an HTML browser interface to help. 329s Type 'q()' to quit R. 329s 329s > library("matrixStats") 329s > 329s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 329s > # Consistency checks 329s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 329s > set.seed(1) 329s > 329s > mean2_R <- function(x, na.rm = FALSE, idxs = NULL) { 329s + if (is.null(idxs)) { 329s + mean(x, na.rm = na.rm) 329s + } else { 329s + mean(x[idxs], na.rm = na.rm) 329s + } 329s + } # mean2_R() 329s > 329s > 329s > cat("Consistency checks:\n") 329s Consistency checks: 329s > for (kk in 1:20) { 329s + cat("Random test #", kk, "\n", sep = "") 329s + 329s + # Simulate data in a matrix of any shape 329s + n <- sample(100L, size = 1L) 329s + x <- rnorm(n, sd = 100) 329s + 329s + # Add NAs? 329s + if ((kk %% 4) %in% c(3, 0)) { 329s + cat("Adding NAs\n") 329s + nna <- sample(n, size = 1L) 329s + na_values <- c(NA_real_, NaN) 329s + t <- sample(na_values, size = nna, replace = TRUE) 329s + x[sample(length(x), size = nna)] <- t 329s + } 329s + 329s + # Integer or double? 329s + if ((kk %% 4) %in% c(2, 0)) { 329s + cat("Coercing to integers\n") 329s + storage.mode(x) <- "integer" 329s + } 329s + 329s + na.rm <- sample(c(TRUE, FALSE), size = 1L) 329s + 329s + # Sum over all 329s + y0 <- mean2_R(x, na.rm = na.rm) 329s + y1 <- mean2(x, na.rm = na.rm) 329s + stopifnot(all.equal(y1, y0)) 329s + 329s + # Sum over subset 329s + nidxs <- sample(n, size = 1L) 329s + idxs <- sample(n, size = nidxs) 329s + y0 <- mean2_R(x, na.rm = na.rm, idxs = idxs) 329s + y1 <- mean2(x, na.rm = na.rm, idxs = idxs) 329s + stopifnot(all.equal(y1, y0)) 329s + 329s + if (storage.mode(x) == "integer") { 329s + storage.mode(x) <- "logical" 329s + 329s + y0 <- mean2_R(x, na.rm = na.rm) 329s + y1 <- mean2(x, na.rm = na.rm) 329s + stopifnot(all.equal(y1, y0)) 329s + 329s + y0 <- mean2_R(x, na.rm = na.rm, idxs = idxs) 329s + y1 <- mean2(x, na.rm = na.rm, idxs = idxs) 329s + stopifnot(all.equal(y1, y0)) 329s + } 329s + } # for (kk ...) 330s Random test #1 330s Random test #2 330s Coercing to integers 330s Random test #3 330s Adding NAs 330s Random test #4 330s Adding NAs 330s Coercing to integers 330s Random test #5 330s Random test #6 330s Coercing to integers 330s Random test #7 330s Adding NAs 330s Random test #8 330s Adding NAs 330s Coercing to integers 330s Random test #9 330s Random test #10 330s Coercing to integers 330s Random test #11 330s Adding NAs 330s Random test #12 330s Adding NAs 330s Coercing to integers 330s Random test #13 330s Random test #14 330s Coercing to integers 330s Random test #15 330s Adding NAs 330s Random test #16 330s Adding NAs 330s Coercing to integers 330s Random test #17 330s Random test #18 330s Coercing to integers 330s Random test #19 330s Adding NAs 330s Random test #20 330s Adding NAs 330s Coercing to integers 330s > 330s > 330s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 330s > # Special cases 330s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 330s > for (na.rm in c(FALSE, TRUE)) { 330s + # Averaging over zero elements (integers) 330s + x <- integer(0) 330s + s1 <- mean(x, na.rm = na.rm) 330s + s2 <- mean2(x, na.rm = na.rm) 330s + stopifnot(identical(s1, s2)) 330s + 330s + x <- 1:5 330s + idxs <- integer(0) 330s + s1 <- mean(x[idxs], na.rm = na.rm) 330s + s2 <- mean2(x, idxs = idxs, na.rm = na.rm) 330s + stopifnot(identical(s1, s2)) 330s + 330s + # Averaging over NA_integer_:s 330s + x <- rep(NA_integer_, times = 5L) 330s + s1 <- mean(x, na.rm = na.rm) 330s + s2 <- mean2(x, na.rm = na.rm) 330s + stopifnot(identical(s1, s2)) 330s + 330s + x <- rep(NA_integer_, times = 5L) 330s + idxs <- 1:3 330s + s1 <- mean(x[idxs], na.rm = na.rm) 330s + s2 <- mean2(x, idxs = idxs, na.rm = na.rm) 330s + stopifnot(identical(s1, s2)) 330s + 330s + 330s + # Averaging over zero elements (doubles) 330s + x <- double(0) 330s + s1 <- mean(x) 330s + s2 <- mean2(x) 330s + stopifnot(identical(s1, s2)) 330s + 330s + x <- as.double(1:10) 330s + idxs <- integer(0) 330s + s1 <- mean(x[idxs]) 330s + s2 <- mean2(x, idxs = idxs) 330s + stopifnot(identical(s1, s2)) 330s + 330s + # Averaging over NA_real_:s 330s + x <- rep(NA_real_, times = 5L) 330s + s1 <- mean(x, na.rm = na.rm) 330s + s2 <- mean2(x, na.rm = na.rm) 330s + stopifnot(identical(s1, s2)) 330s + 330s + x <- rep(NA_real_, times = 5L) 330s + idxs <- 1:3 330s + s1 <- mean(x[idxs], na.rm = na.rm) 330s + s2 <- mean2(x, idxs = idxs, na.rm = na.rm) 330s + stopifnot(identical(s1, s2)) 330s + 330s + # Averaging over -Inf:s 330s + x <- rep(-Inf, times = 3L) 330s + s1 <- mean(x, na.rm = na.rm) 330s + s2 <- mean2(x, na.rm = na.rm) 330s + stopifnot(identical(s1, s2)) 330s + 330s + # Averaging over +Inf:s 330s + x <- rep(+Inf, times = 3L) 330s + s1 <- mean(x, na.rm = na.rm) 330s + s2 <- mean2(x, na.rm = na.rm) 330s + stopifnot(identical(s1, s2)) 330s + 330s + # Averaging over mix of -Inf:s and +Inf:s 330s + x <- rep(c(-Inf, +Inf), times = 3L) 330s + s1 <- mean(x, na.rm = na.rm) 330s + s2 <- mean2(x, na.rm = na.rm) 330s + stopifnot(identical(s1, s2)) 330s + 330s + # Averaging over mix of -Inf:s and +Inf:s and numerics 330s + x <- rep(c(-Inf, +Inf, 3.14), times = 2L) 330s + s1 <- mean(x, na.rm = na.rm) 330s + s2 <- mean2(x, na.rm = na.rm) 330s + stopifnot(identical(s1, s2)) 330s + 330s + # Averaging over mix of NaN, NA, +Inf, and numerics 330s + x <- c(NaN, NA, +Inf, 3.14) 330s + s1 <- mean(x, na.rm = na.rm) 330s + s2 <- mean2(x, na.rm = na.rm) 330s + if (na.rm) { 330s + stopifnot(identical(s2, s1)) 330s + } else { 330s + stopifnot(is.na(s1), is.na(s2)) 330s + ## NOTE, due to compiler optimization, it is not guaranteed that NA is 330s + ## returned here (as one would expect). NaN might very well be returned, 330s + ## when both NA and NaN are involved. This is an accepted feature in R, 330s + ## which is documented in help("is.nan"). See also 330s + ## https://stat.ethz.ch/pipermail/r-devel/2017-April/074009.html. 330s + ## Thus, we cannot guarantee that s1 is identical to s0. 330s + } 330s + 330s + # Averaging over mix of NaN, NA_real_, +Inf, and numerics 330s + x <- c(NA_real_, NaN, +Inf, 3.14) 330s + s1 <- mean(x, na.rm = na.rm) 330s + s2 <- mean2(x, na.rm = na.rm) 330s + if (na.rm) { 330s + stopifnot(identical(s2, s1)) 330s + } else { 330s + stopifnot(is.na(s1), is.na(s2)) 330s + ## NOTE, due to compiler optimization, it is not guaranteed that NA is 330s + ## returned here (as one would expect). NaN might very well be returned, 330s + ## when both NA and NaN are involved. This is an accepted feature in R, 330s + ## which is documented in help("is.nan"). See also 330s + ## https://stat.ethz.ch/pipermail/r-devel/2017-April/074009.html. 330s + ## Thus, we cannot guarantee that s1 is identical to s0. 330s + } 330s + } 330s > 330s > 330s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 330s > # Argument 'idxs' 330s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 330s > x <- 1:5 330s > idxs_list <- list( 330s + integer = 1:3, 330s + double = as.double(1:3), 330s + logical = (x <= 3) 330s + ) 330s > 330s > for (idxs in idxs_list) { 330s + cat("idxs:\n") 330s + str(idxs) 330s + s1 <- mean(x[idxs], na.rm = TRUE) 330s + s2 <- mean2(x, idxs = idxs, na.rm = TRUE) 330s + stopifnot(identical(s1, s2)) 330s + } 330s idxs: 330s int [1:3] 1 2 3 330s idxs: 330s num [1:3] 1 2 3 330s idxs: 330s logi [1:5] TRUE TRUE TRUE FALSE FALSE 330s > 330s 330s R version 4.4.3 (2025-02-28) -- "Trophy Case" 330s Copyright (C) 2025 The R Foundation for Statistical Computing 330s Platform: aarch64-unknown-linux-gnu 330s 330s R is free software and comes with ABSOLUTELY NO WARRANTY. 330s You are welcome to redistribute it under certain conditions. 330s Type 'license()' or 'licence()' for distribution details. 330s 330s R is a collaborative project with many contributors. 330s Type 'contributors()' for more information and 330s 'citation()' on how to cite R or R packages in publications. 330s 330s Type 'demo()' for some demos, 'help()' for on-line help, or 330s 'help.start()' for an HTML browser interface to help. 330s Type 'q()' to quit R. 330s 330s > library("matrixStats") 330s > 330s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 330s > # Subsetted tests 330s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 330s > source("utils/validateIndicesFramework.R") 330s > x <- runif(6, min = -6, max = 6) 330s > storage.mode(x) <- "integer" 330s > for (idxs in index_cases) { 330s + validateIndicesTestVector(x, idxs, 330s + ftest = mean2, fsure = mean, 330s + na.rm = FALSE) 330s + validateIndicesTestVector(x, idxs, 330s + ftest = mean2, fsure = mean, 330s + na.rm = TRUE) 330s + } 330s > 330s 330s R version 4.4.3 (2025-02-28) -- "Trophy Case" 330s Copyright (C) 2025 The R Foundation for Statistical Computing 330s Platform: aarch64-unknown-linux-gnu 330s 330s R is free software and comes with ABSOLUTELY NO WARRANTY. 330s You are welcome to redistribute it under certain conditions. 330s Type 'license()' or 'licence()' for distribution details. 330s 330s R is a collaborative project with many contributors. 330s Type 'contributors()' for more information and 330s 'citation()' on how to cite R or R packages in publications. 330s 330s Type 'demo()' for some demos, 'help()' for on-line help, or 330s 'help.start()' for an HTML browser interface to help. 330s Type 'q()' to quit R. 330s 330s > library("matrixStats") 330s > 330s > for (mode in c("integer", "double")) { 330s + cat("mode: ", mode, "\n", sep = "") 330s + 330s + # Empty vector 330s + x <- 0 330s + storage.mode(x) <- mode 330s + y <- prod(x, na.rm = TRUE) 330s + print(y) 330s + z <- product(x, na.rm = TRUE) 330s + print(z) 330s + stopifnot(all.equal(z, y)) 330s + 330s + # Test negative values 330s + x <- c(1, -4, 2) 330s + storage.mode(x) <- mode 330s + y <- prod(x, na.rm = TRUE) 330s + print(y) 330s + z <- product(x, na.rm = TRUE) 330s + print(z) 330s + stopifnot(all.equal(z, y)) 330s + 330s + # Test missing values 330s + x <- c(1, NA, NaN, 2) 330s + storage.mode(x) <- mode 330s + y <- prod(x, na.rm = TRUE) 330s + print(y) 330s + z <- product(x, na.rm = TRUE) 330s + print(z) 330s + stopifnot(all.equal(z, y)) 330s + 330s + x <- c(1, NA, NaN, 2) 330s + storage.mode(x) <- mode 330s + y <- prod(x, na.rm = FALSE) 330s + print(y) 330s + z <- product(x, na.rm = FALSE) 330s + print(z) 330s + stopifnot(all(is.na(z), is.na(y))) 330s + 330s + x <- c(1, NaN, 2) 330s + storage.mode(x) <- mode 330s + y <- prod(x, na.rm = FALSE) 330s + print(y) 330s + stopifnot(is.na(y)) 330s + z <- product(x, na.rm = FALSE) 330s + print(z) 330s + stopifnot(is.na(z)) 330s + 330s + } # for (mode ...) 330s mode: integer 330s [1] 0 330s [1] 0 330s [1] -8 330s [1] -8 330s [1] 2 330s [1] 2 330s [1] NA 330s [1] NA 330s [1] NA 330s [1] NA 330s mode: double 330s [1] 0 330s [1] 0 330s [1] -8 330s [1] -8 330s [1] 2 330s [1] 2 330s [1] NA 330s [1] NA 330s [1] NaN 330s [1] NA 330s > 330s > 330s > # NAs following 0s 330s > x <- c(0L, NA_integer_) 330s > y <- prod(x, na.rm = FALSE) 330s > print(y) 330s [1] NA 330s > z <- product(x, na.rm = FALSE) 330s > print(z) 330s [1] NA 330s > stopifnot(identical(z, y)) 330s > 330s 330s R version 4.4.3 (2025-02-28) -- "Trophy Case" 330s Copyright (C) 2025 The R Foundation for Statistical Computing 330s Platform: aarch64-unknown-linux-gnu 330s 330s R is free software and comes with ABSOLUTELY NO WARRANTY. 330s You are welcome to redistribute it under certain conditions. 330s Type 'license()' or 'licence()' for distribution details. 330s 330s R is a collaborative project with many contributors. 330s Type 'contributors()' for more information and 330s 'citation()' on how to cite R or R packages in publications. 330s 330s Type 'demo()' for some demos, 'help()' for on-line help, or 330s 'help.start()' for an HTML browser interface to help. 330s Type 'q()' to quit R. 330s 330s > library("matrixStats") 330s > 330s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 330s > # Subsetted tests 330s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 330s > source("utils/validateIndicesFramework.R") 330s > x <- runif(6, min = -6, max = 6) 330s > storage.mode(x) <- "integer" 330s > for (idxs in index_cases) { 330s + validateIndicesTestVector(x, idxs, 330s + ftest = product, fsure = prod, 330s + na.rm = TRUE) 330s + validateIndicesTestVector(x, idxs, 330s + ftest = product, fsure = prod, 330s + na.rm = FALSE) 330s + } 331s > 331s 331s R version 4.4.3 (2025-02-28) -- "Trophy Case" 331s Copyright (C) 2025 The R Foundation for Statistical Computing 331s Platform: aarch64-unknown-linux-gnu 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 > library("utils") ## utils::str 331s > 331s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 331s > # Local functions 331s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 331s > psortKM_R <- function(x, k, m) { 331s + x <- sort(x) 331s + x[(k - m + 1):k] 331s + } 331s > 331s > psortKM_R2 <- function(x, k, m) { 331s + partial <- (k - m + 1):k 331s + x <- sort.int(x, partial = partial) 331s + x[partial] 331s + } 331s > 331s > 331s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 331s > # Consistency checks 331s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 331s > set.seed(1) 331s > 331s > cat("Consistency checks:\n") 331s Consistency checks: 331s > x <- 1:30 331s > x[18:20] <- 20 331s > y <- sample(x) 331s > cat("x:\n") 331s x: 331s > str(x) 331s num [1:30] 1 2 3 4 5 6 7 8 9 10 ... 331s > cat("sample(x):\n") 331s sample(x): 331s > str(y) 331s num [1:30] 25 4 7 1 2 23 11 14 20 20 ... 331s > 331s > for (k in c(1L, 2L, 20L, 21L, length(x))) { 331s + for (m in 1:min(5L, k)) { 331s + px0 <- psortKM_R(x, k = k, m = m) 331s + px0b <- psortKM_R2(x, k = k, m = m) 331s + stopifnot(identical(px0b, px0)) 331s + px1 <- matrixStats:::.psortKM(x, k = k, m = m) 331s + cat(sprintf(".psortKM(x, k = %d, m = %d):\n", k, m)) 331s + print(px1) 331s + stopifnot(identical(px1, px0)) 331s + 331s + py0 <- psortKM_R(y, k = k, m = m) 331s + py0b <- psortKM_R2(y, k = k, m = m) 331s + stopifnot(identical(py0b, py0)) 331s + py1 <- matrixStats:::.psortKM(y, k = k, m = m) 331s + cat(sprintf(".psortKM(y, k = %d, m = %d):\n", k, m)) 331s + print(py1) 331s + stopifnot(identical(py1, py0)) 331s + stopifnot(identical(py1, px1)) 331s + } # for (m ...) 331s + } # for (k ...) 331s .psortKM(x, k = 1, m = 1): 331s [1] 1 331s .psortKM(y, k = 1, m = 1): 331s [1] 1 331s .psortKM(x, k = 2, m = 1): 331s [1] 2 331s .psortKM(y, k = 2, m = 1): 331s [1] 2 331s .psortKM(x, k = 2, m = 2): 331s [1] 1 2 331s .psortKM(y, k = 2, m = 2): 331s [1] 1 2 331s .psortKM(x, k = 20, m = 1): 331s [1] 20 331s .psortKM(y, k = 20, m = 1): 331s [1] 20 331s .psortKM(x, k = 20, m = 2): 331s [1] 20 20 331s .psortKM(y, k = 20, m = 2): 331s [1] 20 20 331s .psortKM(x, k = 20, m = 3): 331s [1] 20 20 20 331s .psortKM(y, k = 20, m = 3): 331s [1] 20 20 20 331s .psortKM(x, k = 20, m = 4): 331s [1] 17 20 20 20 331s .psortKM(y, k = 20, m = 4): 331s [1] 17 20 20 20 331s .psortKM(x, k = 20, m = 5): 331s [1] 16 17 20 20 20 331s .psortKM(y, k = 20, m = 5): 331s [1] 16 17 20 20 20 331s .psortKM(x, k = 21, m = 1): 331s [1] 21 331s .psortKM(y, k = 21, m = 1): 331s [1] 21 331s .psortKM(x, k = 21, m = 2): 331s [1] 20 21 331s .psortKM(y, k = 21, m = 2): 331s [1] 20 21 331s .psortKM(x, k = 21, m = 3): 331s [1] 20 20 21 331s .psortKM(y, k = 21, m = 3): 331s [1] 20 20 21 331s .psortKM(x, k = 21, m = 4): 331s [1] 20 20 20 21 331s .psortKM(y, k = 21, m = 4): 331s [1] 20 20 20 21 331s .psortKM(x, k = 21, m = 5): 331s [1] 17 20 20 20 21 331s .psortKM(y, k = 21, m = 5): 331s [1] 17 20 20 20 21 331s .psortKM(x, k = 30, m = 1): 331s [1] 30 331s .psortKM(y, k = 30, m = 1): 331s [1] 30 331s .psortKM(x, k = 30, m = 2): 331s [1] 29 30 331s .psortKM(y, k = 30, m = 2): 331s [1] 29 30 331s .psortKM(x, k = 30, m = 3): 331s [1] 28 29 30 331s .psortKM(y, k = 30, m = 3): 331s [1] 28 29 30 331s .psortKM(x, k = 30, m = 4): 331s [1] 27 28 29 30 331s .psortKM(y, k = 30, m = 4): 331s [1] 27 28 29 30 331s .psortKM(x, k = 30, m = 5): 331s [1] 26 27 28 29 30 331s .psortKM(y, k = 30, m = 5): 331s [1] 26 27 28 29 30 331s > 331s 331s R version 4.4.3 (2025-02-28) -- "Trophy Case" 331s Copyright (C) 2025 The R Foundation for Statistical Computing 331s Platform: aarch64-unknown-linux-gnu 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 > rowAlls_R <- function(x, value = TRUE, na.rm = FALSE, ..., useNames = TRUE) { 331s + if (is.na(value)) { 331s + res <- apply(is.na(x), MARGIN = 1L, FUN = all, na.rm = na.rm) 331s + } else { 331s + y <- x == value 331s + 331s + # Preserve dimnames attribute 331s + dim <- dim(x) # for 0xN and Mx0 cases; needed in R (< 3.4.0) 331s + if (!isTRUE(all.equal(dim(y), dim))) { 331s + dim(y) <- dim 331s + dimnames(y) <- dimnames(x) 331s + } 331s + 331s + res <- apply(y, MARGIN = 1L, FUN = all, na.rm = na.rm) 331s + } 331s + if (!useNames) names(res) <- NULL 331s + res 331s + } 331s > 331s > rowAnys_R <- function(x, value = TRUE, na.rm = FALSE, ..., useNames = TRUE) { 331s + if (is.na(value)) { 331s + res <- apply(is.na(x), MARGIN = 1L, FUN = any, na.rm = na.rm) 331s + } else { 331s + y <- x == value 331s + 331s + # Preserve dimnames attribute 331s + dim <- dim(x) # for 0xN and Mx0 cases; needed in R (< 3.4.0) 331s + if (!isTRUE(all.equal(dim(y), dim))) { 331s + dim(y) <- dim 331s + dimnames(y) <- dimnames(x) 331s + } 331s + 331s + res <- apply(y, MARGIN = 1L, FUN = any, na.rm = na.rm) 331s + } 331s + if (!useNames) names(res) <- NULL 331s + res 331s + } 331s > 331s > rowAnyMissings_R <- function(x, ..., useNames = TRUE) { 331s + res <- apply(x, MARGIN = 1L, FUN = anyMissing) 331s + if (!useNames) names(res) <- NULL 331s + res 331s + } 331s > 331s > 331s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 331s > # Data type: logical 331s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 331s > x <- matrix(FALSE, nrow = 10L, ncol = 4L) 331s > x[7:8, 2:3] <- TRUE 331s > x[1:3, ] <- TRUE 331s > x[, 1] <- TRUE 331s > x[4, ] <- FALSE 331s > x[, 4] <- FALSE 331s > x[2, ] <- FALSE 331s > x[3, ] <- TRUE 331s > 331s > # To check names attribute 331s > dimnames <- list(letters[1:10], LETTERS[1:4]) 331s > 331s > for (kk in 1:3) { 331s + if (kk == 2) { 331s + x[2, 2] <- NA 331s + } else if (kk == 3) { 331s + x[, 2] <- NA 331s + x[2, ] <- NA 331s + } 331s + 331s + # Test with and without dimnames on x 331s + for (setDimnames in c(TRUE, FALSE)) { 331s + dimnames(x) <- if (setDimnames) dimnames else NULL 331s + 331s + for (na.rm in c(FALSE, TRUE)) { 331s + # Check names attribute 331s + for (useNames in c(TRUE, FALSE)) { 331s + m0 <- rowAlls_R(x, na.rm = na.rm, useNames = useNames) 331s + m1 <- rowAlls(x, na.rm = na.rm, useNames = useNames) 331s + m2 <- colAlls(t(x), na.rm = na.rm, useNames = useNames) 331s + str(list("all()", m0 = m0, m1 = m1, m2 = m2)) 331s + stopifnot(identical(m1, m0)) 331s + stopifnot(identical(m2, m0)) 331s + 331s + m0 <- rowAnys_R(x, na.rm = na.rm, useNames = useNames) 331s + m1 <- rowAnys(x, na.rm = na.rm, useNames = useNames) 331s + m2 <- colAnys(t(x), na.rm = na.rm, useNames = useNames) 331s + str(list("any()", m0 = m0, m1 = m1, m2 = m2)) 331s + stopifnot(identical(m1, m0)) 331s + stopifnot(identical(m2, m0)) 331s + 331s + m0 <- rowAnyMissings_R(x, useNames = useNames) 331s + m1 <- rowAnyMissings(x, useNames = useNames) 331s + m2 <- colAnyMissings(t(x), useNames = useNames) 331s + str(list("anyMissing()", m0 = m0, m1 = m1, m2 = m2)) 331s + stopifnot(identical(m1, m0)) 331s + stopifnot(identical(m2, m0)) 331s + } 331s + } 331s + } 331s + } # for (kk ...) 331s List of 4 331s $ : chr "all()" 331s $ m0: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 331s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 331s $ m1: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 331s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 331s $ m2: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 331s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 331s List of 4 331s $ : chr "any()" 331s $ m0: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 331s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 331s $ m1: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 331s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 331s $ m2: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 331s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 331s List of 4 331s $ : chr "anyMissing()" 331s $ m0: Named logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 331s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 331s $ m1: Named logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 331s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 331s $ m2: Named logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 331s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 331s List of 4 331s $ : chr "all()" 331s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 331s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 331s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 331s List of 4 331s $ : chr "any()" 331s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 331s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 331s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 331s List of 4 331s $ : chr "anyMissing()" 331s $ m0: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 331s $ m1: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 331s $ m2: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 331s List of 4 331s $ : chr "all()" 331s $ m0: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 331s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 331s $ m1: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 331s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 331s $ m2: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 331s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 331s List of 4 331s $ : chr "any()" 331s $ m0: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 331s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 331s $ m1: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 331s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 331s $ m2: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 331s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 331s List of 4 331s $ : chr "anyMissing()" 331s $ m0: Named logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 331s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 331s $ m1: Named logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 331s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 331s $ m2: Named logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 331s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 331s List of 4 331s $ : chr "all()" 331s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 331s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 331s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 331s List of 4 331s $ : chr "any()" 331s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 331s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 331s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 331s List of 4 331s $ : chr "anyMissing()" 331s $ m0: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 331s $ m1: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 331s $ m2: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 331s List of 4 331s $ : chr "all()" 331s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 331s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 331s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 331s List of 4 331s $ : chr "any()" 331s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 331s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 331s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 331s List of 4 331s $ : chr "anyMissing()" 331s $ m0: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 331s $ m1: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 331s $ m2: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 331s List of 4 331s $ : chr "all()" 331s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 331s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 331s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 331s List of 4 331s $ : chr "any()" 331s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 331s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 331s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 331s List of 4 331s $ : chr "anyMissing()" 331s $ m0: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 331s $ m1: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 331s $ m2: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 331s List of 4 331s $ : chr "all()" 331s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 331s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 331s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 331s List of 4 331s $ : chr "any()" 331s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 331s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 331s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 331s List of 4 331s $ : chr "anyMissing()" 331s $ m0: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 331s $ m1: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 331s $ m2: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 331s List of 4 331s $ : chr "all()" 331s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 331s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 331s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 331s List of 4 331s $ : chr "any()" 331s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 331s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 331s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 331s List of 4 331s $ : chr "anyMissing()" 331s $ m0: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 331s $ m1: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 331s $ m2: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 331s List of 4 331s $ : chr "all()" 331s $ m0: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 331s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 331s $ m1: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 331s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 331s $ m2: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 331s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 331s List of 4 331s $ : chr "any()" 331s $ m0: Named logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 331s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 331s $ m1: Named logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 331s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 331s $ m2: Named logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 331s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 331s List of 4 331s $ : chr "anyMissing()" 331s $ m0: Named logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 331s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 331s $ m1: Named logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 331s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 331s $ m2: Named logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 331s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 331s List of 4 331s $ : chr "all()" 331s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 331s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 331s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 331s List of 4 331s $ : chr "any()" 331s $ m0: logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 331s $ m1: logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 331s $ m2: logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 331s List of 4 331s $ : chr "anyMissing()" 331s $ m0: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 331s $ m1: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 331s $ m2: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 331s List of 4 331s $ : chr "all()" 331s $ m0: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 331s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 331s $ m1: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 331s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 331s $ m2: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 331s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 331s List of 4 331s $ : chr "any()" 331s $ m0: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 331s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 331s $ m1: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 331s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 331s $ m2: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 331s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 331s List of 4 331s $ : chr "anyMissing()" 331s $ m0: Named logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 331s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 331s $ m1: Named logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 331s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 331s $ m2: Named logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 331s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 331s List of 4 331s $ : chr "all()" 331s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 331s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 331s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 331s List of 4 331s $ : chr "any()" 331s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 331s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 331s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 331s List of 4 331s $ : chr "anyMissing()" 331s $ m0: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 331s $ m1: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 331s $ m2: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 331s List of 4 331s $ : chr "all()" 331s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 331s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 331s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 331s List of 4 331s $ : chr "any()" 331s $ m0: logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 331s $ m1: logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 331s $ m2: logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 331s List of 4 331s $ : chr "anyMissing()" 331s $ m0: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 331s $ m1: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 331s $ m2: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 331s List of 4 331s $ : chr "all()" 331s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 331s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 331s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 331s List of 4 331s $ : chr "any()" 331s $ m0: logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 331s $ m1: logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 331s $ m2: logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 331s List of 4 331s $ : chr "anyMissing()" 331s $ m0: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 331s $ m1: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 331s $ m2: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 331s List of 4 331s $ : chr "all()" 331s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 331s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 331s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 331s List of 4 331s $ : chr "any()" 331s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 331s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 331s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 331s List of 4 331s $ : chr "anyMissing()" 331s $ m0: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 331s $ m1: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 331s $ m2: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 331s List of 4 331s $ : chr "all()" 331s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 331s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 331s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 331s List of 4 331s $ : chr "any()" 331s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 331s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 331s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 331s List of 4 331s $ : chr "anyMissing()" 331s $ m0: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 331s $ m1: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 331s $ m2: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 331s List of 4 331s $ : chr "all()" 331s $ m0: Named logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 331s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 331s $ m1: Named logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 331s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 331s $ m2: Named logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 331s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 331s List of 4 331s $ : chr "any()" 331s $ m0: Named logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 331s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 331s $ m1: Named logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 331s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 331s $ m2: Named logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 331s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 331s List of 4 331s $ : chr "anyMissing()" 331s $ m0: Named logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 331s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 331s $ m1: Named logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 331s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 331s $ m2: Named logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 331s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 331s List of 4 331s $ : chr "all()" 331s $ m0: logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 331s $ m1: logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 331s $ m2: logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 331s List of 4 331s $ : chr "any()" 331s $ m0: logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 331s $ m1: logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 331s $ m2: logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 331s List of 4 331s $ : chr "anyMissing()" 331s $ m0: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 331s $ m1: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 331s $ m2: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 331s List of 4 331s $ : chr "all()" 331s $ m0: Named logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 331s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 331s $ m1: Named logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 331s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 331s $ m2: Named logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 331s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 331s List of 4 331s $ : chr "any()" 331s $ m0: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 331s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 331s $ m1: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 331s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 331s $ m2: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 331s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 331s List of 4 331s $ : chr "anyMissing()" 331s $ m0: Named logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 331s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 331s $ m1: Named logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 331s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 331s $ m2: Named logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 331s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 331s List of 4 331s $ : chr "all()" 331s $ m0: logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 331s $ m1: logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 331s $ m2: logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 331s List of 4 331s $ : chr "any()" 331s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 331s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 331s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 331s List of 4 331s $ : chr "anyMissing()" 331s $ m0: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 331s $ m1: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 331s $ m2: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 331s List of 4 331s $ : chr "all()" 331s $ m0: logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 331s $ m1: logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 331s $ m2: logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 331s List of 4 331s $ : chr "any()" 331s $ m0: logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 331s $ m1: logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 331s $ m2: logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 331s List of 4 331s $ : chr "anyMissing()" 331s $ m0: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 331s $ m1: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 331s $ m2: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 331s List of 4 331s $ : chr "all()" 331s $ m0: logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 331s $ m1: logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 331s $ m2: logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 331s List of 4 331s $ : chr "any()" 331s $ m0: logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 331s $ m1: logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 331s $ m2: logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 331s List of 4 331s $ : chr "anyMissing()" 331s $ m0: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 331s $ m1: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 331s $ m2: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 331s List of 4 331s $ : chr "all()" 331s $ m0: logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 331s $ m1: logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 331s $ m2: logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 331s List of 4 331s $ : chr "any()" 331s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 331s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 331s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 331s List of 4 331s $ : chr "anyMissing()" 331s $ m0: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 331s $ m1: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 331s $ m2: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 331s List of 4 331s $ : chr "all()" 331s $ m0: logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 331s $ m1: logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 331s $ m2: logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 331s List of 4 331s $ : chr "any()" 331s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 331s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 331s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 331s List of 4 331s $ : chr "anyMissing()" 331s $ m0: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 331s $ m1: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 331s $ m2: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 331s > 331s > 331s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 331s > # Data type: integer 331s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 331s > x <- matrix(rep(1:6, length.out = 4 * 5), nrow = 4L, ncol = 5L) 331s > x[2, ] <- 7L 331s > x[3, 1] <- 7L 331s > x[2:3, 3:4] <- NA_integer_ 331s > 331s > # To check names attribute 331s > dimnames <- list(letters[1:4], LETTERS[1:5]) 331s > 331s > # Row/column counts 331s > value <- 7L 331s > 331s > # Test with and without dimnames on x 331s > for (setDimnames in c(TRUE, FALSE)) { 331s + dimnames(x) <- if (setDimnames) dimnames else NULL 331s + for (na.rm in c(FALSE, TRUE)) { 331s + # Check names attribute 331s + for (useNames in c(TRUE, FALSE)) { 331s + r0 <- rowAlls_R(x, value = value, na.rm = na.rm, useNames = useNames) 331s + r1 <- rowAlls(x, value = value, na.rm = na.rm, useNames = useNames) 331s + r2 <- colAlls(t(x), value = value, na.rm = na.rm, useNames = useNames) 331s + stopifnot(identical(r1, r0)) 331s + stopifnot(identical(r2, r1)) 331s + if (!useNames && !setDimnames) { 331s + for (rr in seq_len(nrow(x))) { 331s + c <- allValue(x[rr, ], value = value, na.rm = na.rm) 331s + stopifnot(identical(c, r1[rr])) 331s + c <- allValue(x[rr, ], value = value, na.rm = na.rm) 331s + stopifnot(identical(c, r1[rr])) 331s + } 331s + } 331s + 331s + r0 <- rowAnys_R(x, value = value, na.rm = na.rm, useNames = useNames) 331s + r1 <- rowAnys(x, value = value, na.rm = na.rm, useNames = useNames) 331s + r2 <- colAnys(t(x), value = value, na.rm = na.rm, useNames = useNames) 331s + stopifnot(identical(r1, r0)) 331s + stopifnot(identical(r2, r1)) 331s + if (!useNames && !setDimnames) { 331s + for (rr in seq_len(nrow(x))) { 331s + c <- anyValue(x[rr, ], value = value, na.rm = na.rm) 331s + stopifnot(identical(c, r1[rr])) 331s + c <- anyValue(x[rr, ], value = value, na.rm = na.rm) 331s + stopifnot(identical(c, r1[rr])) 331s + } 331s + } 331s + } 331s + } 331s + } 331s > 331s > 331s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 331s > # rowAlls(x) et al. on numeric 'x' with logical 'value' 331s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 331s > x <- matrix(0, nrow = 4L, ncol = 5L) 331s > x[2:4, 2] <- (1:3) / 4 331s > x[2, 2:4] <- (1:3) / 4 331s > x[3:4, 3] <- (3:4) / 4 331s > x[3, 3:4] <- (3:4) / 4 331s > x[1:4, 5] <- (1:4) / 5 331s > x[4, 4] <- NA_real_ 331s > 331s > # To check names attribute 331s > dimnames <- list(letters[1:4], LETTERS[1:5]) 331s > 331s > for (value in c(TRUE, FALSE)) { 331s + for (na.rm in c(FALSE, TRUE)) { 331s + y0 <- suppressWarnings(apply(x, MARGIN = 1L, FUN = function(e) any(as.logical(e) == value, na.rm = na.rm))) 331s + y <- rowAnys(x, na.rm = na.rm, value = value) 331s + stopifnot(identical(y, y0)) 331s + # Check names attribute 331s + dimnames(x) <- dimnames 331s + y <- rowAnys(x, na.rm = na.rm, value = value, useNames = FALSE) 331s + stopifnot(all.equal(y, y0)) 331s + y0 <- suppressWarnings(apply(x, MARGIN = 1L, FUN = function(e) any(as.logical(e) == value, na.rm = na.rm))) 331s + y <- rowAnys(x, na.rm = na.rm, value = value, useNames = TRUE) 331s + stopifnot(all.equal(y, y0)) 331s + dimnames(x) <- NULL 331s + 331s + y0 <- suppressWarnings(apply(x, MARGIN = 2L, FUN = function(e) any(as.logical(e) == value, na.rm = na.rm))) 331s + y <- colAnys(x, na.rm = na.rm, value = value) 331s + stopifnot(identical(y, y0)) 331s + # Check names attribute 331s + dimnames(x) <- dimnames 331s + y <- colAnys(x, na.rm = na.rm, value = value, useNames = FALSE) 331s + stopifnot(all.equal(y, y0)) 331s + y0 <- suppressWarnings(apply(x, MARGIN = 2L, FUN = function(e) any(as.logical(e) == value, na.rm = na.rm))) 331s + y <- colAnys(x, na.rm = na.rm, value = value, useNames = TRUE) 331s + stopifnot(all.equal(y, y0)) 331s + dimnames(x) <- NULL 331s + 331s + y0 <- suppressWarnings(apply(x, MARGIN = 1L, FUN = function(e) all(as.logical(e) == value, na.rm = na.rm))) 331s + y <- rowAlls(x, na.rm = na.rm, value = value) 331s + stopifnot(identical(y, y0)) 331s + # Check names attribute 331s + dimnames(x) <- dimnames 331s + y <- rowAlls(x, na.rm = na.rm, value = value, useNames = FALSE) 331s + stopifnot(all.equal(y, y0)) 331s + y0 <- suppressWarnings(apply(x, MARGIN = 1L, FUN = function(e) all(as.logical(e) == value, na.rm = na.rm))) 331s + y <- rowAlls(x, na.rm = na.rm, value = value, useNames = TRUE) 331s + stopifnot(all.equal(y, y0)) 331s + dimnames(x) <- NULL 331s + 331s + y0 <- suppressWarnings(apply(x, MARGIN = 2L, FUN = function(e) all(as.logical(e) == value, na.rm = na.rm))) 331s + y <- colAlls(x, na.rm = na.rm, value = value) 331s + stopifnot(identical(y, y0)) 331s + print(y0) 331s + # Check names attribute 331s + dimnames(x) <- dimnames 331s + y <- colAlls(x, na.rm = na.rm, value = value, useNames = FALSE) 331s + stopifnot(all.equal(y, y0)) 331s + y0 <- suppressWarnings(apply(x, MARGIN = 2L, FUN = function(e) all(as.logical(e) == value, na.rm = na.rm))) 331s + y <- colAlls(x, na.rm = na.rm, value = value, useNames = TRUE) 331s + stopifnot(all.equal(y, y0)) 331s + dimnames(x) <- NULL 331s + } ## for (na.rm ...) 331s + } ## for(value ...) 331s [1] FALSE FALSE FALSE FALSE TRUE 331s [1] FALSE FALSE FALSE FALSE TRUE 331s [1] TRUE FALSE FALSE FALSE FALSE 331s [1] TRUE FALSE FALSE FALSE FALSE 331s > 331s > 331s > 331s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 331s > # Data type: character (not sure if this should be supported) 331s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 331s > all_R <- function(x, value = TRUE, ...) { 331s + if (is.na(value)) { 331s + all(is.na(x), ...) 331s + } else { 331s + all(x == value, ...) 331s + } 331s + } 331s > 331s > any_R <- function(x, value = TRUE, ...) { 331s + if (is.na(value)) { 331s + any(is.na(x), ...) 331s + } else { 331s + any(x == value, ...) 331s + } 331s + } 331s > 331s > x <- matrix(rep(letters, length.out = 10 * 5), nrow = 10L, ncol = 5L) 331s > x[2, ] <- "g" 331s > x[2:4, 3:4] <- NA_character_ 331s > 331s > # To check names attribute 331s > dimnames <- list(letters[1:10], LETTERS[1:5]) 331s > 331s > # Test with and without dimnames on x 331s > for (setDimnames in c(TRUE, FALSE)) { 331s + dimnames(x) <- if (setDimnames) dimnames else NULL 331s + 331s + # Row/column counts 331s + for (value in c("g", NA_character_)) { 331s + for (na.rm in c(FALSE, TRUE)) { 331s + # Check names attribute 331s + for (useNames in c(TRUE, FALSE)) { 331s + r0 <- rowAlls_R(x, value = value, na.rm = na.rm, useNames = useNames) 331s + r1 <- rowAlls(x, value = value, na.rm = na.rm, useNames = useNames) 331s + r2 <- colAlls(t(x), value = value, na.rm = na.rm, useNames = useNames) 331s + stopifnot(identical(r1, r0)) 331s + stopifnot(identical(r2, r1)) 331s + if (!useNames && !setDimnames) { 331s + for (rr in seq_len(nrow(x))) { 331s + c0 <- all_R(x[rr, ], value, na.rm = na.rm) 331s + c <- allValue(x[rr, ], value = value, na.rm = na.rm) 331s + stopifnot(identical(c, r1[rr])) 331s + stopifnot(identical(c, c0)) 331s + } 331s + } 331s + 331s + r0 <- rowAnys_R(x, value = value, na.rm = na.rm, useNames = useNames) 331s + r1 <- rowAnys(x, value = value, na.rm = na.rm, useNames = useNames) 331s + r2 <- colAnys(t(x), value = value, na.rm = na.rm, useNames = useNames) 331s + stopifnot(identical(r1, r0)) 331s + stopifnot(identical(r2, r1)) 331s + if (!useNames && !setDimnames) { 331s + for (rr in seq_len(nrow(x))) { 331s + c0 <- any_R(x[rr, ], value, na.rm = na.rm) 331s + c <- anyValue(x[rr, ], value = value, na.rm = na.rm) 331s + stopifnot(identical(c, c0)) 331s + stopifnot(identical(c, r1[rr])) 331s + } 331s + } 331s + } 331s + } 331s + } 331s + } 332s > 332s > 332s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 332s > # NA 0 test 332s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 332s > x <- matrix(0, nrow = 3L, ncol = 3L) 332s > x[1, ] <- c(NA_real_, NA_real_, 0) 332s > x[3, ] <- c(1, 0, 1) 332s > 332s > dimnames <- list(letters[1:3], LETTERS[1:3]) 332s > 332s > # Test with and without dimnames on x 332s > for (setDimnames in c(TRUE, FALSE)) { 332s + dimnames(x) <- if (setDimnames) dimnames else NULL 332s + # Check names attribute 332s + for (useNames in c(TRUE, FALSE)) { 332s + r0 <- rowAnys_R(x, value = 0, useNames = useNames) 332s + r1 <- rowAnys(x, value = 0, useNames = useNames) 332s + stopifnot(identical(r0, r1)) 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: aarch64-unknown-linux-gnu 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 > rowAlls_R <- function(x, value = TRUE, na.rm = FALSE, ..., useNames = TRUE) { 332s + if (is.na(value)) { 332s + res <- apply(is.na(x), MARGIN = 1L, FUN = all, na.rm = na.rm) 332s + } else { 332s + y <- x == value 332s + 332s + # Preserve dimnames attribute 332s + dim <- dim(x) # for 0xN and Mx0 cases; needed in R (< 3.4.0) 332s + if (!isTRUE(all.equal(dim(y), dim))) { 332s + dim(y) <- dim 332s + dimnames(y) <- dimnames(x) 332s + } 332s + 332s + res <- apply(y, MARGIN = 1L, FUN = all, na.rm = na.rm) 332s + } 332s + if (!useNames) names(res) <- NULL 332s + res 332s + } 332s > 332s > rowAnys_R <- function(x, value = TRUE, na.rm = FALSE, ..., useNames = TRUE) { 332s + if (is.na(value)) { 332s + res <- apply(is.na(x), MARGIN = 1L, FUN = any, na.rm = na.rm) 332s + } else { 332s + y <- x == value 332s + 332s + # Preserve dimnames attribute 332s + dim <- dim(x) # for 0xN and Mx0 cases; needed in R (< 3.4.0) 332s + if (!isTRUE(all.equal(dim(y), dim))) { 332s + dim(y) <- dim 332s + dimnames(y) <- dimnames(x) 332s + } 332s + 332s + res <- apply(y, MARGIN = 1L, FUN = any, na.rm = na.rm) 332s + } 332s + if (!useNames) names(res) <- NULL 332s + res 332s + } 332s > 332s > rowAnyMissings_R <- function(x, ..., useNames = TRUE) { 332s + res <- apply(x, MARGIN = 1L, FUN = anyMissing) 332s + if (!useNames) names(res) <- NULL 332s + res 332s + } 332s > 332s > 332s > all_R <- function(x, value = TRUE, ...) { 332s + if (is.na(value)) { 332s + all(is.na(x), ...) 332s + } else { 332s + all(x == value, ...) 332s + } 332s + } 332s > 332s > any_R <- function(x, value = TRUE, ...) { 332s + if (is.na(value)) { 332s + any(is.na(x), ...) 332s + } else { 332s + any(x == value, ...) 332s + } 332s + } 332s > 332s > 332s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 332s > # Subsetted tests 332s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 332s > source("utils/validateIndicesFramework.R") 332s > x <- matrix(runif(6 * 6, min = -3, max = 3), nrow = 6, ncol = 6) 332s > storage.mode(x) <- "integer" 332s > x[2:3, ] <- NA_integer_ 332s > x[2, 1] <- 0L 332s > x[4:5, ] <- 0L 332s > x[4, 6] <- NA_integer_ 332s > 332s > # To check names attribute 332s > dimnames <- list(letters[1:6], LETTERS[1:6]) 332s > 332s > # Test with and without dimnames on x 332s > for (setDimnames in c(TRUE, FALSE)) { 332s + if (setDimnames) dimnames(x) <- dimnames 332s + else dimnames(x) <- NULL 332s + 332s + count <- 0L 332s + for (rows in index_cases) { 332s + for (cols in index_cases) { 332s + count <- count + 1L 332s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 332s + useNames <- c(TRUE, FALSE) 332s + useNames <- useNames[count %% length(useNames) + 1] 332s + 332s + validateIndicesTestMatrix(x, rows, cols, 332s + ftest = rowAlls, fsure = rowAlls_R, 332s + value = 0, na.rm = TRUE, useNames = useNames) 332s + validateIndicesTestMatrix(x, rows, cols, 332s + ftest = rowAlls, fsure = rowAlls_R, 332s + value = 0, na.rm = FALSE, useNames = useNames) 332s + validateIndicesTestMatrix(x, rows, cols, 332s + ftest = rowAlls, fsure = rowAlls_R, 332s + value = NA_integer_, useNames = useNames) 332s + validateIndicesTestMatrix(x, rows, cols, 332s + fcoltest = colAlls, fsure = rowAlls_R, 332s + value = 0, na.rm = TRUE, useNames = useNames) 332s + validateIndicesTestMatrix(x, rows, cols, 332s + fcoltest = colAlls, fsure = rowAlls_R, 332s + value = 0, na.rm = FALSE, useNames = useNames) 332s + validateIndicesTestMatrix(x, rows, cols, 332s + fcoltest = colAlls, fsure = rowAlls_R, 332s + value = NA_integer_, useNames = useNames) 332s + 332s + validateIndicesTestMatrix(x, rows, cols, 332s + ftest = rowAnys, fsure = rowAnys_R, 332s + value = 0, na.rm = TRUE, useNames = useNames) 332s + validateIndicesTestMatrix(x, rows, cols, 332s + ftest = rowAnys, fsure = rowAnys_R, 332s + value = 0, na.rm = FALSE, useNames = useNames) 332s + validateIndicesTestMatrix(x, rows, cols, 332s + ftest = rowAnys, fsure = rowAnys_R, 332s + value = NA_integer_, useNames = useNames) 332s + validateIndicesTestMatrix(x, rows, cols, 332s + fcoltest = colAnys, fsure = rowAnys_R, 332s + value = 0, na.rm = TRUE, useNames = useNames) 332s + validateIndicesTestMatrix(x, rows, cols, 332s + fcoltest = colAnys, fsure = rowAnys_R, 332s + value = 0, na.rm = FALSE, useNames = useNames) 332s + validateIndicesTestMatrix(x, rows, cols, 332s + fcoltest = colAnys, fsure = rowAnys_R, 332s + value = NA_integer_, useNames = useNames) 332s + 332s + validateIndicesTestMatrix(x, rows, cols, 332s + ftest = rowAnyMissings, 332s + fsure = rowAnyMissings_R, useNames = useNames) 332s + validateIndicesTestMatrix(x, rows, cols, 332s + fcoltest = colAnyMissings, 332s + fsure = rowAnyMissings_R, useNames = useNames) 332s + } 332s + } 332s + } 334s > 334s > for (rr in seq_len(nrow(x))) { 334s + for (idxs in index_cases) { 334s + validateIndicesTestVector(x[rr, ], idxs, 334s + ftest = allValue, fsure = all_R, 334s + value = 0, na.rm = TRUE) 334s + validateIndicesTestVector(x[rr, ], idxs, 334s + ftest = allValue, fsure = all_R, 334s + value = 0, na.rm = FALSE) 334s + validateIndicesTestVector(x[rr, ], idxs, 334s + ftest = allValue, fsure = all_R, 334s + value = NA_integer_) 334s + 334s + validateIndicesTestVector(x[rr, ], idxs, 334s + ftest = anyValue, fsure = any_R, 334s + value = 0, na.rm = TRUE) 334s + validateIndicesTestVector(x[rr, ], idxs, 334s + ftest = anyValue, fsure = any_R, 334s + value = 0, na.rm = FALSE) 334s + validateIndicesTestVector(x[rr, ], idxs, 334s + ftest = anyValue, fsure = any_R, 334s + value = NA_integer_) 334s + } 334s + } 334s > 334s > 334s > storage.mode(x) <- "character" 334s > # Test with and without dimnames on x 334s > for (setDimnames in c(TRUE, FALSE)) { 334s + if (setDimnames) dimnames(x) <- dimnames 334s + else dimnames(x) <- NULL 334s + for (rows in index_cases) { 334s + for (cols in index_cases) { 334s + # Check names attribute 334s + for (useNames in c(TRUE, FALSE)) { 334s + validateIndicesTestMatrix(x, rows, cols, 334s + ftest = rowAlls, fsure = rowAlls_R, 334s + value = "0", na.rm = TRUE, useNames = useNames) 334s + validateIndicesTestMatrix(x, rows, cols, 334s + ftest = rowAlls, fsure = rowAlls_R, 334s + value = "0", na.rm = FALSE, useNames = useNames) 334s + validateIndicesTestMatrix(x, rows, cols, 334s + ftest = rowAlls, fsure = rowAlls_R, 334s + value = NA_character_, useNames = useNames) 334s + validateIndicesTestMatrix(x, rows, cols, 334s + fcoltest = colAlls, fsure = rowAlls_R, 334s + value = "0", na.rm = TRUE, useNames = useNames) 334s + validateIndicesTestMatrix(x, rows, cols, 334s + fcoltest = colAlls, fsure = rowAlls_R, 334s + value = "0", na.rm = FALSE, useNames = useNames) 334s + validateIndicesTestMatrix(x, rows, cols, 334s + fcoltest = colAlls, fsure = rowAlls_R, 334s + value = NA_character_, useNames = useNames) 334s + 334s + validateIndicesTestMatrix(x, rows, cols, 334s + ftest = rowAnys, fsure = rowAnys_R, 334s + value = "0", na.rm = TRUE, useNames = useNames) 334s + validateIndicesTestMatrix(x, rows, cols, 334s + ftest = rowAnys, fsure = rowAnys_R, 334s + value = "0", na.rm = FALSE, useNames = useNames) 334s + validateIndicesTestMatrix(x, rows, cols, 334s + ftest = rowAnys, fsure = rowAnys_R, 334s + value = NA_character_, useNames = useNames) 334s + validateIndicesTestMatrix(x, rows, cols, 334s + fcoltest = colAnys, fsure = rowAnys_R, 334s + value = "0", na.rm = TRUE, useNames = useNames) 334s + validateIndicesTestMatrix(x, rows, cols, 334s + fcoltest = colAnys, fsure = rowAnys_R, 334s + value = "0", na.rm = FALSE, useNames = useNames) 334s + validateIndicesTestMatrix(x, rows, cols, 334s + fcoltest = colAnys, fsure = rowAnys_R, 334s + value = NA_character_, useNames = useNames) 334s + 334s + validateIndicesTestMatrix(x, rows, cols, 334s + ftest = rowAnyMissings, 334s + fsure = rowAnyMissings_R, useNames = useNames) 334s + validateIndicesTestMatrix(x, rows, cols, 334s + fcoltest = colAnyMissings, 334s + fsure = rowAnyMissings_R, useNames = useNames) 334s + } 334s + } 334s + } 334s + } 337s > 337s > for (rr in seq_len(nrow(x))) { 337s + for (idxs in index_cases) { 337s + validateIndicesTestVector(x[rr, ], idxs, 337s + ftest = allValue, fsure = all_R, 337s + value = "0", na.rm = TRUE) 337s + validateIndicesTestVector(x[rr, ], idxs, 337s + ftest = allValue, fsure = all_R, 337s + value = "0", na.rm = FALSE) 337s + validateIndicesTestVector(x[rr, ], idxs, 337s + ftest = allValue, fsure = all_R, 337s + value = NA_integer_) 337s + 337s + validateIndicesTestVector(x[rr, ], idxs, 337s + ftest = anyValue, fsure = any_R, 337s + value = "0", na.rm = TRUE) 337s + validateIndicesTestVector(x[rr, ], idxs, 337s + ftest = anyValue, fsure = any_R, 337s + value = "0", na.rm = FALSE) 337s + validateIndicesTestVector(x[rr, ], idxs, 337s + ftest = anyValue, fsure = any_R, 337s + value = NA_integer_) 337s + } 337s + } 337s > 337s 337s R version 4.4.3 (2025-02-28) -- "Trophy Case" 337s Copyright (C) 2025 The R Foundation for Statistical Computing 337s Platform: aarch64-unknown-linux-gnu 337s 337s R is free software and comes with ABSOLUTELY NO WARRANTY. 337s You are welcome to redistribute it under certain conditions. 337s Type 'license()' or 'licence()' for distribution details. 337s 337s R is a collaborative project with many contributors. 337s Type 'contributors()' for more information and 337s 'citation()' on how to cite R or R packages in publications. 337s 337s Type 'demo()' for some demos, 'help()' for on-line help, or 337s 'help.start()' for an HTML browser interface to help. 337s Type 'q()' to quit R. 337s 338s > library("matrixStats") 338s > 338s > X <- matrix(rnorm(20 * 6), nrow = 20, ncol = 6) 338s > rownames(X) <- LETTERS[1:nrow(X)] 338s > colnames(X) <- letters[1:ncol(X)] 338s > print(X) 338s a b c d e f 338s A 1.3723688 -0.30823134 -0.48700930 -0.10049739 -0.01049207 -1.6324363 338s B -1.7421557 -1.29273737 0.39972060 0.21623851 -1.06086478 0.5884781 338s C 0.6968352 -1.20795966 0.10306832 0.24898178 -0.11328281 0.4979945 338s D 0.5875876 1.02870384 0.28772720 0.84437905 0.38881385 -1.0544426 338s E -1.7123094 1.42897507 -1.79484412 -0.35472199 1.50625781 -1.6548489 338s F -0.2494951 0.39743137 -0.77001345 0.26679567 -0.13703530 1.2402265 338s G 1.8463057 0.04895086 1.61264862 0.03671065 -0.15861570 -0.5132100 338s H -0.3936968 -1.31933224 -0.64614307 -0.15071585 -0.58179343 -0.3061026 338s I 0.8796954 1.16437370 0.71890385 -1.56868175 0.96205770 -1.3449448 338s J 2.9674548 -0.19739503 0.10159737 0.44185323 -0.41599247 2.2202750 338s K -1.3072253 -0.98037177 0.12073726 0.62481688 -0.11381852 0.7250456 338s L 0.9920537 -1.69802252 -0.09621637 -0.16690045 -1.39006422 -2.6828840 338s M 2.2609632 -0.06707271 1.35353751 -1.10324567 -0.02633095 -0.5405127 338s N -0.8994993 -0.75197501 -1.31455653 -2.44717246 0.35140095 0.1560931 338s O -0.4776911 -1.53820426 -0.14310915 0.97961095 1.13003258 -0.9231269 338s P 0.5392764 1.04463765 0.40796643 0.67756088 -0.97294039 0.5302721 338s Q -0.2162897 1.29930055 0.19691605 0.57505531 0.61013054 -0.2280224 338s R 0.3041370 -0.53582659 -1.17263450 0.91793562 -1.16802753 1.0540615 338s S 0.6840009 1.60950298 1.29062781 -0.33812224 -0.18490102 0.1984814 338s T 0.1029307 -0.35146862 0.98929955 -0.16315198 0.53315338 -0.7280749 338s > 338s > 338s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 338s > # Apply rowMeans() for 3 sets of 2 columns 338s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 338s > nbr_of_sets <- 3L 338s > S <- matrix(1:ncol(X), ncol = nbr_of_sets) 338s > colnames(S) <- sprintf("s%d", 1:nbr_of_sets) 338s > print(S) 338s s1 s2 s3 338s [1,] 1 3 5 338s [2,] 2 4 6 338s > 338s > Z <- rowAvgsPerColSet(X, S = S) 338s > print(Z) 338s s1 s2 s3 338s A 0.53206873 -0.2937533 -0.82146420 338s B -1.51744652 0.3079796 -0.23619333 338s C -0.25556223 0.1760251 0.19235582 338s D 0.80814570 0.5660531 -0.33281439 338s E -0.14166718 -1.0747831 -0.07429556 338s F 0.07396815 -0.2516089 0.55159562 338s G 0.94762826 0.8246796 -0.33591285 338s H -0.85651451 -0.3984295 -0.44394800 338s I 1.02203455 -0.4248889 -0.19144353 338s J 1.38502989 0.2717253 0.90214129 338s K -1.14379855 0.3727771 0.30561352 338s L -0.35298442 -0.1315584 -2.03647409 338s M 1.09694523 0.1251459 -0.28342183 338s N -0.82573717 -1.8808645 0.25374704 338s O -1.00794770 0.4182509 0.10345283 338s P 0.79195702 0.5427637 -0.22133414 338s Q 0.54150544 0.3859857 0.19105408 338s R -0.11584480 -0.1273494 -0.05698303 338s S 1.14675192 0.4762528 0.00679018 338s T -0.12426897 0.4130738 -0.09746074 338s > 338s > # Validation 338s > Z0 <- cbind(s1 = rowMeans(X[, 1:2]), s2 = rowMeans(X[, 3:4]), 338s + s3 = rowMeans(X[, 5:6])) 338s > stopifnot(identical(drop(Z), Z0)) 338s > 338s > 338s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 338s > # Apply colMeans() for 5 sets of 4 rows 338s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 338s > nbr_of_sets <- 5L 338s > S <- matrix(1:nrow(X), ncol = nbr_of_sets) 338s > colnames(S) <- sprintf("s%d", 1:nbr_of_sets) 338s > print(S) 338s s1 s2 s3 s4 s5 338s [1,] 1 5 9 13 17 338s [2,] 2 6 10 14 18 338s [3,] 3 7 11 15 19 338s [4,] 4 8 12 16 20 338s > 338s > Z <- colAvgsPerRowSet(X, S = S) 338s > print(Z) 338s a b c d e f 338s s1 0.2286590 -0.4450561 0.07587671 0.30227549 -0.19895645 -0.4001016 338s s2 -0.1272989 0.1390063 -0.39958800 -0.05048288 0.15720335 -0.3084837 338s s3 0.8829946 -0.4278539 0.21125553 -0.16722802 -0.23945438 -0.2706270 338s s4 0.3557623 -0.3281536 0.07595956 -0.47331157 0.12054055 -0.1943186 338s s5 0.2186947 0.5053771 0.32605223 0.24792918 -0.05241116 0.0741114 338s > 338s > # Validation 338s > Z0 <- rbind(s1 = colMeans(X[1:4, ]), s2 = colMeans(X[5:8, ]), 338s + s3 = colMeans(X[9:12, ]), s4 = colMeans(X[13:16, ]), 338s + s5 = colMeans(X[17:20, ])) 338s > stopifnot(identical(drop(Z), Z0)) 338s > 338s > 338s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 338s > # When there is only one "complete" set 338s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 338s > nbr_of_sets <- 1L 338s > S <- matrix(1:ncol(X), ncol = nbr_of_sets) 338s > colnames(S) <- sprintf("s%d", 1:nbr_of_sets) 338s > print(S) 338s s1 338s [1,] 1 338s [2,] 2 338s [3,] 3 338s [4,] 4 338s [5,] 5 338s [6,] 6 338s > 338s > Z <- rowAvgsPerColSet(X, S = S, FUN = rowMeans) 338s > print(Z) 338s s1 338s A -0.19438294 338s B -0.48188676 338s C 0.03760622 338s D 0.34712814 338s E -0.43024860 338s F 0.12465163 338s G 0.47879835 338s H -0.56629733 338s I 0.13523402 338s J 0.85296549 338s K -0.15513599 338s L -0.84033897 338s M 0.31288977 338s N -0.81761821 338s O -0.16208132 338s P 0.37112884 338s Q 0.37284840 338s R -0.10005909 338s S 0.54326496 338s T 0.06378136 338s > 338s > Z0 <- rowMeans(X) 338s > stopifnot(identical(drop(Z), Z0)) 338s > 338s > 338s > nbr_of_sets <- 1L 338s > S <- matrix(1:nrow(X), ncol = nbr_of_sets) 338s > colnames(S) <- sprintf("s%d", 1:nbr_of_sets) 338s > print(S) 338s s1 338s [1,] 1 338s [2,] 2 338s [3,] 3 338s [4,] 4 338s [5,] 5 338s [6,] 6 338s [7,] 7 338s [8,] 8 338s [9,] 9 338s [10,] 10 338s [11,] 11 338s [12,] 12 338s [13,] 13 338s [14,] 14 338s [15,] 15 338s [16,] 16 338s [17,] 17 338s [18,] 18 338s [19,] 19 338s [20,] 20 338s > 338s > Z <- colAvgsPerRowSet(X, S = S, FUN = colMeans) 338s > print(Z) 338s a b c d e f 338s s1 0.3117623 -0.1113361 0.0579112 -0.02816356 -0.04261562 -0.2198839 338s > 338s > Z0 <- colMeans(X) 338s > stopifnot(identical(drop(Z), Z0)) 338s > 338s > 338s > 338s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 338s > # Use weights 338s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 338s > nbr_of_sets <- 3L 338s > S <- matrix(1:ncol(X), ncol = nbr_of_sets) 338s > colnames(S) <- sprintf("s%d", 1:nbr_of_sets) 338s > print(S) 338s s1 s2 s3 338s [1,] 1 3 5 338s [2,] 2 4 6 338s > 338s > W <- matrix(runif(length(X)), nrow = nrow(X), ncol = ncol(X)) 338s > Z1 <- rowAvgsPerColSet(X, W = W, S = S, FUN = rowWeightedMeans) 338s > print(Z1) 338s s1 s2 s3 338s A 0.53206873 -0.2937533 -0.82146420 338s B -1.51744652 0.3079796 -0.23619333 338s C -0.25556223 0.1760251 0.19235582 338s D 0.80814570 0.5660531 -0.33281439 338s E -0.14166718 -1.0747831 -0.07429556 338s F 0.07396815 -0.2516089 0.55159562 338s G 0.94762826 0.8246796 -0.33591285 338s H -0.85651451 -0.3984295 -0.44394800 338s I 1.02203455 -0.4248889 -0.19144353 338s J 1.38502989 0.2717253 0.90214129 338s K -1.14379855 0.3727771 0.30561352 338s L -0.35298442 -0.1315584 -2.03647409 338s M 1.09694523 0.1251459 -0.28342183 338s N -0.82573717 -1.8808645 0.25374704 338s O -1.00794770 0.4182509 0.10345283 338s P 0.79195702 0.5427637 -0.22133414 338s Q 0.54150544 0.3859857 0.19105408 338s R -0.11584480 -0.1273494 -0.05698303 338s S 1.14675192 0.4762528 0.00679018 338s T -0.12426897 0.4130738 -0.09746074 338s > Z2 <- colAvgsPerRowSet(X, W = W, S = S, FUN = colWeightedMeans) 338s > print(Z2) 338s a b c d e f 338s s1 -0.1848934 -0.80048435 -0.04364435 0.05787056 -0.5356784 -0.5219791 338s s2 0.6422114 -0.08962791 0.19539776 0.54668042 0.1377655 -0.2782241 338s s3 -0.9809023 0.91320322 -1.28242878 -0.04396316 0.6846113 -0.2073112 338s > 338s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 338s > # Result should always be a matrix, including when nrow(X) <= 1 338s > # (https://github.com/HenrikBengtsson/matrixStats/issues/108) 338s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 338s > X <- matrix(1:3, nrow = 1L, ncol = 3L) 338s > S <- matrix(1, nrow = 1L, ncol = 1L) 338s > Z1 <- rowAvgsPerColSet(X, S = S) 338s > stopifnot(is.matrix(Z1)) 338s > Z2 <- rowAvgsPerColSet(X, S = S, rows = 0) 338s > stopifnot(is.matrix(Z2)) 338s > 338s > 338s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 338s > # Works with many, one or zero columns / rows 338s > # (https://github.com/HenrikBengtsson/matrixStats/issues/172) 338s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 338s > S <- cbind(1:2, 3:4, 5:6) 338s > X <- matrix(rnorm(2 * 6), nrow = 6, ncol = 2) 338s > Z2 <- colAvgsPerRowSet(X, S = S, FUN = colSums2) 338s > Z2_ref <- rbind(colSums2(X[S[,1], ,drop=FALSE]), 338s + colSums2(X[S[,2], ,drop=FALSE]), 338s + colSums2(X[S[,3], ,drop=FALSE])) 338s > stopifnot(identical(Z2, Z2_ref)) 338s > X <- matrix(rnorm(6), nrow = 6, ncol = 1) 338s > Z1 <- colAvgsPerRowSet(X, S = S, FUN = colSums2) 338s > Z1_ref <- rbind(colSums2(X[S[,1], ,drop=FALSE]), 338s + colSums2(X[S[,2], ,drop=FALSE]), 338s + colSums2(X[S[,3], ,drop=FALSE])) 338s > stopifnot(identical(Z1, Z1_ref)) 338s > X <- matrix(numeric(0), nrow = 6, ncol = 0) 338s > Z0 <- colAvgsPerRowSet(X, S = S, FUN = colSums2) 338s > Z0_ref <- matrix(numeric(0), nrow = ncol(S), ncol = 0) 338s > stopifnot(identical(Z0, unname(Z0_ref))) 338s > 338s > 338s > S <- rbind(1:4, 5:8) 338s > X <- matrix(rnorm(n = 2 * 8), nrow = 2, ncol = 8) 338s > Z2 <- rowAvgsPerColSet(X, S = S, FUN = rowMeans2) 338s > Z2_ref <- cbind(rowMeans2(X[,S[,1],drop=FALSE]), 338s + rowMeans2(X[,S[,2],drop=FALSE]), 338s + rowMeans2(X[,S[,3],drop=FALSE]), 338s + rowMeans2(X[,S[,4],drop=FALSE])) 338s > stopifnot(identical(Z2, Z2_ref)) 338s > X <- matrix(rnorm(n = 8), nrow = 1, ncol = 8) 338s > Z1 <- rowAvgsPerColSet(X, S = S, FUN = rowMeans2) 338s > Z1_ref <- cbind(rowMeans2(X[,S[,1],drop=FALSE]), 338s + rowMeans2(X[,S[,2],drop=FALSE]), 338s + rowMeans2(X[,S[,3],drop=FALSE]), 338s + rowMeans2(X[,S[,4],drop=FALSE])) 338s > stopifnot(identical(Z1, Z1_ref)) 338s > X <- matrix(numeric(0), nrow = 0, ncol = 8) 338s > Z0 <- rowAvgsPerColSet(X, S = S, FUN = rowMeans2) 338s > Z0_ref <- matrix(numeric(0), nrow = 0, ncol = ncol(S)) 338s > stopifnot(identical(Z0, Z0_ref)) 338s > 338s 338s R version 4.4.3 (2025-02-28) -- "Trophy Case" 338s Copyright (C) 2025 The R Foundation for Statistical Computing 338s Platform: aarch64-unknown-linux-gnu 338s 338s R is free software and comes with ABSOLUTELY NO WARRANTY. 338s You are welcome to redistribute it under certain conditions. 338s Type 'license()' or 'licence()' for distribution details. 338s 338s R is a collaborative project with many contributors. 338s Type 'contributors()' for more information and 338s 'citation()' on how to cite R or R packages in publications. 338s 338s Type 'demo()' for some demos, 'help()' for on-line help, or 338s 'help.start()' for an HTML browser interface to help. 338s Type 'q()' to quit R. 338s 338s > library("matrixStats") 338s > 338s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 338s > # Subsetted tests 338s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 338s > source("utils/validateIndicesFramework.R") 338s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 338s > #W <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 338s > for (rows in index_cases) { 338s + for (cols in index_cases) { 338s + if (is.null(rows)) { 338s + rows <- seq_len(nrow(x)) 338s + rows_finite <- rows 338s + } else { 338s + rows_finite <- rows[is.finite(rows)] 338s + } 338s + 338s + if (is.null(cols)) { 338s + cols <- seq_len(ncol(x)) 338s + cols_finite <- cols 338s + } else { 338s + cols_finite <- cols[is.finite(cols)] 338s + } 338s + 338s + suppressWarnings({ 338s + actual <- tryCatch({ 338s + rowAvgsPerColSet(x, rows = rows, S = matrix(cols, ncol = 1), 338s + FUN = rowMeans) 338s + }, error = function(c) "error") 338s + expect <- tryCatch({ 338s + rowMeans(x[rows, cols_finite, drop = FALSE], na.rm = TRUE) 338s + }, error = function(c) "error") 338s + }) 338s + stopifnot(all.equal(as.vector(actual), expect)) 338s + 338s + suppressWarnings({ 338s + actual <- tryCatch({ 338s + colAvgsPerRowSet(x, cols = cols, S = matrix(rows, ncol = 1), 338s + FUN = colMeans) 338s + }, error = function(c) "error") 338s + expect <- tryCatch({ 338s + colMeans(x[rows_finite, cols, drop = FALSE], na.rm = TRUE) 338s + }, error = function(c) "error") 338s + }) 338s + stopifnot(all.equal(as.vector(actual), expect)) 338s + } 338s + } 338s > 338s 338s R version 4.4.3 (2025-02-28) -- "Trophy Case" 338s Copyright (C) 2025 The R Foundation for Statistical Computing 338s Platform: aarch64-unknown-linux-gnu 338s 338s R is free software and comes with ABSOLUTELY NO WARRANTY. 338s You are welcome to redistribute it under certain conditions. 338s Type 'license()' or 'licence()' for distribution details. 338s 338s R is a collaborative project with many contributors. 338s Type 'contributors()' for more information and 338s 'citation()' on how to cite R or R packages in publications. 338s 338s Type 'demo()' for some demos, 'help()' for on-line help, or 338s 'help.start()' for an HTML browser interface to help. 338s Type 'q()' to quit R. 338s 338s > library("matrixStats") 338s > 338s > x <- matrix(1:27, ncol = 3) 338s > 338s > # To check names attribute 338s > dimnames <- list(letters[1:9], LETTERS[1:3]) 338s > 338s > rowCollapse_R <- function(x, idxs, ..., useNames = TRUE) { 338s + res <- x[, idxs] 338s + # Preserve names attribute? 338s + if (!useNames) names(res) <- NULL 338s + res 338s + } 338s > 338s > idxs <- 1L 338s > # Test with and without dimnames on x 338s > for (setDimnames in c(TRUE, FALSE)) { 338s + if (setDimnames) dimnames(x) <- dimnames 338s + else dimnames(x) <- NULL 338s + # Check names attribute 338s + for (useNames in c(TRUE, FALSE)) { 338s + y_truth <- rowCollapse_R(x, idxs, useNames = useNames) 338s + y <- rowCollapse(x, idxs, useNames = useNames) 338s + stopifnot(identical(y, y_truth)) 338s + y2 <- colCollapse(t(x), idxs, useNames = useNames) 338s + stopifnot(identical(y2, y)) 338s + } 338s + } 338s > 338s > idxs <- 2L 338s > # Test with and without dimnames on x 338s > for (setDimnames in c(TRUE, FALSE)) { 338s + if (setDimnames) dimnames(x) <- dimnames 338s + else dimnames(x) <- NULL 338s + # Check names attribute 338s + for (useNames in c(TRUE, FALSE)) { 338s + y_truth <- rowCollapse_R(x, idxs, useNames = useNames) 338s + y <- rowCollapse(x, idxs, useNames = useNames) 338s + stopifnot(identical(y, y_truth)) 338s + y2 <- colCollapse(t(x), idxs, useNames = useNames) 338s + stopifnot(identical(y2, y)) 338s + } 338s + } 338s > 338s > 338s > rowCollapse_R <- function(x, idxs, ..., useNames = TRUE) { 338s + res <- c(x[1:5, 1], x[6:9, 3]) 338s + # Preserve names attribute? 338s + if (!useNames) names(res) <- NULL 338s + res 338s + } 338s > 338s > idxs <- c(1, 1, 1, 1, 1, 3, 3, 3, 3) 338s > # Test with and without dimnames on x 338s > for (setDimnames in c(TRUE, FALSE)) { 338s + if (setDimnames) dimnames(x) <- dimnames 338s + else dimnames(x) <- NULL 338s + # Check names attribute 338s + for (useNames in c(TRUE, FALSE)) { 338s + y_truth <- rowCollapse_R(x, idxs, useNames = useNames) 338s + y <- rowCollapse(x, idxs, useNames = useNames) 338s + stopifnot(identical(y, y_truth)) 338s + y2 <- colCollapse(t(x), idxs, useNames = useNames) 338s + stopifnot(identical(y2, y)) 338s + } 338s + } 338s > 338s > 338s > rowCollapse_R <- function(x, idxs, ..., useNames = TRUE) { 338s + res <- c(x[1, 1], x[2, 2], x[3, 3], x[4, 1], x[5, 2], 338s + x[6, 3], x[7, 1], x[8, 2], x[9, 3]) 338s + # Preserve names attribute? 338s + if (useNames) { 338s + names <- rownames(x) 338s + if (!is.null(names)) names(res) <- names 338s + } 338s + res 338s + } 338s > 338s > idxs <- 1:3 338s > # Test with and without dimnames on x 338s > for (setDimnames in c(TRUE, FALSE)) { 338s + if (setDimnames) dimnames(x) <- dimnames 338s + else dimnames(x) <- NULL 338s + # Check names attribute 338s + for (useNames in c(TRUE, FALSE)) { 338s + y_truth <- rowCollapse_R(x, idxs, useNames = useNames) 338s + y <- rowCollapse(x, idxs, useNames = useNames) 338s + stopifnot(identical(y, y_truth)) 338s + y2 <- colCollapse(t(x), idxs, useNames = useNames) 338s + stopifnot(identical(y2, y)) 338s + } 338s + } 338s > 338s 338s R version 4.4.3 (2025-02-28) -- "Trophy Case" 338s Copyright (C) 2025 The R Foundation for Statistical Computing 338s Platform: aarch64-unknown-linux-gnu 338s 338s R is free software and comes with ABSOLUTELY NO WARRANTY. 338s You are welcome to redistribute it under certain conditions. 338s Type 'license()' or 'licence()' for distribution details. 338s 338s R is a collaborative project with many contributors. 338s Type 'contributors()' for more information and 338s 'citation()' on how to cite R or R packages in publications. 338s 338s Type 'demo()' for some demos, 'help()' for on-line help, or 338s 'help.start()' for an HTML browser interface to help. 338s Type 'q()' to quit R. 338s 338s > library("matrixStats") 338s > 338s > rowCollapse_R <- function(x, idxs, ..., useNames = TRUE) { 338s + ans <- c() 338s + storage.mode(ans) <- storage.mode(x) 338s + for (ii in seq_len(length(idxs))) { 338s + ans[ii] <- x[ii, idxs[ii]] 338s + } 338s + 338s + # Preserve names attribute 338s + if (useNames) { 338s + names <- rownames(x) 338s + if (!is.null(names)) names(ans) <- names 338s + } 338s + 338s + ans 338s + } 338s > 338s > 338s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 338s > # Subsetted tests 338s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 338s > source("utils/validateIndicesFramework.R") 338s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 338s > storage.mode(x) <- "integer" 338s > 338s > # To check names attribute 338s > dimnames <- list(letters[1:6], LETTERS[1:6]) 338s > 338s > for (rows in index_cases) { 338s + if (is.null(rows)) rows <- seq_len(nrow(x)) 338s + 338s + for (idxs in list(2L, seq_len(6L))) { 338s + for (useNames in c(TRUE, FALSE)) { 338s + suppressWarnings({ 338s + actual <- tryCatch(rowCollapse(x, idxs, rows = rows, useNames = useNames), 338s + error = function(c) "error") 338s + expect <- tryCatch({ 338s + idxs_0 <- rep(idxs, length.out = nrow(x))[rows] 338s + rowCollapse_R(x[rows, , drop = FALSE], idxs_0, useNames = useNames) 338s + }, error = function(c) "error") 338s + }) 338s + stopifnot(all.equal(actual, expect)) 338s + 338s + suppressWarnings({ 338s + actual <- tryCatch(colCollapse(t(x), idxs, cols = rows, useNames = useNames), 338s + error = function(c) "error") 338s + }) 338s + stopifnot(all.equal(actual, expect)) 338s + 338s + # Check names attribute 338s + dimnames(x) <- dimnames 338s + suppressWarnings({ 338s + actual <- tryCatch(rowCollapse(x, idxs, rows = rows, useNames = useNames), 338s + error = function(c) "error") 338s + expect <- tryCatch({ 338s + idxs_0 <- rep(idxs, length.out = nrow(x))[rows] 338s + rowCollapse_R(x[rows, , drop = FALSE], idxs_0, useNames = useNames) 338s + }, error = function(c) "error") 338s + }) 338s + stopifnot(all.equal(actual, expect)) 338s + 338s + suppressWarnings({ 338s + actual <- tryCatch(colCollapse(t(x), idxs, cols = rows, useNames = useNames), 338s + error = function(c) "error") 338s + }) 338s + stopifnot(all.equal(actual, expect)) 338s + 338s + dimnames(x) <- NULL 338s + } 338s + } 338s + } 339s > 339s 339s R version 4.4.3 (2025-02-28) -- "Trophy Case" 339s Copyright (C) 2025 The R Foundation for Statistical Computing 339s Platform: aarch64-unknown-linux-gnu 339s 339s R is free software and comes with ABSOLUTELY NO WARRANTY. 339s You are welcome to redistribute it under certain conditions. 339s Type 'license()' or 'licence()' for distribution details. 339s 339s R is a collaborative project with many contributors. 339s Type 'contributors()' for more information and 339s 'citation()' on how to cite R or R packages in publications. 339s 339s Type 'demo()' for some demos, 'help()' for on-line help, or 339s 'help.start()' for an HTML browser interface to help. 339s Type 'q()' to quit R. 339s 339s > library("matrixStats") 339s > 339s > rowCounts_R <- function(x, value = TRUE, na.rm = FALSE, ...) { 339s + if (is.na(value)) { 339s + counts <- apply(x, MARGIN = 1L, FUN = function(x) 339s + sum(is.na(x)) 339s + ) 339s + } else { 339s + counts <- apply(x, MARGIN = 1L, FUN = function(x) 339s + sum(x == value, na.rm = na.rm) 339s + ) 339s + } 339s + # Preserve names attribute 339s + names <- names(counts) 339s + counts <- as.integer(counts) 339s + if (useNames && !is.null(names)) names(counts) <- names 339s + counts 339s + } 339s > 339s > 339s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 339s > # Data type: integer and numeric 339s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 339s > for (mode in c("integer", "double")) { 339s + x <- matrix(runif(10 * 5, min = -3, max = 3), nrow = 10L, ncol = 5L) 339s + x[sample.int(length(x), size = 7L)] <- 0 339s + storage.mode(x) <- mode 339s + 339s + dimnames = list(letters[1:10], LETTERS[1:5]) 339s + 339s + # Test with and without dimnames on x 339s + for (setDimnames in c(TRUE, FALSE)) { 339s + if (setDimnames) dimnames(x) <- dimnames 339s + else dimnames(x) <- NULL 339s + for (na.rm in c(FALSE, TRUE)) { 339s + # Check names attribute 339s + for (useNames in c(TRUE, FALSE)) { 339s + # Count zeros 339s + r0 <- rowCounts_R(x, value = 0, na.rm = na.rm, useNames = useNames) 339s + r1 <- rowCounts(x, value = 0, na.rm = na.rm, useNames = useNames) 339s + r2 <- colCounts(t(x), value = 0, na.rm = na.rm, useNames = useNames) 339s + stopifnot(identical(r1, r0)) 339s + stopifnot(identical(r2, r0)) 339s + 339s + # Count NAs 339s + r0 <- rowCounts_R(x, value = NA, na.rm = na.rm, useNames = useNames) 339s + r1 <- rowCounts(x, value = NA, na.rm = na.rm, useNames = useNames) 339s + r2 <- colCounts(t(x), value = NA, na.rm = na.rm, useNames = useNames) 339s + stopifnot(identical(r1, r0)) 339s + stopifnot(identical(r2, r0)) 339s + 339s + if (mode == "integer") { 339s + ux <- unique(as.vector(x)) 339s + r0 <- r1 <- r2 <- integer(nrow(x)) 339s + for (value in ux) { 339s + r0 <- r0 + rowCounts_R(x, value = value, na.rm = na.rm, useNames = useNames) 339s + r1 <- r1 + rowCounts(x, value = value, na.rm = na.rm, useNames = useNames) 339s + r2 <- r2 + colCounts(t(x), value = value, na.rm = na.rm, useNames = useNames) 339s + stopifnot(identical(r1, r0)) 339s + stopifnot(identical(r2, r0)) 339s + } 339s + stopifnot(all(r0 == ncol(x))) 339s + } # if (mode == "integer") 339s + } # for (useNames ...) 339s + } # for (na.rm ...) 339s + } # for (setDimnames ...) 339s + } # for (mode ...) 339s > 339s > 339s > # All NAs 339s > na_list <- list(NA_integer_, NA_real_, NaN) 339s > for (na_value in na_list) { 339s + x <- matrix(na_value, nrow = 10L, ncol = 5L) 339s + # Test with and without dimnames on x 339s + for (setDimnames in c(TRUE, FALSE)) { 339s + if (setDimnames) dimnames(x) <- dimnames 339s + else dimnames(x) <- NULL 339s + for (na.rm in c(FALSE, TRUE)) { 339s + # Check names attribute 339s + for (useNames in c(TRUE, FALSE)) { 339s + r0 <- rowCounts_R(x, na.rm = na.rm, useNames = useNames) 339s + r1 <- rowCounts(x, na.rm = na.rm, useNames = useNames) 339s + r2 <- colCounts(t(x), na.rm = na.rm, useNames = useNames) 339s + stopifnot(identical(r1, r0)) 339s + stopifnot(identical(r2, r0)) 339s + 339s + # Count NAs 339s + r0 <- rowCounts_R(x, value = NA, na.rm = na.rm, useNames = useNames) 339s + r1 <- rowCounts(x, value = NA, na.rm = na.rm, useNames = useNames) 339s + r2 <- colCounts(t(x), value = NA, na.rm = na.rm, useNames = useNames) 339s + stopifnot(all(r0 == ncol(x))) 339s + stopifnot(identical(r1, r0)) 339s + stopifnot(identical(r2, r0)) 339s + } 339s + } 339s + } 339s + } # for (na_value ...) 339s > 339s > 339s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 339s > # Data type: logical 339s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 339s > x <- matrix(FALSE, nrow = 10L, ncol = 4L) 339s > x[7:8, 2:3] <- TRUE 339s > x[1:3, ] <- TRUE 339s > x[, 1] <- TRUE 339s > x[4, ] <- FALSE 339s > x[, 4] <- FALSE 339s > x[2, ] <- FALSE 339s > x[3, ] <- TRUE 339s > 339s > # To check names attribute 339s > dimnames <- list(letters[1:10], LETTERS[1:4]) 339s > 339s > # Test with and without dimnames on x 339s > for (setDimnames in c(TRUE, FALSE)) { 339s + if (setDimnames) dimnames(x) <- dimnames 339s + else dimnames(x) <- NULL 339s + # Row/column counts 339s + for (na.rm in c(FALSE, TRUE)) { 339s + # Check names attribute 339s + for (useNames in c(TRUE, FALSE)) { 339s + r0 <- rowCounts_R(x, na.rm = na.rm, useNames = useNames) 339s + r1 <- rowCounts(x, na.rm = na.rm, useNames = useNames) 339s + r2 <- colCounts(t(x), na.rm = na.rm, useNames = useNames) 339s + stopifnot(identical(r1, r0)) 339s + stopifnot(identical(r2, r0)) 339s + 339s + r_true <- rowCounts(x, value = TRUE, na.rm = na.rm, useNames = useNames) 339s + r_false <- rowCounts(x, value = FALSE, na.rm = na.rm, useNames = useNames) 339s + stopifnot(r_true + r_false == ncol(x)) 339s + 339s + c_true <- colCounts(x, value = TRUE, na.rm = na.rm, useNames = useNames) 339s + c_false <- colCounts(x, value = FALSE, na.rm = na.rm, useNames = useNames) 339s + stopifnot(c_true + c_false == nrow(x)) 339s + 339s + # Count NAs 339s + r0 <- rowCounts_R(x, value = NA, na.rm = na.rm, useNames = useNames) 339s + r1 <- rowCounts(x, value = NA, na.rm = na.rm, useNames = useNames) 339s + r2 <- colCounts(t(x), value = NA, na.rm = na.rm, useNames = useNames) 339s + stopifnot(identical(r1, r0)) 339s + stopifnot(identical(r2, r0)) 339s + } 339s + } 339s + } 339s > 339s > 339s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 339s > # Data type: character (not sure if this should be supported) 339s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 339s > x <- matrix(rep(letters, length.out = 10 * 5), nrow = 10L, ncol = 5L) 339s > x[2:3, 3:4] <- NA_character_ 339s > 339s > # Row/column counts 339s > for (na.rm in c(FALSE, TRUE)) { 339s + for (value in c("g", NA_character_)) { 339s + r0 <- rowCounts_R(x, value = value, na.rm = na.rm) 339s + r1 <- rowCounts(x, value = value, na.rm = na.rm) 339s + r2 <- colCounts(t(x), value = value, na.rm = na.rm) 339s + stopifnot(identical(r1, r0)) 339s + stopifnot(identical(r2, r0)) 339s + 339s + c <- count(x[1, ], value = value, na.rm = na.rm) 339s + stopifnot(identical(c, r1[1])) 339s + 339s + c <- count(x[2, ], value = value, na.rm = na.rm) 339s + stopifnot(identical(c, r1[2])) 339s + } 339s + } 339s > 339s > # NA row 339s > x <- matrix(0, nrow = 2L, ncol = 2L) 339s > x[1, ] <- NA_integer_ 339s > 339s > dimnames <- list(letters[1:2], LETTERS[1:2]) 339s > 339s > # Test with and without dimnames on x 339s > for (setDimnames in c(TRUE, FALSE)) { 339s + if (setDimnames) dimnames(x) <- dimnames 339s + else dimnames(x) <- NULL 339s + # Check names attribute 339s + for (useNames in c(TRUE, FALSE)) { 339s + r0 <- rowCounts(x, value = 0, useNames = useNames) 339s + r1 <- rowCounts_R(x, value = 0, useNames = useNames) 339s + stopifnot(identical(r0, r1)) 339s + } 339s + } 339s > 339s 339s R version 4.4.3 (2025-02-28) -- "Trophy Case" 339s Copyright (C) 2025 The R Foundation for Statistical Computing 339s Platform: aarch64-unknown-linux-gnu 339s 339s R is free software and comes with ABSOLUTELY NO WARRANTY. 339s You are welcome to redistribute it under certain conditions. 339s Type 'license()' or 'licence()' for distribution details. 339s 339s R is a collaborative project with many contributors. 339s Type 'contributors()' for more information and 339s 'citation()' on how to cite R or R packages in publications. 339s 339s Type 'demo()' for some demos, 'help()' for on-line help, or 339s 'help.start()' for an HTML browser interface to help. 339s Type 'q()' to quit R. 339s 339s > library("matrixStats") 339s > 339s > rowCounts_R <- function(x, value = TRUE, na.rm = FALSE, ..., useNames = TRUE) { 339s + if (is.na(value)) { 339s + counts <- apply(x, MARGIN = 1L, FUN = function(x) 339s + sum(is.na(x)) 339s + ) 339s + } else { 339s + counts <- apply(x, MARGIN = 1L, FUN = function(x) 339s + sum(x == value, na.rm = na.rm) 339s + ) 339s + } 339s + # Preserve names attribute 339s + names <- names(counts) 339s + counts <- as.integer(counts) 339s + if (useNames && !is.null(names)) names(counts) <- names 339s + counts 339s + } # rowCounts_R() 339s > 339s > 339s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 339s > # Subsetted tests 339s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 339s > source("utils/validateIndicesFramework.R") 339s > x <- matrix(runif(6 * 6, min = -3, max = 3), nrow = 6, ncol = 6) 339s > x[2:3, 3:4] <- NA_real_ 339s > storage.mode(x) <- "integer" 339s > 339s > # To check names attribute 339s > dimnames <- list(letters[1:6], LETTERS[1:6]) 339s > 339s > # Test with and without dimnames on x 339s > for (setDimnames in c(TRUE, FALSE)) { 339s + if (setDimnames) dimnames(x) <- dimnames 339s + else dimnames(x) <- NULL 339s + for (rows in index_cases) { 339s + for (cols in index_cases) { 339s + # Check names attribute 339s + for (useNames in c(TRUE, FALSE)) { 339s + validateIndicesTestMatrix(x, rows, cols, 339s + ftest = rowCounts, fsure = rowCounts_R, 339s + value = 0, na.rm = TRUE, useNames = useNames) 339s + validateIndicesTestMatrix(x, rows, cols, 339s + fcoltest = colCounts, fsure = rowCounts_R, 339s + value = 0, na.rm = TRUE, useNames = useNames) 339s + for (value in c(0, NA_integer_)) { 339s + validateIndicesTestMatrix(x, rows, cols, 339s + ftest = rowCounts, fsure = rowCounts_R, 339s + value = value, useNames = useNames) 339s + validateIndicesTestMatrix(x, rows, cols, 339s + fcoltest = colCounts, fsure = rowCounts_R, 339s + value = value, useNames = useNames) 339s + } 339s + } 339s + } 339s + } 339s + } 341s > 341s > x <- matrix(rep(letters, length.out = 6 * 6), nrow = 6, ncol = 6) 341s > x[2:3, 3:4] <- NA_character_ 341s > # Test with and without dimnames on x 341s > for (setDimnames in c(TRUE, FALSE)) { 341s + if (setDimnames) dimnames(x) <- dimnames 341s + else dimnames(x) <- NULL 341s + 341s + count <- 0L 341s + for (rows in index_cases) { 341s + for (cols in index_cases) { 341s + count <- count + 1L 341s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 341s + useNames <- c(TRUE, FALSE) 341s + useNames <- useNames[count %% length(useNames) + 1] 341s + 341s + validateIndicesTestMatrix(x, rows, cols, 341s + ftest = rowCounts, fsure = rowCounts_R, 341s + value = "g", na.rm = TRUE, useNames = useNames) 341s + validateIndicesTestMatrix(x, rows, cols, 341s + fcoltest = colCounts, fsure = rowCounts_R, 341s + value = "g", na.rm = TRUE, useNames = useNames) 341s + for (value in c("g", NA_character_)) { 341s + validateIndicesTestMatrix(x, rows, cols, 341s + ftest = rowCounts, fsure = rowCounts_R, 341s + value = value, useNames = useNames) 341s + validateIndicesTestMatrix(x, rows, cols, 341s + fcoltest = colCounts, fsure = rowCounts_R, 341s + value = value, useNames = useNames) 341s + } 341s + } 341s + } 341s + } 341s > 341s 341s R version 4.4.3 (2025-02-28) -- "Trophy Case" 341s Copyright (C) 2025 The R Foundation for Statistical Computing 341s Platform: aarch64-unknown-linux-gnu 341s 341s R is free software and comes with ABSOLUTELY NO WARRANTY. 341s You are welcome to redistribute it under certain conditions. 341s Type 'license()' or 'licence()' for distribution details. 341s 341s R is a collaborative project with many contributors. 341s Type 'contributors()' for more information and 341s 'citation()' on how to cite R or R packages in publications. 341s 341s Type 'demo()' for some demos, 'help()' for on-line help, or 341s 'help.start()' for an HTML browser interface to help. 341s Type 'q()' to quit R. 341s 342s > library("matrixStats") 342s > 342s > rowCummins_R <- function(x, ..., useNames = TRUE) { 342s + suppressWarnings({ 342s + y <- t(apply(x, MARGIN = 1L, FUN = cummin)) 342s + }) 342s + 342s + # Preserve dimnames attribute? 342s + dim(y) <- dim(x) 342s + dimnames(y) <- if (useNames) dimnames(x) else NULL 342s + y 342s + } 342s > 342s > rowCummaxs_R <- function(x, ..., useNames = TRUE) { 342s + mode <- storage.mode(x) 342s + # Change mode because a bug is detected on cummax for integer in R-3.2.0 342s + storage.mode(x) <- "numeric" 342s + suppressWarnings({ 342s + y <- t(apply(x, MARGIN = 1L, FUN = cummax)) 342s + }) 342s + 342s + # Preserve dimnames attribute? 342s + dim(y) <- dim(x) 342s + dimnames(y) <- if (useNames) dimnames(x) else NULL 342s + 342s + y 342s + } 342s > 342s > 342s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 342s > # With and without some NAs 342s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 342s > for (mode in c("logical", "integer", "double")) { 342s + for (add_na in c(FALSE, TRUE)) { 342s + cat("add_na = ", add_na, "\n", sep = "") 342s + 342s + x <- matrix(1:50, nrow = 10L, ncol = 5L) 342s + diag(x) <- 0 342s + if (add_na) { 342s + x[3:7, c(2, 4)] <- NA_real_ 342s + } 342s + cat("mode: ", mode, "\n", sep = "") 342s + storage.mode(x) <- mode 342s + str(x) 342s + 342s + # To check dimnames attribute 342s + dimnames <- list(letters[1:10], LETTERS[1:5]) 342s + 342s + # Test with and without dimnames on x 342s + for (setDimnames in c(TRUE, FALSE)) { 342s + if (setDimnames) dimnames(x) <- dimnames 342s + else dimnames(x) <- NULL 342s + # Check names attribute 342s + for (useNames in c(TRUE, FALSE)) { 342s + # Row/column ranges 342s + r0 <- rowCummins_R(x, useNames = useNames) 342s + r1 <- rowCummins(x, useNames = useNames) 342s + r2 <- t(colCummins(t(x), useNames = useNames)) 342s + stopifnot(all.equal(r1, r2)) 342s + stopifnot(all.equal(r1, r0)) 342s + stopifnot(all.equal(r2, r0)) 342s + 342s + r0 <- rowCummaxs_R(x, useNames = useNames) 342s + r1 <- rowCummaxs(x, useNames = useNames) 342s + r2 <- t(colCummaxs(t(x), useNames = useNames)) 342s + stopifnot(all.equal(r1, r2)) 342s + stopifnot(all.equal(r1, r0)) 342s + stopifnot(all.equal(r2, r0)) 342s + } # for (useNames ...) 342s + } # for (setDimnames ...) 342s + } # for (add_na ...) 342s + } # for (mode ...) 342s add_na = FALSE 342s mode: logical 342s logi [1:10, 1:5] FALSE TRUE TRUE TRUE TRUE TRUE ... 342s add_na = TRUE 342s mode: logical 342s logi [1:10, 1:5] FALSE TRUE TRUE TRUE TRUE TRUE ... 342s add_na = FALSE 342s mode: integer 342s int [1:10, 1:5] 0 2 3 4 5 6 7 8 9 10 ... 342s add_na = TRUE 342s mode: integer 342s int [1:10, 1:5] 0 2 3 4 5 6 7 8 9 10 ... 342s add_na = FALSE 342s mode: double 342s num [1:10, 1:5] 0 2 3 4 5 6 7 8 9 10 ... 342s add_na = TRUE 342s mode: double 342s num [1:10, 1:5] 0 2 3 4 5 6 7 8 9 10 ... 342s > 342s > 342s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 342s > # All NAs 342s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 342s > for (mode in c("logical", "integer", "double")) { 342s + x <- matrix(NA_real_, nrow = 10L, ncol = 5L) 342s + cat("mode: ", mode, "\n", sep = "") 342s + storage.mode(x) <- mode 342s + str(x) 342s + 342s + # Test with and without dimnames on x 342s + for (setDimnames in c(TRUE, FALSE)) { 342s + if (setDimnames) dimnames(x) <- dimnames 342s + else dimnames(x) <- NULL 342s + # Check names attribute 342s + for (useNames in c(TRUE, FALSE)) { 342s + r0 <- rowCummins_R(x, useNames = useNames) 342s + r1 <- rowCummins(x, useNames = useNames) 342s + r2 <- t(colCummins(t(x), useNames = useNames)) 342s + stopifnot(all.equal(r1, r2)) 342s + stopifnot(all.equal(r1, r0)) 342s + stopifnot(all.equal(r2, r0)) 342s + 342s + r0 <- rowCummaxs_R(x, useNames = useNames) 342s + r1 <- rowCummaxs(x, useNames = useNames) 342s + r2 <- t(colCummaxs(t(x), useNames = useNames)) 342s + stopifnot(all.equal(r1, r2)) 342s + stopifnot(all.equal(r1, r0)) 342s + stopifnot(all.equal(r2, r0)) 342s + } # for (useNames ...) 342s + } # for (setDimnames ...) 342s + } # for (mode ...) 342s mode: logical 342s logi [1:10, 1:5] NA NA NA NA NA NA ... 342s mode: integer 342s int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 342s mode: double 342s num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 342s > 342s > 342s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 342s > # A 1x1 matrix 342s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 342s > for (mode in c("logical", "integer", "double")) { 342s + x <- matrix(0, nrow = 1L, ncol = 1L) 342s + cat("mode: ", mode, "\n", sep = "") 342s + storage.mode(x) <- mode 342s + str(x) 342s + 342s + # To check dimnames attribute 342s + dimnames <- list("a", "A") 342s + 342s + # Test with and without dimnames on x 342s + for (setDimnames in c(TRUE, FALSE)) { 342s + if (setDimnames) dimnames(x) <- dimnames 342s + else dimnames(x) <- NULL 342s + # Check names attribute 342s + for (useNames in c(TRUE, FALSE)) { 342s + r0 <- rowCummins_R(x, useNames = useNames) 342s + r1 <- rowCummins(x, useNames = useNames) 342s + r2 <- t(colCummins(t(x), useNames = useNames)) 342s + stopifnot(all.equal(r1, r2)) 342s + stopifnot(all.equal(r1, r0)) 342s + stopifnot(all.equal(r2, r0)) 342s + 342s + r0 <- rowCummaxs_R(x, useNames = useNames) 342s + r1 <- rowCummaxs(x, useNames = useNames) 342s + r2 <- t(colCummaxs(t(x), useNames = useNames)) 342s + stopifnot(all.equal(r1, r2)) 342s + stopifnot(all.equal(r1, r0)) 342s + stopifnot(all.equal(r2, r0)) 342s + } # for (useNames ...) 342s + } # for (setDimnames ...) 342s + } # for (mode ...) 342s mode: logical 342s logi [1, 1] FALSE 342s mode: integer 342s int [1, 1] 0 342s mode: double 342s num [1, 1] 0 342s > 342s > 342s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 342s > # Corner cases 342s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 342s > for (mode in c("logical", "integer", "double")) { 342s + cat("mode: ", mode, "\n", sep = "") 342s + value <- 0 342s + storage.mode(value) <- mode 342s + value0 <- if (mode == "logical") 0L else value 342s + 342s + # A 0x0 matrix 342s + x <- matrix(value, nrow = 0L, ncol = 0L) 342s + str(x) 342s + r0 <- matrix(value0, nrow = nrow(x), ncol = ncol(x)) 342s + r1 <- rowCummins(x) 342s + r2 <- t(colCummins(t(x))) 342s + stopifnot(all.equal(r1, r2)) 342s + stopifnot(all.equal(r1, r0)) 342s + stopifnot(all.equal(r2, r0)) 342s + 342s + # A 0xK matrix 342s + x <- matrix(value, nrow = 0L, ncol = 5L) 342s + str(x) 342s + colnames <- LETTERS[1:5] 342s + # Test with and without dimnames on x 342s + for (setDimnames in c(TRUE, FALSE)) { 342s + if (setDimnames) colnames(x) <- colnames 342s + else dimnames(x) <- NULL 342s + # Check names attribute 342s + for (useNames in c(TRUE, FALSE)) { 342s + r0 <- rowCummins_R(x, useNames = useNames) 342s + r1 <- rowCummins(x, useNames = useNames) 342s + r2 <- t(colCummins(t(x), useNames = useNames)) 342s + stopifnot(all.equal(r1, r2)) 342s + stopifnot(all.equal(r1, r0)) 342s + stopifnot(all.equal(r2, r0)) 342s + r0 <- rowCummaxs_R(x, useNames = useNames) 342s + r1 <- rowCummaxs(x, useNames = useNames) 342s + r2 <- t(colCummaxs(t(x), useNames = useNames)) 342s + stopifnot(all.equal(r1, r2)) 342s + stopifnot(all.equal(r1, r0)) 342s + stopifnot(all.equal(r2, r0)) 342s + } # for (useNames ...) 342s + } # for (setDimnames ...) 342s + 342s + # A Nx0 matrix 342s + x <- matrix(value, nrow = 5L, ncol = 0L) 342s + str(x) 342s + rownames <- LETTERS[1:5] 342s + # Test with and without dimnames on x 342s + for (setDimnames in c(TRUE, FALSE)) { 342s + if (setDimnames) rownames(x) <- rownames 342s + else dimnames(x) <- NULL 342s + # Check names attribute 342s + for (useNames in c(TRUE, FALSE)) { 342s + r0 <- rowCummins_R(x, useNames = useNames) 342s + r1 <- rowCummins(x, useNames = useNames) 342s + r2 <- t(colCummins(t(x), useNames = useNames)) 342s + stopifnot(all.equal(r1, r2)) 342s + stopifnot(all.equal(r1, r0)) 342s + stopifnot(all.equal(r2, r0)) 342s + 342s + r0 <- rowCummaxs_R(x, useNames = useNames) 342s + r1 <- rowCummaxs(x, useNames = useNames) 342s + r2 <- t(colCummaxs(t(x), useNames = useNames)) 342s + stopifnot(all.equal(r1, r2)) 342s + stopifnot(all.equal(r1, r0)) 342s + stopifnot(all.equal(r2, r0)) 342s + } # for (useNames ...) 342s + } # for (setDimnames ...) 342s + } # for (mode ...) 342s mode: logical 342s logi[0 , 0 ] 342s logi[0 , 1:5] 342s logi[1:5, 0 ] 342s mode: integer 342s int[0 , 0 ] 342s int[0 , 1:5] 342s int[1:5, 0 ] 342s mode: double 342s num[0 , 0 ] 342s num[0 , 1:5] 342s num[1:5, 0 ] 342s > 342s 342s R version 4.4.3 (2025-02-28) -- "Trophy Case" 342s Copyright (C) 2025 The R Foundation for Statistical Computing 342s Platform: aarch64-unknown-linux-gnu 342s 342s R is free software and comes with ABSOLUTELY NO WARRANTY. 342s You are welcome to redistribute it under certain conditions. 342s Type 'license()' or 'licence()' for distribution details. 342s 342s R is a collaborative project with many contributors. 342s Type 'contributors()' for more information and 342s 'citation()' on how to cite R or R packages in publications. 342s 342s Type 'demo()' for some demos, 'help()' for on-line help, or 342s 'help.start()' for an HTML browser interface to help. 342s Type 'q()' to quit R. 342s 342s > library("matrixStats") 342s > 342s > rowCummins_R <- function(x, ..., useNames = TRUE) { 342s + suppressWarnings({ 342s + y <- t(apply(x, MARGIN = 1L, FUN = cummin)) 342s + }) 342s + 342s + # Preserve dimnames attribute? 342s + dim(y) <- dim(x) 342s + dimnames(y) <- if (useNames) dimnames(x) else NULL 342s + 342s + y 342s + } 342s > 342s > rowCummaxs_R <- function(x, ..., useNames = TRUE) { 342s + mode <- storage.mode(x) 342s + # Change mode because a bug is detected on cummax for integer in R-3.2.0 342s + storage.mode(x) <- "numeric" 342s + suppressWarnings({ 342s + y <- t(apply(x, MARGIN = 1L, FUN = cummax)) 342s + }) 342s + 342s + # Preserve dimnames attribute? 342s + dim(y) <- dim(x) 342s + dimnames(y) <- if (useNames) dimnames(x) else NULL 342s + 342s + storage.mode(y) <- mode 342s + y 342s + } 342s > 342s > 342s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 342s > # Subsetted tests 342s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 342s > source("utils/validateIndicesFramework.R") 342s > x <- matrix(runif(6 * 6, min = -3, max = 3), nrow = 6, ncol = 6) 342s > storage.mode(x) <- "integer" 342s > 342s > # To check dimnames attribute 342s > dimnames <- list(letters[1:6], LETTERS[1:6]) 342s > 342s > # Test with and without dimnames on x 342s > for (setDimnames in c(TRUE, FALSE)) { 342s + if (setDimnames) dimnames(x) <- dimnames 342s + else dimnames(x) <- NULL 342s + for (rows in index_cases) { 342s + for (cols in index_cases) { 342s + # Check names attribute 342s + for (useNames in c(TRUE, FALSE)) { 342s + validateIndicesTestMatrix(x, rows, cols, 342s + ftest = rowCummins, fsure = rowCummins_R, useNames = useNames,verbose=TRUE) 342s + validateIndicesTestMatrix(x, rows, cols, 342s + ftest = function(x, rows, cols, ..., useNames) { 342s + t(colCummins(t(x), rows = cols, cols = rows, useNames = useNames)) 342s + }, fsure = rowCummins_R, useNames = useNames) 342s + 342s + validateIndicesTestMatrix(x, rows, cols, 342s + ftest = rowCummaxs, fsure = rowCummaxs_R, useNames = useNames) 342s + validateIndicesTestMatrix(x, rows, cols, 342s + ftest = function(x, rows, cols, ..., useNames) { 342s + t(colCummaxs(t(x), rows = cols, cols = rows, useNames = useNames)) 342s + }, fsure = rowCummaxs_R, useNames = useNames) 342s + } 342s + } 342s + } 342s + } 344s > 344s 344s R version 4.4.3 (2025-02-28) -- "Trophy Case" 344s Copyright (C) 2025 The R Foundation for Statistical Computing 344s Platform: aarch64-unknown-linux-gnu 344s 344s R is free software and comes with ABSOLUTELY NO WARRANTY. 344s You are welcome to redistribute it under certain conditions. 344s Type 'license()' or 'licence()' for distribution details. 344s 344s R is a collaborative project with many contributors. 344s Type 'contributors()' for more information and 344s 'citation()' on how to cite R or R packages in publications. 344s 344s Type 'demo()' for some demos, 'help()' for on-line help, or 344s 'help.start()' for an HTML browser interface to help. 344s Type 'q()' to quit R. 344s 344s > library("matrixStats") 344s > 344s > rowCumprods_R <- function(x, ..., useNames = TRUE) { 344s + suppressWarnings({ 344s + y <- t(apply(x, MARGIN = 1L, FUN = cumprod)) 344s + }) 344s + 344s + # Preserve dimnames attribute? 344s + dim(y) <- dim(x) 344s + dimnames(y) <- if (useNames) dimnames(x) else NULL 344s + 344s + y 344s + } 344s > 344s > 344s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 344s > # With and without some NAs 344s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 344s > for (mode in c("logical", "integer", "double")) { 344s + for (add_na in c(FALSE, TRUE)) { 344s + cat("add_na = ", add_na, "\n", sep = "") 344s + 344s + x <- matrix(1:50, nrow = 10L, ncol = 5L) 344s + if (add_na) { 344s + x[3:7, c(2, 4)] <- NA_real_ 344s + } 344s + cat("mode: ", mode, "\n", sep = "") 344s + storage.mode(x) <- mode 344s + str(x) 344s + 344s + # To check dimnames attribute 344s + dimnames <- list(letters[1:10], LETTERS[1:5]) 344s + 344s + # Test with and without dimnames on x 344s + for (setDimnames in c(TRUE, FALSE)) { 344s + if (setDimnames) dimnames(x) <- dimnames 344s + else dimnames(x) <- NULL 344s + # Check names attribute 344s + for (useNames in c(TRUE, FALSE)) { 344s + # Row/column ranges 344s + r0 <- rowCumprods_R(x, useNames = useNames) 344s + r1 <- rowCumprods(x, useNames = useNames) 344s + r2 <- t(colCumprods(t(x), useNames = useNames)) 344s + stopifnot(all.equal(r1, r2)) 344s + stopifnot(all.equal(r1, r0)) 344s + stopifnot(all.equal(r2, r0)) 344s + } # for (useNames ...) 344s + } # for (setDimnames ...) 344s + } # for (add_na ...) 344s + } # for (mode ...) 344s add_na = FALSE 344s mode: logical 344s logi [1:10, 1:5] TRUE TRUE TRUE TRUE TRUE TRUE ... 344s add_na = TRUE 344s mode: logical 344s logi [1:10, 1:5] TRUE TRUE TRUE TRUE TRUE TRUE ... 344s add_na = FALSE 344s mode: integer 344s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 344s add_na = TRUE 344s mode: integer 344s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 344s add_na = FALSE 344s mode: double 344s num [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 344s add_na = TRUE 344s mode: double 344s num [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 344s > 344s > 344s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 344s > # All NAs 344s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 344s > for (mode in c("logical", "integer", "double")) { 344s + x <- matrix(NA_real_, nrow = 10L, ncol = 5L) 344s + cat("mode: ", mode, "\n", sep = "") 344s + storage.mode(x) <- mode 344s + str(x) 344s + 344s + # Test with and without dimnames on x 344s + for (setDimnames in c(TRUE, FALSE)) { 344s + if (setDimnames) dimnames(x) <- dimnames 344s + else dimnames(x) <- NULL 344s + # Check names attribute 344s + for (useNames in c(TRUE, FALSE)) { 344s + # Row/column ranges 344s + r0 <- rowCumprods_R(x, useNames = useNames) 344s + r1 <- rowCumprods(x, useNames = useNames) 344s + r2 <- t(colCumprods(t(x), useNames = useNames)) 344s + stopifnot(all.equal(r1, r2)) 344s + stopifnot(all.equal(r1, r0)) 344s + stopifnot(all.equal(r2, r0)) 344s + } # for (useNames ...) 344s + } # for (setDimnames ...) 344s + } # for (mode ...) 344s mode: logical 344s logi [1:10, 1:5] NA NA NA NA NA NA ... 344s mode: integer 344s int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 344s mode: double 344s num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 344s > 344s > 344s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 344s > # A 1x1 matrix 344s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 344s > for (mode in c("logical", "integer", "double")) { 344s + x <- matrix(0, nrow = 1L, ncol = 1L) 344s + cat("mode: ", mode, "\n", sep = "") 344s + storage.mode(x) <- mode 344s + str(x) 344s + 344s + dimnames <- list("a", "A") 344s + # Test with and without dimnames on x 344s + for (setDimnames in c(TRUE, FALSE)) { 344s + if (setDimnames) dimnames(x) <- dimnames 344s + else dimnames(x) <- NULL 344s + # Check names attribute 344s + for (useNames in c(TRUE, FALSE)) { 344s + # Row/column ranges 344s + r0 <- rowCumprods_R(x, useNames = useNames) 344s + r1 <- rowCumprods(x, useNames = useNames) 344s + r2 <- t(colCumprods(t(x), useNames = useNames)) 344s + stopifnot(all.equal(r1, r2)) 344s + stopifnot(all.equal(r1, r0)) 344s + stopifnot(all.equal(r2, r0)) 344s + } # for (useNames ...) 344s + } # for (setDimnames ...) 344s + } 344s mode: logical 344s logi [1, 1] FALSE 344s mode: integer 344s int [1, 1] 0 344s mode: double 344s num [1, 1] 0 344s > 344s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 344s > # BUG FIX TEST: Assert zeros don't trump NAs in integer matrices 344s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 344s > for (mode in c("logical", "integer", "double")) { 344s + x <- matrix(NA_real_, nrow = 3L, ncol = 2L) 344s + x[1, 2] <- 0 344s + x[2, 2] <- 1 344s + x[3, 1] <- 0 344s + storage.mode(x) <- mode 344s + cat("mode: ", mode, "\n", sep = "") 344s + str(x) 344s + 344s + dimnames <- list(letters[1:3], LETTERS[1:2]) 344s + # Test with and without dimnames on x 344s + for (setDimnames in c(TRUE, FALSE)) { 344s + if (setDimnames) dimnames(x) <- dimnames 344s + else dimnames(x) <- NULL 344s + # Check names attribute 344s + for (useNames in c(TRUE, FALSE)) { 344s + # Row/column ranges 344s + r0 <- rowCumprods_R(x, useNames = useNames) 344s + r1 <- rowCumprods(x, useNames = useNames) 344s + r2 <- t(colCumprods(t(x), useNames = useNames)) 344s + stopifnot(all.equal(r1, r2)) 344s + stopifnot(all.equal(r1, r0)) 344s + stopifnot(all.equal(r2, r0)) 344s + } # for (useNames ...) 344s + } # for (setDimnames ...) 344s + } 344s mode: logical 344s logi [1:3, 1:2] NA NA FALSE FALSE TRUE NA 344s mode: integer 344s int [1:3, 1:2] NA NA 0 0 1 NA 344s mode: double 344s num [1:3, 1:2] NA NA 0 0 1 NA 344s > 344s > 344s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 344s > # Corner cases 344s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 344s > for (mode in c("logical", "integer", "double")) { 344s + cat("mode: ", mode, "\n", sep = "") 344s + value <- 0 344s + storage.mode(value) <- mode 344s + if (mode == "logical") value2 <- 0L 344s + 344s + # A 0x0 matrix 344s + x <- matrix(value, nrow = 0L, ncol = 0L) 344s + str(x) 344s + r0 <- matrix(value2, nrow = nrow(x), ncol = ncol(x)) 344s + r1 <- rowCumprods(x) 344s + r2 <- t(colCumprods(t(x))) 344s + stopifnot(all.equal(r1, r2)) 344s + stopifnot(all.equal(r1, r0)) 344s + stopifnot(all.equal(r2, r0)) 344s + 344s + # A 0xK matrix 344s + x <- matrix(value, nrow = 0L, ncol = 5L) 344s + str(x) 344s + colnames <- LETTERS[1:5] 344s + # Test with and without dimnames on x 344s + for (setDimnames in c(TRUE, FALSE)) { 344s + if (setDimnames) colnames(x) <- colnames 344s + else dimnames(x) <- NULL 344s + # Check names attribute 344s + for (useNames in c(TRUE, FALSE)) { 344s + r0 <- rowCumprods_R(x, useNames = useNames) 344s + r1 <- rowCumprods(x, useNames = useNames) 344s + r2 <- t(rowCumprods(t(x), useNames = useNames)) 344s + stopifnot(all.equal(r1, r2)) 344s + stopifnot(all.equal(r1, r0)) 344s + stopifnot(all.equal(r2, r0)) 344s + } # for (useNames ...) 344s + } # for (setDimnames ...) 344s + 344s + # A Nx0 matrix 344s + x <- matrix(value, nrow = 5L, ncol = 0L) 344s + str(x) 344s + rownames <- LETTERS[1:5] 344s + # Test with and without dimnames on x 344s + for (setDimnames in c(TRUE, FALSE)) { 344s + if (setDimnames) rownames(x) <- rownames 344s + else dimnames(x) <- NULL 344s + # Check names attribute 344s + for (useNames in c(TRUE, FALSE)) { 344s + r0 <- rowCumprods_R(x, useNames = useNames) 344s + r1 <- rowCumprods(x, useNames = useNames) 344s + r2 <- t(rowCumprods(t(x), useNames = useNames)) 344s + stopifnot(all.equal(r1, r2)) 344s + stopifnot(all.equal(r1, r0)) 344s + stopifnot(all.equal(r2, r0)) 344s + } # for (useNames ...) 344s + } # for (setDimnames ...) 344s + } # for (mode ...) 345s mode: logical 345s logi[0 , 0 ] 345s logi[0 , 1:5] 345s logi[1:5, 0 ] 345s mode: integer 345s int[0 , 0 ] 345s int[0 , 1:5] 345s int[1:5, 0 ] 345s mode: double 345s num[0 , 0 ] 345s num[0 , 1:5] 345s num[1:5, 0 ] 345s > 345s 345s R version 4.4.3 (2025-02-28) -- "Trophy Case" 345s Copyright (C) 2025 The R Foundation for Statistical Computing 345s Platform: aarch64-unknown-linux-gnu 345s 345s R is free software and comes with ABSOLUTELY NO WARRANTY. 345s You are welcome to redistribute it under certain conditions. 345s Type 'license()' or 'licence()' for distribution details. 345s 345s R is a collaborative project with many contributors. 345s Type 'contributors()' for more information and 345s 'citation()' on how to cite R or R packages in publications. 345s 345s Type 'demo()' for some demos, 'help()' for on-line help, or 345s 'help.start()' for an HTML browser interface to help. 345s Type 'q()' to quit R. 345s 345s > library("matrixStats") 345s > 345s > rowCumprods_R <- function(x, ..., useNames = TRUE) { 345s + suppressWarnings({ 345s + y <- t(apply(x, MARGIN = 1L, FUN = cumprod)) 345s + }) 345s + 345s + # Preserve dimnames attribute? 345s + dim(y) <- dim(x) 345s + dimnames(y) <- if (useNames) dimnames(x) else NULL 345s + 345s + y 345s + } 345s > 345s > 345s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 345s > # Subsetted tests 345s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 345s > source("utils/validateIndicesFramework.R") 345s > x <- matrix(runif(6 * 6, min = -3, max = 3), nrow = 6, ncol = 6) 345s > storage.mode(x) <- "integer" 345s > 345s > # To check dimnames attribute 345s > dimnames <- list(letters[1:6], LETTERS[1:6]) 345s > 345s > # Test with and without dimnames on x 345s > for (setDimnames in c(TRUE, FALSE)) { 345s + if (setDimnames) dimnames(x) <- dimnames 345s + else dimnames(x) <- NULL 345s + for (rows in index_cases) { 345s + for (cols in index_cases) { 345s + # Check names attribute 345s + for (useNames in c(TRUE, FALSE)) { 345s + validateIndicesTestMatrix(x, rows, cols, 345s + ftest = rowCumprods, fsure = rowCumprods_R, useNames = useNames) 345s + validateIndicesTestMatrix(x, rows, cols, 345s + ftest = function(x, rows, cols, ..., useNames) { 345s + t(colCumprods(t(x), rows = cols, cols = rows, useNames = useNames)) 345s + }, fsure = rowCumprods_R, useNames = useNames) 345s + } 345s + } 345s + } 345s + } 346s > 346s 346s R version 4.4.3 (2025-02-28) -- "Trophy Case" 346s Copyright (C) 2025 The R Foundation for Statistical Computing 346s Platform: aarch64-unknown-linux-gnu 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 > 346s > rowCumsums_R <- function(x, ..., useNames = TRUE) { 346s + suppressWarnings({ 346s + y <- t(apply(x, MARGIN = 1L, FUN = cumsum)) 346s + }) 346s + 346s + # Preserve dimnames attribute? 346s + dim(y) <- dim(x) 346s + dimnames(y) <- if (useNames) dimnames(x) else NULL 346s + 346s + y 346s + } 346s > 346s > 346s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 346s > # With and without some NAs 346s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 346s > dimnames <- list(letters[1:10], LETTERS[1:5]) # to check dimnames attribute 346s > for (mode in c("logical", "integer", "double")) { 346s + for (add_na in c(FALSE, TRUE)) { 346s + cat("add_na = ", add_na, "\n", sep = "") 346s + 346s + x <- matrix(1:50, nrow = 10L, ncol = 5L) 346s + if (add_na) { 346s + x[3:7, c(2, 4)] <- NA_real_ 346s + } 346s + cat("mode: ", mode, "\n", sep = "") 346s + storage.mode(x) <- mode 346s + str(x) 346s + 346s + # Test with and without dimnames on x 346s + for (setDimnames in c(TRUE, FALSE)) { 346s + if (setDimnames) dimnames(x) <- dimnames 346s + else dimnames(x) <- NULL 346s + # Check names attribute 346s + for (useNames in c(TRUE, FALSE)) { 346s + # Row/column ranges 346s + r0 <- rowCumsums_R(x, useNames = useNames) 346s + r1 <- rowCumsums(x, useNames = useNames) 346s + r2 <- t(colCumsums(t(x), useNames = useNames)) 346s + stopifnot(all.equal(r1, r2)) 346s + stopifnot(all.equal(r1, r0)) 346s + stopifnot(all.equal(r2, r0)) 346s + } # for (useNames ...) 346s + } # for (setDimnames ...) 346s + } # for (add_na ...) 346s + } 346s add_na = FALSE 346s mode: logical 346s logi [1:10, 1:5] TRUE TRUE TRUE TRUE TRUE TRUE ... 346s add_na = TRUE 346s mode: logical 346s logi [1:10, 1:5] TRUE TRUE TRUE TRUE TRUE TRUE ... 346s add_na = FALSE 346s mode: integer 346s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 346s add_na = TRUE 346s mode: integer 346s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 346s add_na = FALSE 346s mode: double 346s num [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 346s add_na = TRUE 346s mode: double 346s num [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 346s > 346s > 346s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 346s > # All NAs 346s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 346s > for (mode in c("logical", "integer", "double")) { 346s + x <- matrix(NA_real_, nrow = 10L, ncol = 5L) 346s + cat("mode: ", mode, "\n", sep = "") 346s + storage.mode(x) <- mode 346s + str(x) 346s + 346s + # Test with and without dimnames on x 346s + for (setDimnames in c(TRUE, FALSE)) { 346s + if (setDimnames) dimnames(x) <- dimnames 346s + else dimnames(x) <- NULL 346s + # Check names attribute 346s + for (useNames in c(TRUE, FALSE)) { 346s + # Row/column ranges 346s + r0 <- rowCumsums_R(x, useNames = useNames) 346s + r1 <- rowCumsums(x, useNames = useNames) 346s + r2 <- t(colCumsums(t(x), useNames = useNames)) 346s + stopifnot(all.equal(r1, r2)) 346s + stopifnot(all.equal(r1, r0)) 346s + stopifnot(all.equal(r2, r0)) 346s + } # for (useNames ...) 346s + } # for (setDimnames ...) 346s + } # for (mode ...) 346s mode: logical 346s logi [1:10, 1:5] NA NA NA NA NA NA ... 346s mode: integer 346s int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 346s mode: double 346s num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 346s > 346s > 346s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 346s > # A 1x1 matrix 346s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 346s > dimnames <- list("a", "A") # to check dimnames attribute 346s > for (mode in c("logical", "integer", "double")) { 346s + x <- matrix(0, nrow = 1L, ncol = 1L) 346s + cat("mode: ", mode, "\n", sep = "") 346s + storage.mode(x) <- mode 346s + str(x) 346s + 346s + r0 <- rowCumsums_R(x) 346s + r1 <- rowCumsums(x) 346s + r2 <- t(colCumsums(t(x))) 346s + stopifnot(all.equal(r1, r2)) 346s + stopifnot(all.equal(r1, r0)) 346s + stopifnot(all.equal(r2, r0)) 346s + 346s + # Check dimnames attribute 346s + dimnames(x) <- dimnames 346s + # r0 <- rowCumsums_R(x) 346s + # > r0 346s + # a 346s + # [1,] 0 346s + r1 <- rowCumsums(x, useNames = TRUE) 346s + r2 <- t(colCumsums(t(x), useNames = TRUE)) 346s + stopifnot(identical(dimnames(r1), dimnames)) 346s + stopifnot(identical(dimnames(r2), dimnames)) 346s + dimnames(x) <- NULL 346s + } 346s mode: logical 346s logi [1, 1] FALSE 346s mode: integer 346s int [1, 1] 0 346s mode: double 346s num [1, 1] 0 346s > 346s > 346s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 346s > # Corner cases 346s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 346s > names <- LETTERS[1:5] # to check dimnames attribute 346s > for (mode in c("logical", "integer", "double")) { 346s + cat("mode: ", mode, "\n", sep = "") 346s + value <- 0 346s + storage.mode(value) <- mode 346s + value2 <- value 346s + if (mode == "logical") value2 <- 0L 346s + 346s + # A 0x0 matrix 346s + x <- matrix(value, nrow = 0L, ncol = 0L) 346s + str(x) 346s + r0 <- matrix(value2, nrow = nrow(x), ncol = ncol(x)) 346s + r1 <- rowCumsums(x) 346s + r2 <- t(colCumsums(t(x))) 346s + stopifnot(all.equal(r1, r2)) 346s + stopifnot(all.equal(r1, r0)) 346s + stopifnot(all.equal(r2, r0)) 346s + 346s + # A 0xK matrix 346s + x <- matrix(value, nrow = 0L, ncol = 5L) 346s + str(x) 346s + colnames <- LETTERS[1:5] 346s + # Test with and without dimnames on x 346s + for (setDimnames in c(TRUE, FALSE)) { 346s + if (setDimnames) colnames(x) <- colnames 346s + else dimnames(x) <- NULL 346s + # Check names attribute 346s + for (useNames in c(TRUE, FALSE)) { 346s + r0 <- rowCumsums_R(x, useNames = useNames) 346s + r1 <- rowCumsums(x, useNames = useNames) 346s + r2 <- t(rowCumsums(t(x), useNames = useNames)) 346s + stopifnot(all.equal(r1, r2)) 346s + stopifnot(all.equal(r1, r0)) 346s + stopifnot(all.equal(r2, r0)) 346s + } # for (useNames ...) 346s + } # for (setDimnames ...) 346s + 346s + # A Nx0 matrix 346s + x <- matrix(value, nrow = 5L, ncol = 0L) 346s + str(x) 346s + rownames <- LETTERS[1:5] 346s + # Test with and without dimnames on x 346s + for (setDimnames in c(TRUE, FALSE)) { 346s + if (setDimnames) rownames(x) <- rownames 346s + else dimnames(x) <- NULL 346s + # Check names attribute 346s + for (useNames in c(TRUE, FALSE)) { 346s + r0 <- rowCumsums_R(x, useNames = useNames) 346s + r1 <- rowCumsums(x, useNames = useNames) 346s + r2 <- t(rowCumsums(t(x), useNames = useNames)) 346s + stopifnot(all.equal(r1, r2)) 346s + stopifnot(all.equal(r1, r0)) 346s + stopifnot(all.equal(r2, r0)) 346s + } # for (useNames ...) 346s + } # for (setDimnames ...) 346s + } # for (mode ...) 346s mode: logical 346s logi[0 , 0 ] 346s logi[0 , 1:5] 346s logi[1:5, 0 ] 346s mode: integer 346s int[0 , 0 ] 346s int[0 , 1:5] 346s int[1:5, 0 ] 346s mode: double 346s num[0 , 0 ] 346s num[0 , 1:5] 346s num[1:5, 0 ] 346s > 346s 346s R version 4.4.3 (2025-02-28) -- "Trophy Case" 346s Copyright (C) 2025 The R Foundation for Statistical Computing 346s Platform: aarch64-unknown-linux-gnu 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 > 346s > rowCumsums_R <- function(x, ..., useNames = TRUE) { 346s + suppressWarnings({ 346s + y <- t(apply(x, MARGIN = 1L, FUN = cumsum)) 346s + }) 346s + 346s + # Preserve dimnames attribute? 346s + dim(y) <- dim(x) 346s + dimnames(y) <- if (useNames) dimnames(x) else NULL 346s + 346s + y 346s + } 346s > 346s > 346s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 346s > # Subsetted tests 346s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 346s > source("utils/validateIndicesFramework.R") 346s > x <- matrix(runif(6 * 6, min = -3, max = 3), nrow = 6, ncol = 6) 346s > storage.mode(x) <- "integer" 346s > 346s > # To check dimnames attribute 346s > dimnames <- list(letters[1:6], LETTERS[1:6]) 346s > 346s > # Test with and without dimnames on x 346s > for (setDimnames in c(TRUE, FALSE)) { 346s + if (setDimnames) dimnames(x) <- dimnames 346s + else dimnames(x) <- NULL 346s + for (rows in index_cases) { 346s + for (cols in index_cases) { 346s + # Check names attribute 346s + for (useNames in c(TRUE, FALSE)) { 346s + validateIndicesTestMatrix(x, rows, cols, 346s + ftest = rowCumsums, fsure = rowCumsums_R, useNames = useNames) 346s + validateIndicesTestMatrix(x, rows, cols, 346s + ftest = function(x, rows, cols, ..., useNames) { 346s + t(colCumsums(t(x), rows = cols, cols = rows, useNames = useNames)) 346s + }, fsure = rowCumsums_R, useNames = useNames) 346s + } 346s + } 346s + } 346s + } 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: aarch64-unknown-linux-gnu 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 > rowDiffs_R <- function(x, lag = 1L, differences = 1L, ..., useNames = TRUE) { 347s + ncol2 <- ncol(x) - lag * differences 347s + if (ncol2 <= 0) { 347s + y <- matrix(x[integer(0L)], nrow = nrow(x), ncol = 0L) 347s + # Preserve names attribute 347s + if (useNames && !is.null(rownames(x))) rownames(y) <- rownames(x) 347s + return(y) 347s + } 347s + suppressWarnings({ 347s + y <- apply(x, MARGIN = 1L, FUN = diff, lag = lag, differences = differences) 347s + }) 347s + y <- t(y) 347s + 347s + # Preserve dimnames attribute 347s + dim(y) <- c(nrow(x), ncol2) 347s + if (useNames && !is.null(dimnames(x))) { 347s + colnames <- colnames(x) 347s + if (!is.null(colnames)) { 347s + len <- length(colnames) 347s + colnames <- colnames[(len - ncol2 + 1):len] 347s + } 347s + dimnames(y) <- list(rownames(x), colnames) 347s + } 347s + else dimnames(y) <- NULL 347s + 347s + y 347s + } 347s > 347s > 347s > set.seed(0x42) 347s > 347s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 347s > # With and without some NAs 347s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 347s > for (mode in c("integer", "double")) { 347s + cat("mode: ", mode, "\n", sep = "") 347s + 347s + for (add_na in c(FALSE, TRUE)) { 347s + cat("add_na = ", add_na, "\n", sep = "") 347s + 347s + x <- matrix(sample(10 * 8) + 0.1, nrow = 10L, ncol = 8L) 347s + if (add_na) { 347s + x[3:7, c(2, 4)] <- NA_real_ 347s + } 347s + storage.mode(x) <- mode 347s + str(x) 347s + 347s + dimnames <- list(letters[1:10], LETTERS[1:8]) 347s + 347s + # Test with and without dimnames on x 347s + for (setDimnames in c(TRUE, FALSE)) { 347s + if (setDimnames) dimnames(x) <- dimnames 347s + else dimnames(x) <- NULL 347s + # Check dimnames attribute 347s + for (useNames in c(TRUE, FALSE)) { 347s + for (lag in 1:4) { 347s + for (differences in 1:3) { 347s + cat(sprintf("mode: %s, lag = %d, differences = %d\n", 347s + mode, lag, differences)) 347s + # Row/column ranges 347s + r0 <- rowDiffs_R(x, lag = lag, differences = differences, useNames = useNames) 347s + r1 <- rowDiffs(x, lag = lag, differences = differences, useNames = useNames) 347s + r2 <- t(colDiffs(t(x), lag = lag, differences = differences, useNames = useNames)) 347s + stopifnot(all.equal(r1, r0)) 347s + stopifnot(all.equal(r2, r0)) 347s + stopifnot(all.equal(r1, r2)) 347s + } 347s + } 347s + } # for (useNames ...) 347s + } # for (setDimnames ...) 347s + } # for (add_na ...) 347s + } # for (mode ...) 348s mode: integer 348s add_na = FALSE 348s int [1:10, 1:8] 68 26 29 47 48 10 1 38 16 40 ... 348s mode: integer, lag = 1, differences = 1 348s mode: integer, lag = 1, differences = 2 348s mode: integer, lag = 1, differences = 3 348s mode: integer, lag = 2, differences = 1 348s mode: integer, lag = 2, differences = 2 348s mode: integer, lag = 2, differences = 3 348s mode: integer, lag = 3, differences = 1 348s mode: integer, lag = 3, differences = 2 348s mode: integer, lag = 3, differences = 3 348s mode: integer, lag = 4, differences = 1 348s mode: integer, lag = 4, differences = 2 348s mode: integer, lag = 4, differences = 3 348s mode: integer, lag = 1, differences = 1 348s mode: integer, lag = 1, differences = 2 348s mode: integer, lag = 1, differences = 3 348s mode: integer, lag = 2, differences = 1 348s mode: integer, lag = 2, differences = 2 348s mode: integer, lag = 2, differences = 3 348s mode: integer, lag = 3, differences = 1 348s mode: integer, lag = 3, differences = 2 348s mode: integer, lag = 3, differences = 3 348s mode: integer, lag = 4, differences = 1 348s mode: integer, lag = 4, differences = 2 348s mode: integer, lag = 4, differences = 3 348s mode: integer, lag = 1, differences = 1 348s mode: integer, lag = 1, differences = 2 348s mode: integer, lag = 1, differences = 3 348s mode: integer, lag = 2, differences = 1 348s mode: integer, lag = 2, differences = 2 348s mode: integer, lag = 2, differences = 3 348s mode: integer, lag = 3, differences = 1 348s mode: integer, lag = 3, differences = 2 348s mode: integer, lag = 3, differences = 3 348s mode: integer, lag = 4, differences = 1 348s mode: integer, lag = 4, differences = 2 348s mode: integer, lag = 4, differences = 3 348s mode: integer, lag = 1, differences = 1 348s mode: integer, lag = 1, differences = 2 348s mode: integer, lag = 1, differences = 3 348s mode: integer, lag = 2, differences = 1 348s mode: integer, lag = 2, differences = 2 348s mode: integer, lag = 2, differences = 3 348s mode: integer, lag = 3, differences = 1 348s mode: integer, lag = 3, differences = 2 348s mode: integer, lag = 3, differences = 3 348s mode: integer, lag = 4, differences = 1 348s mode: integer, lag = 4, differences = 2 348s mode: integer, lag = 4, differences = 3 348s add_na = TRUE 348s int [1:10, 1:8] 80 71 7 52 79 22 31 10 29 63 ... 348s mode: integer, lag = 1, differences = 1 348s mode: integer, lag = 1, differences = 2 348s mode: integer, lag = 1, differences = 3 348s mode: integer, lag = 2, differences = 1 348s mode: integer, lag = 2, differences = 2 348s mode: integer, lag = 2, differences = 3 348s mode: integer, lag = 3, differences = 1 348s mode: integer, lag = 3, differences = 2 348s mode: integer, lag = 3, differences = 3 348s mode: integer, lag = 4, differences = 1 348s mode: integer, lag = 4, differences = 2 348s mode: integer, lag = 4, differences = 3 348s mode: integer, lag = 1, differences = 1 348s mode: integer, lag = 1, differences = 2 348s mode: integer, lag = 1, differences = 3 348s mode: integer, lag = 2, differences = 1 348s mode: integer, lag = 2, differences = 2 348s mode: integer, lag = 2, differences = 3 348s mode: integer, lag = 3, differences = 1 348s mode: integer, lag = 3, differences = 2 348s mode: integer, lag = 3, differences = 3 348s mode: integer, lag = 4, differences = 1 348s mode: integer, lag = 4, differences = 2 348s mode: integer, lag = 4, differences = 3 348s mode: integer, lag = 1, differences = 1 348s mode: integer, lag = 1, differences = 2 348s mode: integer, lag = 1, differences = 3 348s mode: integer, lag = 2, differences = 1 348s mode: integer, lag = 2, differences = 2 348s mode: integer, lag = 2, differences = 3 348s mode: integer, lag = 3, differences = 1 348s mode: integer, lag = 3, differences = 2 348s mode: integer, lag = 3, differences = 3 348s mode: integer, lag = 4, differences = 1 348s mode: integer, lag = 4, differences = 2 348s mode: integer, lag = 4, differences = 3 348s mode: integer, lag = 1, differences = 1 348s mode: integer, lag = 1, differences = 2 348s mode: integer, lag = 1, differences = 3 348s mode: integer, lag = 2, differences = 1 348s mode: integer, lag = 2, differences = 2 348s mode: integer, lag = 2, differences = 3 348s mode: integer, lag = 3, differences = 1 348s mode: integer, lag = 3, differences = 2 348s mode: integer, lag = 3, differences = 3 348s mode: integer, lag = 4, differences = 1 348s mode: integer, lag = 4, differences = 2 348s mode: integer, lag = 4, differences = 3 348s mode: double 348s add_na = FALSE 348s 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 ... 348s mode: double, lag = 1, differences = 1 348s mode: double, lag = 1, differences = 2 348s mode: double, lag = 1, differences = 3 348s mode: double, lag = 2, differences = 1 348s mode: double, lag = 2, differences = 2 348s mode: double, lag = 2, differences = 3 348s mode: double, lag = 3, differences = 1 348s mode: double, lag = 3, differences = 2 348s mode: double, lag = 3, differences = 3 348s mode: double, lag = 4, differences = 1 348s mode: double, lag = 4, differences = 2 348s mode: double, lag = 4, differences = 3 348s mode: double, lag = 1, differences = 1 348s mode: double, lag = 1, differences = 2 348s mode: double, lag = 1, differences = 3 348s mode: double, lag = 2, differences = 1 348s mode: double, lag = 2, differences = 2 348s mode: double, lag = 2, differences = 3 348s mode: double, lag = 3, differences = 1 348s mode: double, lag = 3, differences = 2 348s mode: double, lag = 3, differences = 3 348s mode: double, lag = 4, differences = 1 348s mode: double, lag = 4, differences = 2 348s mode: double, lag = 4, differences = 3 348s mode: double, lag = 1, differences = 1 348s mode: double, lag = 1, differences = 2 348s mode: double, lag = 1, differences = 3 348s mode: double, lag = 2, differences = 1 348s mode: double, lag = 2, differences = 2 348s mode: double, lag = 2, differences = 3 348s mode: double, lag = 3, differences = 1 348s mode: double, lag = 3, differences = 2 348s mode: double, lag = 3, differences = 3 348s mode: double, lag = 4, differences = 1 348s mode: double, lag = 4, differences = 2 348s mode: double, lag = 4, differences = 3 348s mode: double, lag = 1, differences = 1 348s mode: double, lag = 1, differences = 2 348s mode: double, lag = 1, differences = 3 348s mode: double, lag = 2, differences = 1 348s mode: double, lag = 2, differences = 2 348s mode: double, lag = 2, differences = 3 348s mode: double, lag = 3, differences = 1 348s mode: double, lag = 3, differences = 2 348s mode: double, lag = 3, differences = 3 348s mode: double, lag = 4, differences = 1 348s mode: double, lag = 4, differences = 2 348s mode: double, lag = 4, differences = 3 348s add_na = TRUE 348s 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 ... 348s mode: double, lag = 1, differences = 1 348s mode: double, lag = 1, differences = 2 348s mode: double, lag = 1, differences = 3 348s mode: double, lag = 2, differences = 1 348s mode: double, lag = 2, differences = 2 348s mode: double, lag = 2, differences = 3 348s mode: double, lag = 3, differences = 1 348s mode: double, lag = 3, differences = 2 348s mode: double, lag = 3, differences = 3 348s mode: double, lag = 4, differences = 1 348s mode: double, lag = 4, differences = 2 348s mode: double, lag = 4, differences = 3 348s mode: double, lag = 1, differences = 1 348s mode: double, lag = 1, differences = 2 348s mode: double, lag = 1, differences = 3 348s mode: double, lag = 2, differences = 1 348s mode: double, lag = 2, differences = 2 348s mode: double, lag = 2, differences = 3 348s mode: double, lag = 3, differences = 1 348s mode: double, lag = 3, differences = 2 348s mode: double, lag = 3, differences = 3 348s mode: double, lag = 4, differences = 1 348s mode: double, lag = 4, differences = 2 348s mode: double, lag = 4, differences = 3 348s mode: double, lag = 1, differences = 1 348s mode: double, lag = 1, differences = 2 348s mode: double, lag = 1, differences = 3 348s mode: double, lag = 2, differences = 1 348s mode: double, lag = 2, differences = 2 348s mode: double, lag = 2, differences = 3 348s mode: double, lag = 3, differences = 1 348s mode: double, lag = 3, differences = 2 348s mode: double, lag = 3, differences = 3 348s mode: double, lag = 4, differences = 1 348s mode: double, lag = 4, differences = 2 348s mode: double, lag = 4, differences = 3 348s mode: double, lag = 1, differences = 1 348s mode: double, lag = 1, differences = 2 348s mode: double, lag = 1, differences = 3 348s mode: double, lag = 2, differences = 1 348s mode: double, lag = 2, differences = 2 348s mode: double, lag = 2, differences = 3 348s mode: double, lag = 3, differences = 1 348s mode: double, lag = 3, differences = 2 348s mode: double, lag = 3, differences = 3 348s mode: double, lag = 4, differences = 1 348s mode: double, lag = 4, differences = 2 348s mode: double, lag = 4, differences = 3 348s > 348s > 348s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 348s > # All NAs 348s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 348s > for (mode in c("integer", "double")) { 348s + cat("mode: ", mode, "\n", sep = "") 348s + x <- matrix(NA_real_, nrow = 10L, ncol = 5L) 348s + storage.mode(x) <- mode 348s + str(x) 348s + 348s + dimnames <- list(letters[1:10], LETTERS[1:5]) 348s + 348s + # Test with and without dimnames on x 348s + for (setDimnames in c(TRUE, FALSE)) { 348s + if (setDimnames) dimnames(x) <- dimnames 348s + else dimnames(x) <- NULL 348s + # Check dimnames attribute 348s + for (useNames in c(TRUE, FALSE)) { 348s + r0 <- rowDiffs_R(x, useNames = useNames) 348s + r1 <- rowDiffs(x, useNames = useNames) 348s + r2 <- t(colDiffs(t(x), useNames = useNames)) 348s + stopifnot(all.equal(r1, r0)) 348s + stopifnot(all.equal(r2, r0)) 348s + stopifnot(all.equal(r1, r2)) 348s + } # for (useNames ...) 348s + } # for (setDimnames ...) 348s + } # for (mode ...) 348s mode: integer 348s int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 348s mode: double 348s num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 348s > 348s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 348s > # A 1x1 matrix 348s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 348s > x <- matrix(0, nrow = 1L, ncol = 1L) 348s > dimnames <- list("a", "A") 348s > # Test with and without dimnames on x 348s > for (setDimnames in c(TRUE, FALSE)) { 348s + if (setDimnames) dimnames(x) <- dimnames 348s + else dimnames(x) <- NULL 348s + # Check dimnames attribute 348s + for (useNames in c(TRUE, FALSE)) { 348s + r0 <- rowDiffs_R(x, useNames = useNames) 348s + r1 <- rowDiffs(x, useNames = useNames) 348s + r2 <- t(colDiffs(t(x), useNames = useNames)) 348s + stopifnot(all.equal(r1, r0)) 348s + stopifnot(all.equal(r2, r0)) 348s + stopifnot(all.equal(r1, r2)) 348s + } # for (useNames ...) 348s + } # for (setDimnames ...) 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: aarch64-unknown-linux-gnu 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 > rowDiffs_R <- function(x, lag = 1L, differences = 1L, ..., useNames = TRUE) { 348s + ncol2 <- ncol(x) - lag * differences 348s + if (ncol2 <= 0) { 348s + y <- matrix(x[integer(0L)], nrow = nrow(x), ncol = 0L) 348s + # Preserve names attribute 348s + if (useNames && !is.null(rownames(x))) rownames(y) <- rownames(x) 348s + return(y) 348s + } 348s + suppressWarnings({ 348s + y <- apply(x, MARGIN = 1L, FUN = diff, lag = lag, differences = differences) 348s + }) 348s + y <- t(y) 348s + 348s + # Preserve dimnames attribute 348s + dim(y) <- c(nrow(x), ncol2) 348s + if (useNames && !is.null(dimnames(x))) { 348s + colnames <- colnames(x) 348s + if (!is.null(colnames)) { 348s + len <- length(colnames) 348s + colnames <- colnames[(len - ncol2 + 1):len] 348s + } 348s + dimnames(y) <- list(rownames(x), colnames) 348s + } 348s + else dimnames(y) <- NULL 348s + 348s + y 348s + } 348s > 348s > 348s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 348s > # Subsetted tests 348s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 348s > source("utils/validateIndicesFramework.R") 348s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 348s > storage.mode(x) <- "integer" 348s > 348s > # To check dimnames attribute 348s > dimnames <- list(letters[1:6], LETTERS[1:6]) 348s > 348s > # Test with and without dimnames on x 348s > for (setDimnames in c(TRUE, FALSE)) { 348s + if (setDimnames) dimnames(x) <- dimnames 348s + else dimnames(x) <- NULL 348s + 348s + count <- 0L 348s + for (rows in index_cases) { 348s + for (cols in index_cases) { 348s + count <- count + 1L 348s + for (lag in 1:2) { 348s + for (differences in 1:3) { 348s + # Check dimnames attribute 348s + useNames <- c(TRUE, FALSE) 348s + useNames <- useNames[count %% length(useNames) + 1] 348s + validateIndicesTestMatrix(x, rows, cols, 348s + ftest = rowDiffs, fsure = rowDiffs_R, 348s + lag = lag, differences = differences, useNames = useNames) 348s + validateIndicesTestMatrix(x, rows, cols, 348s + ftest = function(x, rows, cols, ..., useNames) { 348s + t(colDiffs(t(x), rows = cols, cols = rows, ..., useNames = useNames)) 348s + }, fsure = rowDiffs_R, 348s + lag = lag, differences = differences, useNames = useNames) 348s + } 348s + } 348s + } 348s + } 348s + } 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: aarch64-unknown-linux-gnu 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 > rowIQRs_R <- function(x, na.rm = FALSE, ..., useNames = TRUE) { 351s + quantile_na <- function(x, ..., na.rm = FALSE) { 351s + if (!na.rm && anyMissing(x)) 351s + return(c(NA_real_, NA_real_)) 351s + quantile(x, ..., na.rm = na.rm) 351s + } 351s + q <- apply(x, MARGIN = 1L, FUN = quantile_na, 351s + probs = c(0.25, 0.75), na.rm = na.rm) 351s + rownames(q) <- NULL # Not needed anymore 351s + 351s + # Preserve names attribute 351s + dim(q) <- c(2L, nrow(x)) 351s + colnames(q) <- if (useNames) rownames(x) else NULL 351s + 351s + q[2L, , drop = TRUE] - q[1L, , drop = TRUE] 351s + } 351s > 351s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 351s > # Test with multiple quantiles 351s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 351s > for (mode in c("integer", "double")) { 351s + cat("mode: ", mode, "\n", sep = "") 351s + x <- matrix(1:100 + 0.1, nrow = 10, ncol = 10) 351s + storage.mode(x) <- mode 351s + str(x) 351s + 351s + # To check names attribute 351s + dimnames <- list(letters[1:10], LETTERS[1:10]) 351s + 351s + for (add_na in c(FALSE, TRUE)) { 351s + if (add_na) { 351s + x[3:5, 6:9] <- NA 351s + } 351s + # Test with and without dimnames on x 351s + for (setDimnames in c(TRUE, FALSE)) { 351s + if (setDimnames) dimnames(x) <- dimnames 351s + else dimnames(x) <- NULL 351s + for (na.rm in c(FALSE, TRUE)) { 351s + # Check names attribute 351s + for (useNames in c(TRUE, FALSE)) { 351s + probs <- c(0, 0.5, 1) 351s + q0 <- rowIQRs_R(x, na.rm = na.rm, useNames = useNames) 351s + print(q0) 351s + q1 <- rowIQRs(x, na.rm = na.rm, useNames = useNames) 351s + print(q1) 351s + stopifnot(all.equal(q1, q0)) 351s + q2 <- colIQRs(t(x), na.rm = na.rm, useNames = useNames) 351s + stopifnot(all.equal(q2, q0)) 351s + 351s + q <- iqr(x[3, ], na.rm = na.rm) 351s + print(q) 351s + } # for (useNames ...) 351s + } # for (na.rm ...) 351s + } # for (setDimnames ...) 351s + } # for (add_na ...) 351s + } # for (mode ...) 351s mode: integer 351s int [1:10, 1:10] 1 2 3 4 5 6 7 8 9 10 ... 351s a b c d e f g h i j 351s 45 45 45 45 45 45 45 45 45 45 351s a b c d e f g h i j 351s 45 45 45 45 45 45 45 45 45 45 351s [1] 45 351s [1] 45 45 45 45 45 45 45 45 45 45 351s [1] 45 45 45 45 45 45 45 45 45 45 351s [1] 45 351s a b c d e f g h i j 351s 45 45 45 45 45 45 45 45 45 45 351s a b c d e f g h i j 351s 45 45 45 45 45 45 45 45 45 45 351s [1] 45 351s [1] 45 45 45 45 45 45 45 45 45 45 351s [1] 45 45 45 45 45 45 45 45 45 45 351s [1] 45 351s [1] 45 45 45 45 45 45 45 45 45 45 351s [1] 45 45 45 45 45 45 45 45 45 45 351s [1] 45 351s [1] 45 45 45 45 45 45 45 45 45 45 351s [1] 45 45 45 45 45 45 45 45 45 45 351s [1] 45 351s [1] 45 45 45 45 45 45 45 45 45 45 351s [1] 45 45 45 45 45 45 45 45 45 45 351s [1] 45 351s [1] 45 45 45 45 45 45 45 45 45 45 351s [1] 45 45 45 45 45 45 45 45 45 45 351s [1] 45 351s a b c d e f g h i j 351s 45 45 NA NA NA 45 45 45 45 45 351s a b c d e f g h i j 351s 45 45 NA NA NA 45 45 45 45 45 351s [1] NA 351s [1] 45 45 NA NA NA 45 45 45 45 45 351s [1] 45 45 NA NA NA 45 45 45 45 45 351s [1] NA 351s a b c d e f g h i j 351s 45 45 25 25 25 45 45 45 45 45 351s a b c d e f g h i j 351s 45 45 25 25 25 45 45 45 45 45 351s [1] 25 351s [1] 45 45 25 25 25 45 45 45 45 45 351s [1] 45 45 25 25 25 45 45 45 45 45 351s [1] 25 351s [1] 45 45 NA NA NA 45 45 45 45 45 351s [1] 45 45 NA NA NA 45 45 45 45 45 351s [1] NA 351s [1] 45 45 NA NA NA 45 45 45 45 45 351s [1] 45 45 NA NA NA 45 45 45 45 45 351s [1] NA 351s [1] 45 45 25 25 25 45 45 45 45 45 351s [1] 45 45 25 25 25 45 45 45 45 45 351s [1] 25 351s [1] 45 45 25 25 25 45 45 45 45 45 351s [1] 45 45 25 25 25 45 45 45 45 45 351s [1] 25 351s mode: double 351s 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 ... 351s a b c d e f g h i j 351s 45 45 45 45 45 45 45 45 45 45 351s a b c d e f g h i j 351s 45 45 45 45 45 45 45 45 45 45 351s [1] 45 351s [1] 45 45 45 45 45 45 45 45 45 45 351s [1] 45 45 45 45 45 45 45 45 45 45 351s [1] 45 351s a b c d e f g h i j 351s 45 45 45 45 45 45 45 45 45 45 351s a b c d e f g h i j 351s 45 45 45 45 45 45 45 45 45 45 351s [1] 45 351s [1] 45 45 45 45 45 45 45 45 45 45 351s [1] 45 45 45 45 45 45 45 45 45 45 351s [1] 45 351s [1] 45 45 45 45 45 45 45 45 45 45 351s [1] 45 45 45 45 45 45 45 45 45 45 351s [1] 45 351s [1] 45 45 45 45 45 45 45 45 45 45 351s [1] 45 45 45 45 45 45 45 45 45 45 351s [1] 45 351s [1] 45 45 45 45 45 45 45 45 45 45 351s [1] 45 45 45 45 45 45 45 45 45 45 351s [1] 45 351s [1] 45 45 45 45 45 45 45 45 45 45 351s [1] 45 45 45 45 45 45 45 45 45 45 351s [1] 45 351s a b c d e f g h i j 351s 45 45 NA NA NA 45 45 45 45 45 351s a b c d e f g h i j 351s 45 45 NA NA NA 45 45 45 45 45 351s [1] NA 351s [1] 45 45 NA NA NA 45 45 45 45 45 351s [1] 45 45 NA NA NA 45 45 45 45 45 351s [1] NA 351s a b c d e f g h i j 351s 45 45 25 25 25 45 45 45 45 45 351s a b c d e f g h i j 351s 45 45 25 25 25 45 45 45 45 45 351s [1] 25 351s [1] 45 45 25 25 25 45 45 45 45 45 351s [1] 45 45 25 25 25 45 45 45 45 45 351s [1] 25 351s [1] 45 45 NA NA NA 45 45 45 45 45 351s [1] 45 45 NA NA NA 45 45 45 45 45 351s [1] NA 351s [1] 45 45 NA NA NA 45 45 45 45 45 351s [1] 45 45 NA NA NA 45 45 45 45 45 351s [1] NA 351s [1] 45 45 25 25 25 45 45 45 45 45 351s [1] 45 45 25 25 25 45 45 45 45 45 351s [1] 25 351s [1] 45 45 25 25 25 45 45 45 45 45 351s [1] 45 45 25 25 25 45 45 45 45 45 351s [1] 25 351s > 351s > 351s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 351s > # Test corner cases 351s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 351s > for (mode in c("integer", "double")) { 351s + cat("mode: ", mode, "\n", sep = "") 351s + # Empty vectors 351s + x <- integer(0L) 351s + storage.mode(x) <- mode 351s + str(x) 351s + q <- iqr(x) 351s + print(q) 351s + stopifnot(identical(q, NA_real_)) 351s + 351s + # Scalar 351s + x <- 1L 351s + storage.mode(x) <- mode 351s + str(x) 351s + q <- iqr(x) 351s + str(q) 351s + stopifnot(identical(q, 0)) 351s + } 351s mode: integer 351s int(0) 351s [1] NA 351s int 1 351s num 0 351s mode: double 351s num(0) 351s [1] NA 351s num 1 351s num 0 351s > 351s > 351s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 351s > # Single row matrices 351s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 351s > x <- matrix(1, nrow = 1L, ncol = 2L) 351s > dimnames <- list("a", LETTERS[1:2]) 351s > # Test with and without dimnames on x 351s > for (setDimnames in c(TRUE, FALSE)) { 351s + if (setDimnames) dimnames(x) <- dimnames 351s + else dimnames(x) <- NULL 351s + # Check names attribute 351s + for (useNames in c(TRUE, FALSE)) { 351s + q0 <- rowIQRs_R(x, useNames = useNames) 351s + q1 <- rowIQRs(x, useNames = useNames) 351s + q2 <- colIQRs(t(x), useNames = useNames) 351s + stopifnot(all.equal(q0, q1)) 351s + stopifnot(all.equal(q0, q2)) 351s + } 351s + } 351s > 351s > x <- matrix(1, nrow = 2L, ncol = 1L) 351s > q <- colIQRs(x) 351s > stopifnot(identical(q, 0)) 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: aarch64-unknown-linux-gnu 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 > rowIQRs_R <- function(x, na.rm = FALSE, ..., useNames = TRUE) { 351s + quantile_na <- function(x, ..., na.rm = FALSE) { 351s + if (!na.rm && anyMissing(x)) 351s + return(c(NA_real_, NA_real_)) 351s + quantile(x, ..., na.rm = na.rm) 351s + } 351s + q <- apply(x, MARGIN = 1L, FUN = quantile_na, 351s + probs = c(0.25, 0.75), na.rm = na.rm) 351s + rownames(q) <- NULL # Not needed anymore 351s + 351s + # Preserve names attribute 351s + dim(q) <- c(2L, nrow(x)) 351s + colnames(q) <- if (useNames) rownames(x) else NULL 351s + 351s + q[2L, , drop = TRUE] - q[1L, , drop = TRUE] 351s + } 351s > 351s > 351s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 351s > # Subsetted tests 351s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 351s > source("utils/validateIndicesFramework.R") 351s > x <- runif(6, min = -6, max = 6) 351s > for (idxs in index_cases) { 351s + for (na.rm in c(TRUE, FALSE)) { 351s + validateIndicesTestVector(x, idxs, ftest = iqr, fsure = function(x, na.rm) { 351s + dim(x) <- c(1L, length(x)) 351s + rowIQRs_R(x, na.rm = na.rm) 351s + }, na.rm = na.rm) 351s + } 351s + } 351s > 351s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 351s > 351s > # To check names attribute 351s > dimnames <- list(letters[1:6], LETTERS[1:6]) 351s > 351s > # Test with and without dimnames on x 351s > for (setDimnames in c(TRUE, FALSE)) { 351s + if (setDimnames) dimnames(x) <- dimnames 351s + else dimnames(x) <- NULL 351s + 351s + count <- 0L 351s + for (rows in index_cases) { 351s + for (cols in index_cases) { 351s + count <- count + 1L 351s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 351s + useNames <- c(TRUE, FALSE) 351s + useNames <- useNames[count %% length(useNames) + 1] 351s + 351s + validateIndicesTestMatrix(x, rows, cols, 351s + ftest = rowIQRs, fsure = rowIQRs_R, 351s + na.rm = na.rm, useNames = useNames) 351s + validateIndicesTestMatrix(x, rows, cols, 351s + fcoltest = colIQRs, fsure = rowIQRs_R, 351s + na.rm = na.rm, useNames = useNames) 351s + } 351s + } 351s + } 353s > 353s 353s R version 4.4.3 (2025-02-28) -- "Trophy Case" 353s Copyright (C) 2025 The R Foundation for Statistical Computing 353s Platform: aarch64-unknown-linux-gnu 353s 353s R is free software and comes with ABSOLUTELY NO WARRANTY. 353s You are welcome to redistribute it under certain conditions. 353s Type 'license()' or 'licence()' for distribution details. 353s 353s R is a collaborative project with many contributors. 353s Type 'contributors()' for more information and 353s 'citation()' on how to cite R or R packages in publications. 353s 353s Type 'demo()' for some demos, 'help()' for on-line help, or 353s 'help.start()' for an HTML browser interface to help. 353s Type 'q()' to quit R. 353s 353s > # Test inspired by the harmonic mean example in R-help 353s > # thread '[R] Beyond double-precision?' on May 9, 2009. 353s > 353s > library("matrixStats") 353s > library("stats") 353s > 353s > logSumExp0 <- function(lx) { 353s + idx_max <- which.max(lx) 353s + log1p(sum(exp(lx[-idx_max] - lx[idx_max]))) + lx[idx_max] 353s + } 353s > 353s > n <- 200L 353s > set.seed(1) 353s > 353s > for (mode in c("integer", "double")) { 353s + cat("mode: ", mode, "\n", sep = "") 353s + x <- matrix(runif(n, min = 1.0, max = 3.0), nrow = 20L) 353s + storage.mode(x) <- mode 353s + str(x) 353s + 353s + # The logarithm of the harmonic mean by rows 353s + y_h <- log(1 / rowMeans(1 / x)) 353s + str(y_h) 353s + 353s + lx_neg <- -log(x) 353s + 353s + y0 <- log(ncol(x)) - apply(lx_neg, MARGIN = 1L, FUN = logSumExp0) 353s + stopifnot(all.equal(y0, y_h)) 353s + 353s + y1 <- log(ncol(x)) - apply(lx_neg, MARGIN = 1L, FUN = logSumExp) 353s + stopifnot(all.equal(y1, y0)) 353s + 353s + y2 <- log(ncol(x)) - rowLogSumExps(lx_neg) 353s + stopifnot(all.equal(y2, y0)) 353s + 353s + y3 <- log(ncol(x)) - colLogSumExps(t(lx_neg)) 353s + stopifnot(all.equal(y3, y0)) 353s + 353s + 353s + # The logarithm of the harmonic mean by columns 353s + y_h <- log(1 / colMeans(1 / x)) 353s + str(y_h) 353s + 353s + y0 <- log(nrow(x)) - apply(lx_neg, MARGIN = 2L, FUN = logSumExp0) 353s + stopifnot(all.equal(y0, y_h)) 353s + 353s + y1 <- log(nrow(x)) - apply(lx_neg, MARGIN = 2L, FUN = logSumExp) 353s + stopifnot(all.equal(y1, y0)) 353s + 353s + y2 <- log(nrow(x)) - colLogSumExps(lx_neg) 353s + stopifnot(all.equal(y2, y0)) 353s + 353s + y3 <- log(nrow(x)) - rowLogSumExps(t(lx_neg)) 353s + stopifnot(all.equal(y3, y0)) 353s + 353s + # Testing names 353s + rownames(lx_neg) <- seq_len(nrow(x)) 353s + colnames(lx_neg) <- seq_len(ncol(x)) 353s + y2 <- rowLogSumExps(lx_neg, useNames = TRUE) 353s + stopifnot(identical(names(y2), rownames(lx_neg))) 353s + y3 <- colLogSumExps(t(lx_neg), useNames = TRUE) 353s + stopifnot(identical(names(y3), rownames(lx_neg))) 353s + } # for (mode ...) 353s mode: integer 353s int [1:20, 1:10] 1 1 2 2 1 2 2 2 2 1 ... 353s num [1:20] 0.357 0.223 0.223 0.288 0.511 ... 353s num [1:10] 0.322 0.223 0.322 0.255 0.255 ... 353s mode: double 353s num [1:20, 1:10] 1.54 1.44 2.03 1.54 1.36 ... 353s num [1:20] 0.526 0.466 0.734 0.638 0.604 ... 353s num [1:10] 0.627 0.582 0.617 0.474 0.418 ... 353s > 353s > 353s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 353s > # Corner cases 353s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 353s > ## Zero-size matrices 353s > lx <- matrix(numeric(0L), nrow = 0L, ncol = 0L) 353s > y <- rowLogSumExps(lx) 353s > print(y) 353s numeric(0) 353s > stopifnot(length(y) == nrow(lx)) 353s > 353s > y <- colLogSumExps(lx) 353s > print(y) 353s numeric(0) 353s > stopifnot(length(y) == ncol(lx)) 353s > 353s > ## Zero-height matrices 353s > lx <- matrix(numeric(0L), nrow = 0L, ncol = 5L) 353s > y <- rowLogSumExps(lx) 353s > print(y) 353s numeric(0) 353s > stopifnot(length(y) == nrow(lx)) 353s > 353s > y <- colLogSumExps(lx) 353s > print(y) 353s [1] -Inf -Inf -Inf -Inf -Inf 353s > stopifnot(length(y) == ncol(lx)) 353s > stopifnot(all(y == -Inf)) 353s > 353s > ## Zero-width matrices 353s > lx <- matrix(numeric(0L), nrow = 5L, ncol = 0L) 353s > y <- colLogSumExps(lx) 353s > print(y) 353s numeric(0) 353s > stopifnot(length(y) == ncol(lx)) 353s > 353s > y <- rowLogSumExps(lx) 353s > print(y) 353s [1] -Inf -Inf -Inf -Inf -Inf 353s > stopifnot(length(y) == nrow(lx)) 353s > stopifnot(all(y == -Inf)) 353s > 353s > 353s > ## Matrices with one element 353s > lx <- matrix(1.0, nrow = 1L, ncol = 1L) 353s > y <- rowLogSumExps(lx) 353s > print(y) 353s [1] 1 353s > stopifnot(length(y) == nrow(lx)) 353s > stopifnot(all(y == lx)) 353s > 353s > y <- colLogSumExps(lx) 353s > print(y) 353s [1] 1 353s > stopifnot(length(y) == ncol(lx)) 353s > stopifnot(all(y == lx)) 353s > 353s > ## All missing values 353s > lx <- matrix(NA_real_, nrow = 1L, ncol = 1L) 353s > y <- rowLogSumExps(lx, na.rm = TRUE) 353s > print(y) 353s [1] -Inf 353s > stopifnot(length(y) == nrow(lx)) 353s > stopifnot(identical(y, -Inf)) 353s > 353s > lx <- matrix(NA_real_, nrow = 1L, ncol = 1L) 353s > y <- colLogSumExps(lx, na.rm = TRUE) 353s > print(y) 353s [1] -Inf 353s > stopifnot(length(y) == ncol(lx)) 353s > stopifnot(identical(y, -Inf)) 353s > 353s > lx <- matrix(NA_real_, nrow = 2L, ncol = 2L) 353s > y <- rowLogSumExps(lx, na.rm = TRUE) 353s > print(y) 353s [1] -Inf -Inf 353s > stopifnot(length(y) == nrow(lx)) 353s > stopifnot(all(y == -Inf)) 353s > 353s > y <- rowLogSumExps(lx, na.rm = FALSE) 353s > print(y) 353s [1] NA NA 353s > stopifnot(length(y) == nrow(lx)) 353s > stopifnot(all(is.na(y) & !is.nan(y))) 353s > 353s > lx <- matrix(NA_real_, nrow = 2L, ncol = 2L) 353s > y <- colLogSumExps(lx, na.rm = TRUE) 353s > print(y) 353s [1] -Inf -Inf 353s > stopifnot(length(y) == ncol(lx)) 353s > stopifnot(all(y == -Inf)) 353s > 353s > y <- colLogSumExps(lx, na.rm = FALSE) 353s > print(y) 353s [1] NA NA 353s > stopifnot(length(y) == ncol(lx)) 353s > stopifnot(all(is.na(y) & !is.nan(y))) 353s > 353s > ## +Inf values 353s > lx <- matrix(c(1, 2, +Inf), nrow = 3L, ncol = 2L) 353s > y <- colLogSumExps(lx, na.rm = TRUE) 353s > print(y) 353s [1] Inf Inf 353s > stopifnot(length(y) == ncol(lx)) 353s > stopifnot(all(y == +Inf)) 353s > 353s > ## multiple -Inf values 353s > lx <- matrix(c(-Inf, -Inf), nrow = 2L, ncol = 3L) 353s > y <- rowLogSumExps(lx) 353s > print(y) 353s [1] -Inf -Inf 353s > stopifnot(length(y) == nrow(lx)) 353s > stopifnot(all(y == -Inf)) 353s > 353s > lx <- matrix(c(-Inf, 5, -Inf), nrow = 2L, ncol = 3L, byrow = TRUE) 353s > y <- rowLogSumExps(lx) 353s > print(y) 353s [1] 5 5 353s > stopifnot(length(y) == nrow(lx)) 353s > stopifnot(all(y == 5)) 353s > 353s > ## Bug report #104 (https://github.com/HenrikBengtsson/matrixStats/issues/104) 353s > ## (This would core dump on Windows) 353s > x <- matrix(0.0, nrow = 2L, ncol = 32762L) 353s > y <- colLogSumExps(x) 353s > str(y) 353s num [1:32762] 0.693 0.693 0.693 0.693 0.693 ... 353s > 353s > ## Bug report #120 (https://github.com/HenrikBengtsson/matrixStats/issues/120) 353s > ## (This would error if x had rownames/colnames and non-NULL rows/cols were 353s > ## used) 353s > x <- matrix(runif(6), nrow = 2L, ncol = 3L, 353s + dimnames = list(c("A", "B"), c("a", "b", "c"))) 353s > y <- colLogSumExps(x, cols = 3:1, useNames = TRUE) 353s > stopifnot(names(y) == c("c", "b", "a")) 353s > y <- rowLogSumExps(x, rows = 2, useNames = TRUE) 353s > stopifnot(names(y) == "B") 353s > 353s > 353s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 353s > # Check names attributes 353s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 353s > 353s > ## Create isFALSE() if running on an old version of R 353s > if (!exists("isFALSE", mode="function")) { 353s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 353s + } 353s > 353s > rowLogSumExps_R <- function(x, ..., useNames = TRUE) { 353s + res <- apply(x, MARGIN = 1L, FUN = function(rx, ...) { 353s + log(sum(exp(rx), ...)) 353s + }, ...) 353s + if (isFALSE(useNames)) names(res) <- NULL 353s + res 353s + } 353s > 353s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6L, ncol = 6L) 353s > 353s > # To check names attribute 353s > dimnames <- list(letters[1:6], LETTERS[1:6]) 353s > 353s > # Test with and without dimnames on x 353s > for (setDimnames in c(TRUE, FALSE)) { 353s + if (setDimnames) dimnames(x) <- dimnames 353s + else dimnames(x) <- NULL 353s + for (useNames in c(TRUE, FALSE)) { 353s + y0 <- rowLogSumExps_R(x, useNames = useNames) 353s + y1 <- rowLogSumExps(x, useNames = useNames) 353s + y2 <- colLogSumExps(t(x), useNames = useNames) 353s + stopifnot(all.equal(y1, y0)) 353s + stopifnot(all.equal(y2, y0)) 353s + } 353s + } 353s > 353s 353s R version 4.4.3 (2025-02-28) -- "Trophy Case" 353s Copyright (C) 2025 The R Foundation for Statistical Computing 353s Platform: aarch64-unknown-linux-gnu 353s 353s R is free software and comes with ABSOLUTELY NO WARRANTY. 353s You are welcome to redistribute it under certain conditions. 353s Type 'license()' or 'licence()' for distribution details. 353s 353s R is a collaborative project with many contributors. 353s Type 'contributors()' for more information and 353s 'citation()' on how to cite R or R packages in publications. 353s 353s Type 'demo()' for some demos, 'help()' for on-line help, or 353s 'help.start()' for an HTML browser interface to help. 353s Type 'q()' to quit R. 353s 353s > library("matrixStats") 353s > 353s > ## Create isFALSE() if running on an old version of R 353s > if (!exists("isFALSE", mode="function")) { 353s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 353s + } 353s > 353s > rowLogSumExps_R <- function(x, ..., useNames = TRUE) { 353s + res <- apply(x, MARGIN = 1L, FUN = function(rx, ...) { 353s + log(sum(exp(rx), ...)) 353s + }, ...) 353s + if (isFALSE(useNames)) names(res) <- NULL 353s + res 353s + } 353s > 353s > 353s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 353s > # Subsetted tests 353s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 353s > source("utils/validateIndicesFramework.R") 353s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 353s > 353s > # To check names attribute 353s > dimnames <- list(letters[1:6], LETTERS[1:6]) 353s > 353s > # Test with and without dimnames on x 353s > for (setDimnames in c(TRUE, FALSE)) { 353s + if (setDimnames) dimnames(x) <- dimnames 353s + else dimnames(x) <- NULL 353s + for (rows in index_cases) { 353s + for (cols in index_cases) { 353s + for (na.rm in c(TRUE, FALSE)) { 353s + for (useNames in c(TRUE, FALSE)) { 353s + validateIndicesTestMatrix(x, rows, cols, 353s + ftest = rowLogSumExps, 353s + fsure = rowLogSumExps_R, 353s + na.rm = na.rm, useNames = useNames) 353s + validateIndicesTestMatrix(x, rows, cols, 353s + fcoltest = colLogSumExps, 353s + fsure = rowLogSumExps_R, 353s + na.rm = na.rm, useNames = useNames) 353s + } 353s + } 353s + } 353s + } 353s + } 354s > 354s 354s R version 4.4.3 (2025-02-28) -- "Trophy Case" 354s Copyright (C) 2025 The R Foundation for Statistical Computing 354s Platform: aarch64-unknown-linux-gnu 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 > ## Always allow testing of the 'center' argument (as long as it's not defunct) 354s > options(matrixStats.center.onUse = "ignore") 354s > 354s > rowMads_R <- function(x, na.rm = FALSE, ..., useNames = TRUE) { 354s + suppressWarnings({ 354s + res <- apply(x, MARGIN = 1L, FUN = mad, na.rm = na.rm) 354s + }) 354s + if (!useNames) names(res) <- NULL 354s + res 354s + } 354s > 354s > colMads_R <- function(x, na.rm = FALSE, ..., useNames = TRUE) { 354s + suppressWarnings({ 354s + res <- apply(x, MARGIN = 2L, FUN = mad, na.rm = na.rm) 354s + }) 354s + if (!useNames) names(res) <- NULL 354s + res 354s + } 354s > 354s > rowMads_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) { 354s + center <- rowMedians(x, cols = cols, na.rm = na.rm, useNames = FALSE) 354s + rowMads(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 354s + } 354s > 354s > colMads_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) { 354s + center <- colMedians(x, rows = rows, na.rm = na.rm, useNames = FALSE) 354s + colMads(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 354s + } 354s > 354s > 354s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 354s > # A 3x3 matrix (no ties) 354s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 354s > for (mode in c("integer", "double")) { 354s + x <- matrix(c(1, 2, 3, 2, 3, 4, 3, 4, 5) + 0.1, nrow = 3, ncol = 3) 354s + cat("mode: ", mode, "\n", sep = "") 354s + storage.mode(x) <- mode 354s + str(x) 354s + 354s + # To check name attribute 354s + dimnames <- list(letters[1:3], LETTERS[1:3]) 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 + tx <- t(x) 354s + # Check names attribute 354s + for (useNames in c(TRUE, FALSE)) { 354s + cat("rowMads():\n") 354s + center <- rowMedians(x, na.rm = TRUE, useNames = useNames) 354s + r0 <- rowMads_R(x, na.rm = TRUE, useNames = useNames) 354s + r1 <- rowMads(x, na.rm = TRUE, useNames = useNames) 354s + r1b <- rowMads_center(x, na.rm = TRUE, useNames = useNames) 354s + r1c <- rowMads(x, center = center, na.rm = TRUE, useNames = useNames) 354s + r2 <- colMads(tx, na.rm = TRUE, useNames = useNames) 354s + r2b <- colMads_center(tx, na.rm = TRUE, useNames = useNames) 354s + stopifnot(all.equal(r1, r2)) 354s + stopifnot(all.equal(r1, r0)) 354s + stopifnot(all.equal(r1b, r1)) 354s + stopifnot(all.equal(r1c, r1)) 354s + stopifnot(all.equal(r2, r0)) 354s + stopifnot(all.equal(r2b, r2)) 354s + 354s + cat("colMads():\n") 354s + center <- colMedians(x, na.rm = TRUE, useNames = useNames) 354s + r0 <- colMads_R(x, na.rm = TRUE, useNames = useNames) 354s + r1 <- colMads(x, na.rm = TRUE, useNames = useNames) 354s + r1b <- colMads_center(x, na.rm = TRUE, useNames = useNames) 354s + r1c <- colMads(x, center = center, na.rm = TRUE, useNames = useNames) 354s + r2 <- rowMads(tx, na.rm = TRUE, useNames = useNames) 354s + r2b <- rowMads_center(tx, na.rm = TRUE, useNames = useNames) 354s + stopifnot(all.equal(r1, r2)) 354s + stopifnot(all.equal(r1, r0)) 354s + stopifnot(all.equal(r1b, r1)) 354s + stopifnot(all.equal(r1c, r1)) 354s + stopifnot(all.equal(r2, r0)) 354s + stopifnot(all.equal(r2b, r2)) 354s + } 354s + } 354s + } 354s mode: integer 354s int [1:3, 1:3] 1 2 3 2 3 4 3 4 5 354s rowMads(): 354s colMads(): 354s rowMads(): 354s colMads(): 354s rowMads(): 354s colMads(): 354s rowMads(): 354s colMads(): 354s mode: double 354s num [1:3, 1:3] 1.1 2.1 3.1 2.1 3.1 4.1 3.1 4.1 5.1 354s rowMads(): 354s colMads(): 354s rowMads(): 354s colMads(): 354s rowMads(): 354s colMads(): 354s rowMads(): 354s colMads(): 354s > 354s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 354s > # Ties: a 4x4 matrix 354s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 354s > for (mode in c("integer", "double")) { 354s + x <- matrix(c(1:4, 2:5, 3:6, 4:7) + 0.1, nrow = 4, ncol = 4) 354s + cat("mode: ", mode, "\n", sep = "") 354s + storage.mode(x) <- mode 354s + str(x) 354s + tx <- t(x) 354s + 354s + # To check name attribute 354s + dimnames <- list(letters[1:4], LETTERS[1:4]) 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 + tx <- t(x) 354s + # Check names attribute 354s + for (useNames in c(TRUE, FALSE)) { 354s + cat("rowMads():\n") 354s + r0 <- rowMads_R(x, na.rm = TRUE, useNames = useNames) 354s + r1 <- rowMads(x, na.rm = TRUE, useNames = useNames) 354s + r2 <- colMads(tx, na.rm = TRUE, useNames = useNames) 354s + stopifnot(all.equal(r1, r2)) 354s + stopifnot(all.equal(r1, r0)) 354s + stopifnot(all.equal(r2, r0)) 354s + 354s + cat("colMads():\n") 354s + r0 <- colMads_R(x, na.rm = TRUE, useNames = useNames) 354s + r1 <- colMads(x, na.rm = TRUE, useNames = useNames) 354s + r2 <- rowMads(tx, na.rm = TRUE, useNames = useNames) 354s + stopifnot(all.equal(r1, r2)) 354s + stopifnot(all.equal(r1, r0)) 354s + stopifnot(all.equal(r2, r0)) 354s + } 354s + } 354s + } 354s mode: integer 354s int [1:4, 1:4] 1 2 3 4 2 3 4 5 3 4 ... 354s rowMads(): 354s colMads(): 354s rowMads(): 354s colMads(): 354s rowMads(): 354s colMads(): 354s rowMads(): 354s colMads(): 354s mode: double 354s 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 ... 354s rowMads(): 354s colMads(): 354s rowMads(): 354s colMads(): 354s rowMads(): 354s colMads(): 354s rowMads(): 354s colMads(): 354s > tx <- NULL 354s > 354s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 354s > # No ties: a 3x3 matrix with an NA value 354s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 354s > for (mode in c("integer", "double")) { 354s + x <- matrix(c(1, 2, 3, 2, 3, 4, 3, 4, 5) + 0.1, nrow = 3, ncol = 3) 354s + x[2, 2] <- NA_real_ 354s + 354s + cat("mode: ", mode, "\n", sep = "") 354s + storage.mode(x) <- mode 354s + str(x) 354s + tx <- t(x) 354s + 354s + # To check name attribute 354s + dimnames <- list(letters[1:3], LETTERS[1:3]) 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 + tx <- t(x) 354s + # Check names attribute 354s + for (useNames in c(TRUE, FALSE)) { 354s + cat("rowMads():\n") 354s + r0 <- rowMads_R(x, na.rm = TRUE, useNames = useNames) 354s + r1 <- rowMads(x, na.rm = TRUE, useNames = useNames) 354s + r2 <- colMads(tx, na.rm = TRUE, useNames = useNames) 354s + stopifnot(all.equal(r1, r2)) 354s + stopifnot(all.equal(r1, r0)) 354s + stopifnot(all.equal(r2, r0)) 354s + 354s + cat("colMads():\n") 354s + r0 <- colMads_R(x, na.rm = TRUE, useNames = useNames) 354s + r1 <- colMads(x, na.rm = TRUE, useNames = useNames) 354s + r2 <- rowMads(tx, na.rm = TRUE, useNames = useNames) 354s + stopifnot(all.equal(r1, r2)) 354s + stopifnot(all.equal(r1, r0)) 354s + stopifnot(all.equal(r2, r0)) 354s + } 354s + } 354s + } 354s mode: integer 354s int [1:3, 1:3] 1 2 3 2 NA 4 3 4 5 354s rowMads(): 354s colMads(): 354s rowMads(): 354s colMads(): 354s rowMads(): 354s colMads(): 354s rowMads(): 354s colMads(): 354s mode: double 354s num [1:3, 1:3] 1.1 2.1 3.1 2.1 NA 4.1 3.1 4.1 5.1 354s rowMads(): 354s colMads(): 354s rowMads(): 354s colMads(): 354s rowMads(): 354s colMads(): 354s rowMads(): 354s colMads(): 354s > tx <- NULL 354s > 354s > 354s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 354s > # With and without some NAs 354s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 354s > for (add_na in c(FALSE, TRUE)) { 354s + cat("add_na = ", add_na, "\n", sep = "") 354s + 354s + x <- matrix(1:50, nrow = 10L, ncol = 5L) 354s + if (add_na) { 354s + x[3:7, c(2, 4)] <- NA_real_ 354s + } 354s + 354s + # To check name attribute 354s + dimnames <- list(letters[1:10], LETTERS[1:5]) 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 + tx <- t(x) 354s + # Row/column ranges 354s + for (na.rm in c(FALSE, TRUE)) { 354s + # Check names attribute 354s + for (useNames in c(TRUE, FALSE)) { 354s + cat("na.rm = ", na.rm, "\n", sep = "") 354s + cat("rowMads():\n") 354s + center <- rowMedians(x, na.rm = na.rm, useNames = useNames) 354s + r0 <- rowMads_R(x, na.rm = na.rm, useNames = useNames) 354s + r1 <- rowMads(x, na.rm = na.rm, useNames = useNames) 354s + r2 <- rowMads(x, center = center, na.rm = na.rm, useNames = useNames) 354s + r3 <- colMads(tx, na.rm = na.rm, useNames = useNames) 354s + stopifnot(all.equal(r1, r0)) 354s + stopifnot(all.equal(r2, r0)) 354s + stopifnot(all.equal(r2, r1)) 354s + stopifnot(all.equal(r3, r0)) 354s + stopifnot(all.equal(r3, r1)) 354s + stopifnot(all.equal(r3, r2)) 354s + 354s + cat("colMads():\n") 354s + center <- colMedians(x, na.rm = na.rm, useNames = useNames) 354s + r0 <- colMads_R(x, na.rm = na.rm, useNames = useNames) 354s + r1 <- colMads(x, na.rm = na.rm, useNames = useNames) 354s + r2 <- colMads(x, center = center, na.rm = na.rm, useNames = useNames) 354s + r3 <- rowMads(tx, na.rm = na.rm, useNames = useNames) 354s + stopifnot(all.equal(r1, r0)) 354s + stopifnot(all.equal(r2, r0)) 354s + stopifnot(all.equal(r2, r1)) 354s + stopifnot(all.equal(r3, r0)) 354s + stopifnot(all.equal(r3, r1)) 354s + stopifnot(all.equal(r3, r2)) 354s + } 354s + } 354s + } 354s + tx <- NULL 354s + } # for (add_na ...) 354s add_na = FALSE 354s na.rm = FALSE 354s rowMads(): 354s colMads(): 354s na.rm = FALSE 354s rowMads(): 354s colMads(): 354s na.rm = TRUE 354s rowMads(): 354s colMads(): 354s na.rm = TRUE 354s rowMads(): 354s colMads(): 354s na.rm = FALSE 354s rowMads(): 354s colMads(): 354s na.rm = FALSE 354s rowMads(): 354s colMads(): 354s na.rm = TRUE 354s rowMads(): 354s colMads(): 354s na.rm = TRUE 354s rowMads(): 354s colMads(): 354s add_na = TRUE 354s na.rm = FALSE 354s rowMads(): 354s colMads(): 354s na.rm = FALSE 354s rowMads(): 354s colMads(): 354s na.rm = TRUE 354s rowMads(): 354s colMads(): 354s na.rm = TRUE 354s rowMads(): 354s colMads(): 354s na.rm = FALSE 354s rowMads(): 354s colMads(): 354s na.rm = FALSE 354s rowMads(): 354s colMads(): 354s na.rm = TRUE 354s rowMads(): 354s colMads(): 354s na.rm = TRUE 354s rowMads(): 354s colMads(): 354s > 354s > 354s > 354s > 354s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 354s > # All NAs 354s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 354s > x <- matrix(NA_real_, nrow = 10L, ncol = 5L) 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 + tx <- t(x) 354s + # Row/column ranges 354s + for (na.rm in c(FALSE, TRUE)) { 354s + # Check names attribute 354s + for (useNames in c(TRUE, FALSE)) { 354s + cat("na.rm = ", na.rm, "\n", sep = "") 354s + r0 <- rowMads_R(x, na.rm = na.rm, useNames = useNames) 354s + if (na.rm) r0[is.na(r0)] <- NaN 354s + r1 <- rowMads(x, na.rm = na.rm, useNames = useNames) 354s + r2 <- colMads(tx, na.rm = na.rm, useNames = useNames) 354s + stopifnot(all.equal(r1, r0)) 354s + stopifnot(all.equal(r2, r0)) 354s + stopifnot(all.equal(r1, r2)) 354s + } 354s + } 354s + } 354s na.rm = FALSE 354s na.rm = FALSE 354s na.rm = TRUE 354s na.rm = TRUE 354s na.rm = FALSE 354s na.rm = FALSE 354s na.rm = TRUE 354s na.rm = TRUE 354s > tx <- NULL 354s > 354s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 354s > # A 1x1 matrix 354s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 354s > x <- matrix(0, nrow = 1L, ncol = 1L) 354s > dimnames <- list("a", "A") 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 + tx <- t(x) 354s + # Row/column ranges 354s + for (na.rm in c(FALSE, TRUE)) { 354s + # Check names attribute 354s + for (useNames in c(TRUE, FALSE)) { 354s + cat("na.rm = ", na.rm, "\n", sep = "") 354s + r0 <- rowMads_R(x, na.rm = na.rm, useNames = useNames) 354s + r1 <- rowMads(x, na.rm = na.rm, useNames = useNames) 354s + r2 <- colMads(tx, na.rm = na.rm, useNames = useNames) 354s + stopifnot(all.equal(r1, r0)) 354s + stopifnot(all.equal(r2, r0)) 354s + stopifnot(all.equal(r1, r2)) 354s + } 354s + } 354s + } 354s na.rm = FALSE 354s na.rm = FALSE 354s na.rm = TRUE 354s na.rm = TRUE 354s na.rm = FALSE 354s na.rm = FALSE 354s na.rm = TRUE 354s na.rm = TRUE 354s > 354s > 354s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 354s > # A 0x0 matrix 354s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 354s > x <- matrix(double(0), nrow = 0, ncol = 0) 354s > tx <- t(x) 354s > for (na.rm in c(FALSE, TRUE)) { 354s + cat("na.rm = ", na.rm, "\n", sep = "") 354s + r0 <- rowMads_R(x, na.rm = na.rm) 354s + r1 <- rowMads(x, na.rm = na.rm) 354s + r2 <- colMads(tx, na.rm = na.rm) 354s + stopifnot(all.equal(r1, r2)) 354s + stopifnot(all.equal(r1, r0)) 354s + stopifnot(all.equal(r2, r0)) 354s + } 354s na.rm = FALSE 354s na.rm = TRUE 354s > 355s 355s R version 4.4.3 (2025-02-28) -- "Trophy Case" 355s Copyright (C) 2025 The R Foundation for Statistical Computing 355s Platform: aarch64-unknown-linux-gnu 355s 355s R is free software and comes with ABSOLUTELY NO WARRANTY. 355s You are welcome to redistribute it under certain conditions. 355s Type 'license()' or 'licence()' for distribution details. 355s 355s R is a collaborative project with many contributors. 355s Type 'contributors()' for more information and 355s 'citation()' on how to cite R or R packages in publications. 355s 355s Type 'demo()' for some demos, 'help()' for on-line help, or 355s 'help.start()' for an HTML browser interface to help. 355s Type 'q()' to quit R. 355s 355s > library("matrixStats") 355s > 355s > ## Always allow testing of the 'center' argument (as long as it's not defunct) 355s > options(matrixStats.center.onUse = "ignore") 355s > 355s > rowMads_R <- function(x, na.rm = FALSE, ..., useNames = TRUE) { 355s + suppressWarnings({ 355s + res <- apply(x, MARGIN = 1L, FUN = mad, na.rm = na.rm) 355s + }) 355s + if (!useNames) names(res) <- NULL 355s + res 355s + } 355s > 355s > colMads_R <- function(x, na.rm = FALSE, ..., useNames = TRUE) { 355s + suppressWarnings({ 355s + res <- apply(x, MARGIN = 2L, FUN = mad, na.rm = na.rm) 355s + }) 355s + if (!useNames) names(res) <- NULL 355s + res 355s + } 355s > 355s > rowMads_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) { 355s + center <- rowMedians(x, cols = cols, na.rm = na.rm, useNames = FALSE) 355s + rowMads(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 355s + } 355s > 355s > colMads_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) { 355s + center <- colMedians(x, rows = rows, na.rm = na.rm, useNames = FALSE) 355s + colMads(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 355s + } 355s > 355s > 355s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 355s > # Subsetted tests 355s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 355s > source("utils/validateIndicesFramework.R") 355s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 355s > storage.mode(x) <- "integer" 355s > 355s > # To check names attribute 355s > dimnames <- list(letters[1:6], LETTERS[1:6]) 355s > 355s > # Test with and without dimnames on x 355s > for (setDimnames in c(TRUE, FALSE)) { 355s + if (setDimnames) dimnames(x) <- dimnames 355s + else dimnames(x) <- NULL 355s + 355s + count <- 0L 355s + for (rows in index_cases) { 355s + for (cols in index_cases) { 355s + count <- count + 1L 355s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 355s + useNames <- c(TRUE, FALSE) 355s + useNames <- useNames[count %% length(useNames) + 1] 355s + 355s + validateIndicesTestMatrix(x, rows, cols, 355s + ftest = rowMads, fsure = rowMads_R, 355s + na.rm = na.rm, useNames = useNames) 355s + validateIndicesTestMatrix(x, rows, cols, 355s + ftest = rowMads_center, fsure = rowMads_R, 355s + na.rm = na.rm, useNames = useNames) 355s + 355s + validateIndicesTestMatrix(x, rows, cols, 355s + fcoltest = colMads, fsure = rowMads_R, 355s + na.rm = na.rm, useNames = useNames) 355s + validateIndicesTestMatrix(x, rows, cols, 355s + fcoltest = colMads_center, fsure = rowMads_R, 355s + na.rm = na.rm, useNames = useNames) 355s + } 355s + } 355s + } 356s > 356s 356s R version 4.4.3 (2025-02-28) -- "Trophy Case" 356s Copyright (C) 2025 The R Foundation for Statistical Computing 356s Platform: aarch64-unknown-linux-gnu 356s 356s R is free software and comes with ABSOLUTELY NO WARRANTY. 356s You are welcome to redistribute it under certain conditions. 356s Type 'license()' or 'licence()' for distribution details. 356s 356s R is a collaborative project with many contributors. 356s Type 'contributors()' for more information and 356s 'citation()' on how to cite R or R packages in publications. 356s 356s Type 'demo()' for some demos, 'help()' for on-line help, or 356s 'help.start()' for an HTML browser interface to help. 356s Type 'q()' to quit R. 356s 356s > library("matrixStats") 356s > 356s > rowMeans_R <- function(x, na.rm = FALSE, ..., useNames = TRUE) { 356s + res <- rowMeans(x, na.rm = na.rm) 356s + if (!useNames) names(res) <- NULL 356s + res 356s + } 356s > 356s > colMeans_R <- function(x, na.rm = FALSE, ..., useNames = TRUE) { 356s + res <- colMeans(x, na.rm = na.rm) 356s + if (!useNames) names(res) <- NULL 356s + res 356s + } 356s > 356s > for (mode in c("integer", "logical", "double")) { 356s + x <- matrix(-4:4, nrow = 3, ncol = 3) 356s + storage.mode(x) <- mode 356s + if (mode == "double") x <- x + 0.1 356s + 356s + # To check names attribute 356s + dimnames <- list(letters[1:3], LETTERS[1:3]) 356s + 356s + # Test with and without dimnames on x 356s + for (setDimnames in c(TRUE, FALSE)) { 356s + if (setDimnames) dimnames(x) <- dimnames 356s + else dimnames(x) <- NULL 356s + # Check names attribute 356s + for (useNames in c(TRUE, FALSE)) { 356s + y0 <- rowMeans_R(x, na.rm = FALSE, useNames = useNames) 356s + y1 <- rowMeans2(x, na.rm = FALSE, useNames = useNames) 356s + stopifnot(all.equal(y1, y0)) 356s + 356s + y0 <- colMeans_R(x, na.rm = FALSE, useNames = useNames) 356s + y1 <- colMeans2(x, na.rm = FALSE, useNames = useNames) 356s + stopifnot(all.equal(y1, y0)) 356s + } 356s + } 356s + } 356s > 356s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 356s > # Special case: Single-element matrix 356s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 356s > cat("Special case: Single-element matrix:\n") 356s Special case: Single-element matrix: 356s > for (mode in c("integer", "logical", "double")) { 356s + x <- matrix(1, nrow = 1, ncol = 1) 356s + storage.mode(x) <- mode 356s + 356s + # To check names attribute 356s + dimnames <- list("a", "A") 356s + 356s + # Test with and without dimnames on x 356s + for (setDimnames in c(TRUE, FALSE)) { 356s + if (setDimnames) dimnames(x) <- dimnames 356s + else dimnames(x) <- NULL 356s + # Check names attribute 356s + for (useNames in c(TRUE, FALSE)) { 356s + y0 <- rowMeans_R(x, na.rm = FALSE, useNames = useNames) 356s + y1 <- rowMeans2(x, na.rm = FALSE, useNames = useNames) 356s + stopifnot(all.equal(y1, y0)) 356s + 356s + y0 <- colMeans_R(x, na.rm = FALSE, useNames = useNames) 356s + y1 <- colMeans2(x, na.rm = FALSE, useNames = useNames) 356s + stopifnot(all.equal(y1, y0)) 356s + } 356s + } 356s + } 356s > 356s > 356s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 356s > # Special case: Empty matrix 356s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 356s > cat("Special case: Empty matrix:\n") 356s Special case: Empty matrix: 356s > for (mode in c("integer", "logical", "double")) { 356s + x <- matrix(integer(0), nrow = 0, ncol = 0) 356s + storage.mode(x) <- mode 356s + 356s + y0 <- rowMeans(x, na.rm = FALSE) 356s + y1 <- rowMeans2(x, na.rm = FALSE) 356s + stopifnot(all.equal(y1, y0)) 356s + 356s + y0 <- colMeans(x, na.rm = FALSE) 356s + y1 <- colMeans2(x, na.rm = FALSE) 356s + stopifnot(all.equal(y1, y0)) 356s + } 356s > 356s > 356s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 356s > # Special case: All NAs 356s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 356s > cat("Special case: All NAs:\n") 356s Special case: All NAs: 356s > for (mode in c("integer", "logical", "double")) { 356s + x <- matrix(NA_integer_, nrow = 3, ncol = 3) 356s + storage.mode(x) <- mode 356s + 356s + # To check names attribute 356s + dimnames <- list(letters[1:3], LETTERS[1:3]) 356s + 356s + # Test with and without dimnames on x 356s + for (setDimnames in c(TRUE, FALSE)) { 356s + if (setDimnames) dimnames(x) <- dimnames 356s + else dimnames(x) <- NULL 356s + # Check names attribute 356s + for (useNames in c(TRUE, FALSE)) { 356s + y0 <- rowMeans_R(x, na.rm = TRUE, useNames = useNames) 356s + y1 <- rowMeans2(x, na.rm = TRUE, useNames = useNames) 356s + stopifnot(all.equal(y1, y0)) 356s + 356s + y0 <- colMeans_R(x, na.rm = TRUE, useNames = useNames) 356s + y1 <- colMeans2(x, na.rm = TRUE, useNames = useNames) 356s + stopifnot(all.equal(y1, y0)) 356s + } 356s + } 356s + } 356s > 356s > 356s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 356s > # Special case: All NaNs 356s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 356s > cat("Special case: All NaNs:\n") 356s Special case: All NaNs: 356s > x <- matrix(NA_real_, nrow = 3, ncol = 3) 356s > 356s > # Test with and without dimnames on x 356s > for (setDimnames in c(TRUE, FALSE)) { 356s + if (setDimnames) dimnames(x) <- dimnames 356s + else dimnames(x) <- NULL 356s + # Check names attribute 356s + for (useNames in c(TRUE, FALSE)) { 356s + y0 <- rowMeans_R(x, na.rm = TRUE, useNames = useNames) 356s + y1 <- rowMeans2(x, na.rm = TRUE, useNames = useNames) 356s + stopifnot(all.equal(y1, y0)) 356s + 356s + y0 <- colMeans_R(x, na.rm = TRUE, useNames = useNames) 356s + y1 <- colMeans2(x, na.rm = TRUE, useNames = useNames) 356s + stopifnot(all.equal(y1, y0)) 356s + } 356s + } 356s > 356s > 356s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 356s > # Special case: All Infs 356s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 356s > cat("Special case: All Infs:\n") 356s Special case: All Infs: 356s > x <- matrix(Inf, nrow = 3, ncol = 3) 356s > 356s > # Test with and without dimnames on x 356s > for (setDimnames in c(TRUE, FALSE)) { 356s + if (setDimnames) dimnames(x) <- dimnames 356s + else dimnames(x) <- NULL 356s + # Check names attribute 356s + for (useNames in c(TRUE, FALSE)) { 356s + y0 <- rowMeans_R(x, na.rm = FALSE, useNames = useNames) 356s + y1 <- rowMeans2(x, na.rm = FALSE, useNames = useNames) 356s + stopifnot(all.equal(y1, y0)) 356s + 356s + y0 <- colMeans_R(x, na.rm = FALSE, useNames = useNames) 356s + y1 <- colMeans2(x, na.rm = FALSE, useNames = useNames) 356s + stopifnot(all.equal(y1, y0)) 356s + } 356s + } 356s > 356s > 356s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 356s > # Special case: All -Infs 356s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 356s > cat("Special case: All -Infs:\n") 356s Special case: All -Infs: 356s > x <- matrix(-Inf, nrow = 3, ncol = 3) 356s > 356s > # Test with and without dimnames on x 356s > for (setDimnames in c(TRUE, FALSE)) { 356s + if (setDimnames) dimnames(x) <- dimnames 356s + else dimnames(x) <- NULL 356s + # Check names attribute 356s + for (useNames in c(TRUE, FALSE)) { 356s + y0 <- rowMeans_R(x, na.rm = FALSE, useNames = useNames) 356s + y1 <- rowMeans2(x, na.rm = FALSE, useNames = useNames) 356s + stopifnot(all.equal(y1, y0)) 356s + 356s + y0 <- colMeans_R(x, na.rm = FALSE, useNames = useNames) 356s + y1 <- colMeans2(x, na.rm = FALSE, useNames = useNames) 356s + stopifnot(all.equal(y1, y0)) 356s + } 356s + } 356s > 356s > 356s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 356s > # Special case: Infs and -Infs 356s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 356s > cat("Special case: Infs and -Infs:\n") 356s Special case: Infs and -Infs: 356s > x <- matrix(c(-Inf, +Inf), nrow = 4, ncol = 4) 356s > 356s > # To check names attribute 356s > dimnames <- list(letters[1:4], LETTERS[1:4]) 356s > 356s > # Test with and without dimnames on x 356s > for (setDimnames in c(TRUE, FALSE)) { 356s + if (setDimnames) dimnames(x) <- dimnames 356s + else dimnames(x) <- NULL 356s + # Check names attribute 356s + for (useNames in c(TRUE, FALSE)) { 356s + y0 <- rowMeans_R(x, na.rm = FALSE, useNames = useNames) 356s + y1 <- rowMeans2(x, na.rm = FALSE, useNames = useNames) 356s + stopifnot(all.equal(y1, y0)) 356s + 356s + y0 <- colMeans_R(x, na.rm = FALSE, useNames = useNames) 356s + y1 <- colMeans2(x, na.rm = FALSE, useNames = useNames) 356s + stopifnot(all.equal(y1, y0)) 356s + } 356s + } 356s > 356s > 356s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 356s > # Special case: NaNs and NAs 356s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 356s > cat("Special case: NaNs and NAs:\n") 356s Special case: NaNs and NAs: 356s > x <- matrix(c(NaN, NA_real_), nrow = 4, ncol = 4) 356s > 356s > # Test with and without dimnames on x 356s > for (setDimnames in c(TRUE, FALSE)) { 356s + if (setDimnames) dimnames(x) <- dimnames 356s + else dimnames(x) <- NULL 356s + # Check names attribute 356s + for (useNames in c(TRUE, FALSE)) { 356s + y0 <- rowMeans_R(x, na.rm = FALSE, useNames = useNames) 356s + str(y0) 356s + stopifnot(all(is.na(y0)), length(unique(y0)) >= 1L) 356s + y1 <- rowMeans2(x, na.rm = FALSE, useNames = useNames) 356s + str(y1) 356s + stopifnot(all(is.na(y1)), length(unique(y1)) >= 1L) 356s + stopifnot(all.equal(y1, y0)) 356s + 356s + y0 <- colMeans_R(x, na.rm = FALSE, useNames = useNames) 356s + stopifnot(all(is.na(y0)), length(unique(y0)) == 1L) 356s + y1 <- colMeans2(x, na.rm = FALSE, useNames = useNames) 356s + stopifnot(all(is.na(y1)), length(unique(y1)) == 1L) 356s + stopifnot(all.equal(y1, y0)) 356s + } 356s + } 356s Named num [1:4] NaN NA NaN NA 356s - attr(*, "names")= chr [1:4] "a" "b" "c" "d" 356s Named num [1:4] NaN NA NaN NA 356s - attr(*, "names")= chr [1:4] "a" "b" "c" "d" 356s num [1:4] NaN NA NaN NA 356s num [1:4] NaN NA NaN NA 356s num [1:4] NaN NA NaN NA 356s num [1:4] NaN NA NaN NA 356s num [1:4] NaN NA NaN NA 356s num [1:4] NaN NA NaN NA 356s > ## NOTE, due to compiler optimization, it is not guaranteed that NA is 356s > ## returned here (as one would expect). NaN might very well be returned, 356s > ## when both NA and NaN are involved. This is an accepted feature in R, 356s > ## which is documented in help("is.nan"). See also 356s > ## https://stat.ethz.ch/pipermail/r-devel/2017-April/074009.html. 356s > ## Thus, we cannot guarantee that y1 is identical to y0. 356s > 356s > 356s > 356s > 356s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 356s > # Special case: Integer overflow with ties 356s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 356s > cat("Special case: Integer overflow with ties:\n") 356s Special case: Integer overflow with ties: 356s > x <- matrix(.Machine$integer.max, nrow = 4, ncol = 4) 356s > 356s > # Test with and without dimnames on x 356s > for (setDimnames in c(TRUE, FALSE)) { 356s + if (setDimnames) dimnames(x) <- dimnames 356s + else dimnames(x) <- NULL 356s + # Check names attribute 356s + for (useNames in c(TRUE, FALSE)) { 356s + y0 <- rowMeans_R(x, na.rm = FALSE, useNames = useNames) 356s + y1 <- rowMeans2(x, na.rm = FALSE, useNames = useNames) 356s + stopifnot(all.equal(y1, y0)) 356s + 356s + y0 <- colMeans_R(x, na.rm = FALSE, useNames = useNames) 356s + y1 <- colMeans2(x, na.rm = FALSE, useNames = useNames) 356s + stopifnot(all.equal(y1, y0)) 356s + } 356s + } 356s > 356s > 356s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 356s > # Consistency checks 356s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 356s > set.seed(1) 356s > 356s > cat("Consistency checks:\n") 356s Consistency checks: 356s > n_sims <- if (Sys.getenv("_R_CHECK_USE_VALGRIND_") != "") 4L else 20L 356s > for (kk in seq_len(n_sims)) { 356s + cat("Random test #", kk, "\n", sep = "") 356s + 356s + # Simulate data in a matrix of any shape 356s + dim <- sample(50:200, size = 2) 356s + n <- prod(dim) 356s + x <- rnorm(n, sd = 100) 356s + dim(x) <- dim 356s + 356s + # Add NAs? 356s + if ((kk %% 4) %in% c(3, 0)) { 356s + cat("Adding NAs\n") 356s + nna <- sample(n, size = 1) 356s + na_values <- c(NA_real_, NaN) 356s + t <- sample(na_values, size = nna, replace = TRUE) 356s + x[sample(length(x), size = nna)] <- t 356s + } 356s + 356s + # Mode? 356s + modes <- "double" 356s + if ((kk %% 4) %in% c(2, 0)) { 356s + modes <- c("integer", "logical") 356s + } 356s + 356s + for (mode in modes) { 356s + if (mode != "double") { 356s + cat(sprintf("Coercing from %s to %s\n", storage.mode(x), mode)) 356s + storage.mode(x) <- mode 356s + } 356s + 356s + na.rm <- sample(c(TRUE, FALSE), size = 1) 356s + 356s + # rowMeans2(): 356s + y0 <- rowMeans(x, na.rm = na.rm) 356s + y1 <- rowMeans2(x, na.rm = na.rm) 356s + stopifnot(all.equal(y1, y0)) 356s + y2 <- colMeans2(t(x), na.rm = na.rm) 356s + stopifnot(all.equal(y2, y0)) 356s + 356s + # colMeans2(): 356s + y0 <- colMeans(x, na.rm = na.rm) 356s + y1 <- colMeans2(x, na.rm = na.rm) 356s + stopifnot(all.equal(y1, y0)) 356s + y2 <- rowMeans2(t(x), na.rm = na.rm) 356s + stopifnot(all.equal(y2, y0)) 356s + } 356s + } # for (kk ...) 356s Random test #1 356s Random test #2 356s Coercing from double to integer 356s Coercing from integer to logical 356s Random test #3 356s Adding NAs 356s Random test #4 356s Adding NAs 356s Coercing from double to integer 356s Coercing from integer to logical 356s Random test #5 356s Random test #6 356s Coercing from double to integer 356s Coercing from integer to logical 356s Random test #7 356s Adding NAs 356s Random test #8 356s Adding NAs 356s Coercing from double to integer 356s Coercing from integer to logical 356s Random test #9 356s Random test #10 356s Coercing from double to integer 356s Coercing from integer to logical 356s Random test #11 356s Adding NAs 356s Random test #12 356s Adding NAs 356s Coercing from double to integer 356s Coercing from integer to logical 356s Random test #13 356s Random test #14 356s Coercing from double to integer 356s Coercing from integer to logical 356s Random test #15 356s Adding NAs 356s Random test #16 356s Adding NAs 356s Coercing from double to integer 356s Coercing from integer to logical 356s Random test #17 356s Random test #18 356s Coercing from double to integer 356s Coercing from integer to logical 356s Random test #19 356s Adding NAs 356s Random test #20 356s Adding NAs 356s Coercing from double to integer 356s Coercing from integer to logical 356s > 356s 356s R version 4.4.3 (2025-02-28) -- "Trophy Case" 356s Copyright (C) 2025 The R Foundation for Statistical Computing 356s Platform: aarch64-unknown-linux-gnu 356s 356s R is free software and comes with ABSOLUTELY NO WARRANTY. 356s You are welcome to redistribute it under certain conditions. 356s Type 'license()' or 'licence()' for distribution details. 356s 356s R is a collaborative project with many contributors. 356s Type 'contributors()' for more information and 356s 'citation()' on how to cite R or R packages in publications. 356s 356s Type 'demo()' for some demos, 'help()' for on-line help, or 356s 'help.start()' for an HTML browser interface to help. 356s Type 'q()' to quit R. 356s 356s > library("matrixStats") 356s > 356s > rowMeans_R <- function(x, na.rm = FALSE, ..., useNames = TRUE) { 356s + res <- rowMeans(x, na.rm = na.rm) 356s + if (!useNames) names(res) <- NULL 356s + res 356s + } 356s > 356s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 356s > # Subsetted tests 356s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 356s > source("utils/validateIndicesFramework.R") 356s > x <- matrix(runif(6 * 6, min = -3, max = 3), nrow = 6, ncol = 6) 356s > storage.mode(x) <- "integer" 356s > 356s > # To check names attribute 356s > dimnames <- list(letters[1:6], LETTERS[1:6]) 356s > 356s > # Test with and without dimnames on x 356s > for (setDimnames in c(TRUE, FALSE)) { 356s + if (setDimnames) dimnames(x) <- dimnames 356s + else dimnames(x) <- NULL 356s + 356s + count <- 0L 356s + for (rows in index_cases) { 356s + for (cols in index_cases) { 356s + count <- count + 1L 356s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 356s + useNames <- c(TRUE, FALSE) 356s + useNames <- useNames[count %% length(useNames) + 1] 356s + 356s + validateIndicesTestMatrix(x, rows, cols, 356s + ftest = rowMeans2, fsure = rowMeans_R, 356s + na.rm = na.rm, useNames = useNames) 356s + validateIndicesTestMatrix(x, rows, cols, 356s + fcoltest = colMeans2, fsure = rowMeans_R, 356s + na.rm = na.rm, useNames = useNames) 356s + } 356s + } 356s + } 357s > 357s 357s R version 4.4.3 (2025-02-28) -- "Trophy Case" 357s Copyright (C) 2025 The R Foundation for Statistical Computing 357s Platform: aarch64-unknown-linux-gnu 357s 357s R is free software and comes with ABSOLUTELY NO WARRANTY. 357s You are welcome to redistribute it under certain conditions. 357s Type 'license()' or 'licence()' for distribution details. 357s 357s R is a collaborative project with many contributors. 357s Type 'contributors()' for more information and 357s 'citation()' on how to cite R or R packages in publications. 357s 357s Type 'demo()' for some demos, 'help()' for on-line help, or 357s 'help.start()' for an HTML browser interface to help. 357s Type 'q()' to quit R. 357s 357s > library("matrixStats") 357s > 357s > rowMedians_R <- function(x, na.rm = FALSE, ..., useNames = TRUE) { 357s + res <- apply(x, MARGIN = 1L, FUN = median, na.rm = na.rm) 357s + if (!useNames) names(res) <- NULL 357s + res 357s + } 357s > 357s > colMedians_R <- function(x, na.rm = FALSE, ..., useNames = TRUE) { 357s + res <- apply(x, MARGIN = 2L, FUN = median, na.rm = na.rm) 357s + if (!useNames) names(res) <- NULL 357s + res 357s + } 357s > 357s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 357s > # Special case: Non-ties 357s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 357s > cat("Special case: Non-ties:\n") 357s Special case: Non-ties: 357s > for (mode in c("integer", "double")) { 357s + x <- matrix(1:9 + 0.1, nrow = 3, ncol = 3) 357s + storage.mode(x) <- mode 357s + 357s + # To check names attribute 357s + dimnames <- list(letters[1:3], LETTERS[1:3]) 357s + 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 + # Check names attribute 357s + for (useNames in c(TRUE, FALSE)) { 357s + y0 <- rowMedians_R(x, na.rm = FALSE, useNames = useNames) 357s + y1 <- rowMedians(x, na.rm = FALSE, useNames = useNames) 357s + stopifnot(all.equal(y1, y0)) 357s + 357s + y0 <- colMedians_R(x, na.rm = FALSE, useNames = useNames) 357s + y1 <- colMedians(x, na.rm = FALSE, useNames = useNames) 357s + stopifnot(all.equal(y1, y0)) 357s + } 357s + } 357s + } 357s > 357s > 357s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 357s > # Special case: Ties 357s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 357s > cat("Special case: Ties:\n") 357s Special case: Ties: 357s > for (mode in c("integer", "double")) { 357s + x <- matrix(1:16 + 0.1, nrow = 4, ncol = 4) 357s + storage.mode(x) <- mode 357s + 357s + # To check names attribute 357s + dimnames <- list(letters[1:4], LETTERS[1:4]) 357s + 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 + # Check names attribute 357s + for (useNames in c(TRUE, FALSE)) { 357s + y0 <- rowMedians_R(x, na.rm = FALSE, useNames = useNames) 357s + y1 <- rowMedians(x, na.rm = FALSE, useNames = useNames) 357s + stopifnot(all.equal(y1, y0)) 357s + 357s + y0 <- colMedians_R(x, na.rm = FALSE, useNames = useNames) 357s + y1 <- colMedians(x, na.rm = FALSE, useNames = useNames) 357s + stopifnot(all.equal(y1, y0)) 357s + } 357s + } 357s + } 357s > 357s > 357s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 357s > # Special case: Single-element matrix 357s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 357s > cat("Special case: Single-element matrix:\n") 357s Special case: Single-element matrix: 357s > for (mode in c("integer", "double")) { 357s + x <- matrix(1, nrow = 1, ncol = 1) 357s + storage.mode(x) <- mode 357s + 357s + # To check names attribute 357s + dimnames <- list("a", "A") 357s + 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 + # Check names attribute 357s + for (useNames in c(TRUE, FALSE)) { 357s + y0 <- rowMedians_R(x, na.rm = FALSE, useNames = useNames) 357s + y1 <- rowMedians(x, na.rm = FALSE, useNames = useNames) 357s + stopifnot(all.equal(y1, y0)) 357s + 357s + y0 <- colMedians_R(x, na.rm = FALSE, useNames = useNames) 357s + y1 <- colMedians(x, na.rm = FALSE, useNames = useNames) 357s + stopifnot(all.equal(y1, y0)) 357s + } 357s + } 357s + } 357s > 357s > 357s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 357s > # Special case: Empty matrix 357s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 357s > cat("Special case: Empty matrix:\n") 357s Special case: Empty matrix: 357s > for (mode in c("integer", "double")) { 357s + x <- matrix(integer(0), nrow = 0, ncol = 0) 357s + storage.mode(x) <- mode 357s + 357s + y0 <- rowMedians_R(x, na.rm = FALSE) 357s + y1 <- rowMedians(x, na.rm = FALSE) 357s + stopifnot(all.equal(y1, y0)) 357s + 357s + y0 <- colMedians_R(x, na.rm = FALSE) 357s + y1 <- colMedians(x, na.rm = FALSE) 357s + stopifnot(all.equal(y1, y0)) 357s + } 357s > 357s > 357s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 357s > # Special case: All NAs 357s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 357s > cat("Special case: All NAs:\n") 357s Special case: All NAs: 357s > for (mode in c("integer", "double")) { 357s + x <- matrix(NA_integer_, nrow = 3, ncol = 3) 357s + storage.mode(x) <- mode 357s + 357s + # To check names attribute 357s + dimnames <- list(letters[1:3], LETTERS[1:3]) 357s + 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 + # Check names attribute 357s + for (useNames in c(TRUE, FALSE)) { 357s + y0 <- rowMedians_R(x, na.rm = TRUE, useNames = useNames) 357s + y1 <- rowMedians(x, na.rm = TRUE, useNames = useNames) 357s + stopifnot(all.equal(y1, y0)) 357s + 357s + y0 <- colMedians_R(x, na.rm = TRUE, useNames = useNames) 357s + y1 <- colMedians(x, na.rm = TRUE, useNames = useNames) 357s + stopifnot(all.equal(y1, y0)) 357s + } 357s + } 357s + } 357s > 357s > 357s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 357s > # Special case: All NaNs 357s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 357s > cat("Special case: All NaNs:\n") 357s Special case: All NaNs: 357s > x <- matrix(NA_real_, nrow = 3, ncol = 3) 357s > 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 + # Check names attribute 357s + for (useNames in c(TRUE, FALSE)) { 357s + y0 <- rowMedians_R(x, na.rm = TRUE, useNames = useNames) 357s + y1 <- rowMedians(x, na.rm = TRUE, useNames = useNames) 357s + stopifnot(all.equal(y1, y0)) 357s + 357s + y0 <- colMedians_R(x, na.rm = TRUE, useNames = useNames) 357s + y1 <- colMedians(x, na.rm = TRUE, useNames = useNames) 357s + stopifnot(all.equal(y1, y0)) 357s + } 357s + } 357s > 357s > 357s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 357s > # Special case: All Infs 357s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 357s > cat("Special case: All Infs:\n") 357s Special case: All Infs: 357s > x <- matrix(Inf, nrow = 3, ncol = 3) 357s > 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 + # Check names attribute 357s + for (useNames in c(TRUE, FALSE)) { 357s + y0 <- rowMedians_R(x, na.rm = FALSE, useNames = useNames) 357s + y1 <- rowMedians(x, na.rm = FALSE, useNames = useNames) 357s + stopifnot(all.equal(y1, y0)) 357s + 357s + y0 <- colMedians_R(x, na.rm = FALSE, useNames = useNames) 357s + y1 <- colMedians(x, na.rm = FALSE, useNames = useNames) 357s + stopifnot(all.equal(y1, y0)) 357s + } 357s + } 357s > 357s > 357s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 357s > # Special case: All -Infs 357s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 357s > cat("Special case: All -Infs:\n") 357s Special case: All -Infs: 357s > x <- matrix(-Inf, nrow = 3, ncol = 3) 357s > 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 + # Check names attribute 357s + for (useNames in c(TRUE, FALSE)) { 357s + y0 <- rowMedians_R(x, na.rm = FALSE, useNames = useNames) 357s + y1 <- rowMedians(x, na.rm = FALSE, useNames = useNames) 357s + stopifnot(all.equal(y1, y0)) 357s + 357s + y0 <- colMedians_R(x, na.rm = FALSE, useNames = useNames) 357s + y1 <- colMedians(x, na.rm = FALSE, useNames = useNames) 357s + stopifnot(all.equal(y1, y0)) 357s + } 357s + } 357s > 357s > 357s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 357s > # Special case: Infs and -Infs 357s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 357s > cat("Special case: Infs and -Infs:\n") 357s Special case: Infs and -Infs: 357s > x <- matrix(c(-Inf, +Inf), nrow = 4, ncol = 4) 357s > 357s > # To check names attribute 357s > dimnames <- list(letters[1:4], LETTERS[1:4]) 357s > 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 + # Check names attribute 357s + for (useNames in c(TRUE, FALSE)) { 357s + y0 <- rowMedians_R(x, na.rm = FALSE, useNames = useNames) 357s + y1 <- rowMedians(x, na.rm = FALSE, useNames = useNames) 357s + stopifnot(all.equal(y1, y0)) 357s + 357s + y0 <- colMedians_R(x, na.rm = FALSE, useNames = useNames) 357s + y1 <- colMedians(x, na.rm = FALSE, useNames = useNames) 357s + stopifnot(all.equal(y1, y0)) 357s + } 357s + } 357s > 357s > 357s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 357s > # Special case: Integer overflow with ties 357s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 357s > cat("Special case: Integer overflow with ties:\n") 357s Special case: Integer overflow with ties: 357s > x <- matrix(.Machine$integer.max, nrow = 4, ncol = 4) 357s > 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 + # Check names attribute 357s + for (useNames in c(TRUE, FALSE)) { 357s + y0 <- rowMedians_R(x, na.rm = FALSE, useNames = useNames) 357s + y1 <- rowMedians(x, na.rm = FALSE, useNames = useNames) 357s + stopifnot(all.equal(y1, y0)) 357s + 357s + y0 <- colMedians_R(x, na.rm = FALSE, useNames = useNames) 357s + y1 <- colMedians(x, na.rm = FALSE, useNames = useNames) 357s + stopifnot(all.equal(y1, y0)) 357s + } 357s + } 357s > 357s > 357s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 357s > # Consistency checks 357s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 357s > set.seed(1) 357s > 357s > cat("Consistency checks:\n") 357s Consistency checks: 357s > n_sims <- if (Sys.getenv("_R_CHECK_USE_VALGRIND_") != "") 4L else 20L 357s > for (kk in seq_len(n_sims)) { 357s + cat("Random test #", kk, "\n", sep = "") 357s + 357s + # Simulate data in a matrix of any shape 357s + dim <- sample(50:200, size = 2) 357s + n <- prod(dim) 357s + x <- rnorm(n, sd = 100) 357s + dim(x) <- dim 357s + 357s + # Add NAs? 357s + if ((kk %% 4) %in% c(3, 0)) { 357s + cat("Adding NAs\n") 357s + nna <- sample(n, size = 1) 357s + na_values <- c(NA_real_, NaN) 357s + t <- sample(na_values, size = nna, replace = TRUE) 357s + x[sample(length(x), size = nna)] <- t 357s + } 357s + 357s + # Integer or double? 357s + if ((kk %% 4) %in% c(2, 0)) { 357s + cat("Coercing to integers\n") 357s + storage.mode(x) <- "integer" 357s + } 357s + 357s + na.rm <- sample(c(TRUE, FALSE), size = 1) 357s + 357s + # rowMedians(): 357s + y0 <- rowMedians_R(x, na.rm = na.rm) 357s + y1 <- rowMedians(x, na.rm = na.rm) 357s + stopifnot(all.equal(y1, y0)) 357s + y2 <- colMedians(t(x), na.rm = na.rm) 357s + stopifnot(all.equal(y2, y0)) 357s + 357s + # colMedians(): 357s + y0 <- colMedians_R(x, na.rm = na.rm) 357s + y1 <- colMedians(x, na.rm = na.rm) 357s + stopifnot(all.equal(y1, y0)) 357s + y2 <- rowMedians(t(x), na.rm = na.rm) 357s + stopifnot(all.equal(y2, y0)) 357s + } # for (kk ...) 357s Random test #1 357s Random test #2 357s Coercing to integers 357s Random test #3 357s Adding NAs 357s Random test #4 357s Adding NAs 357s Coercing to integers 357s Random test #5 357s Random test #6 357s Coercing to integers 357s Random test #7 357s Adding NAs 357s Random test #8 357s Adding NAs 357s Coercing to integers 357s Random test #9 357s Random test #10 357s Coercing to integers 357s Random test #11 357s Adding NAs 357s Random test #12 357s Adding NAs 357s Coercing to integers 357s Random test #13 357s Random test #14 357s Coercing to integers 357s Random test #15 357s Adding NAs 357s Random test #16 357s Adding NAs 357s Coercing to integers 357s Random test #17 357s Random test #18 357s Coercing to integers 357s Random test #19 357s Adding NAs 357s Random test #20 357s Adding NAs 357s Coercing to integers 357s > 357s 357s R version 4.4.3 (2025-02-28) -- "Trophy Case" 357s Copyright (C) 2025 The R Foundation for Statistical Computing 357s Platform: aarch64-unknown-linux-gnu 357s 357s R is free software and comes with ABSOLUTELY NO WARRANTY. 357s You are welcome to redistribute it under certain conditions. 357s Type 'license()' or 'licence()' for distribution details. 357s 357s R is a collaborative project with many contributors. 357s Type 'contributors()' for more information and 357s 'citation()' on how to cite R or R packages in publications. 357s 357s Type 'demo()' for some demos, 'help()' for on-line help, or 357s 'help.start()' for an HTML browser interface to help. 357s Type 'q()' to quit R. 357s 357s > library("matrixStats") 357s > 357s > rowMedians_R <- function(x, na.rm = FALSE, ..., useNames = TRUE) { 357s + res <- apply(x, MARGIN = 1L, FUN = median, na.rm = na.rm) 357s + if (!useNames) names(res) <- NULL 357s + res 357s + } 357s > 357s > colMedians_R <- function(x, na.rm = FALSE, ..., useNames = TRUE) { 357s + res <- apply(x, MARGIN = 2L, FUN = median, na.rm = na.rm) 357s + if (!useNames) names(res) <- NULL 357s + res 357s + } 357s > 357s > 357s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 357s > # Subsetted tests 357s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 357s > source("utils/validateIndicesFramework.R") 357s > x <- matrix(runif(6 * 6, min = -3, max = 3), nrow = 6, ncol = 6) 357s > storage.mode(x) <- "integer" 357s > 357s > # To check names attribute 357s > dimnames <- list(letters[1:6], LETTERS[1:6]) 357s > 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 + 357s + count <- 0L 357s + for (rows in index_cases) { 357s + for (cols in index_cases) { 357s + count <- count + 1L 357s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 357s + useNames <- c(TRUE, FALSE) 357s + useNames <- useNames[count %% length(useNames) + 1] 357s + 357s + validateIndicesTestMatrix(x, rows, cols, 357s + ftest = rowMedians, fsure = rowMedians_R, 357s + na.rm = na.rm, useNames = useNames) 357s + validateIndicesTestMatrix(x, rows, cols, 357s + fcoltest = colMedians, fsure = rowMedians_R, 357s + na.rm = na.rm, useNames = useNames) 357s + } 357s + } 357s + } 358s > 358s 358s R version 4.4.3 (2025-02-28) -- "Trophy Case" 358s Copyright (C) 2025 The R Foundation for Statistical Computing 358s Platform: aarch64-unknown-linux-gnu 358s 358s R is free software and comes with ABSOLUTELY NO WARRANTY. 358s You are welcome to redistribute it under certain conditions. 358s Type 'license()' or 'licence()' for distribution details. 358s 358s R is a collaborative project with many contributors. 358s Type 'contributors()' for more information and 358s 'citation()' on how to cite R or R packages in publications. 358s 358s Type 'demo()' for some demos, 'help()' for on-line help, or 358s 'help.start()' for an HTML browser interface to help. 358s Type 'q()' to quit R. 358s 358s > library("matrixStats") 358s > library("stats") 358s > 358s > asWhich <- function(probs, max) { 358s + idx <- as.integer(round(probs * max)) 358s + if (idx < 1L) { 358s + idx <- 1L 358s + } else if (idx > max) { 358s + idx <- max 358s + } 358s + idx 358s + } # asWhich() 358s > 358s > rowOrderStats_R <- function(x, probs, ..., useNames = TRUE) { 358s + ans <- apply(x, MARGIN = 1L, FUN = quantile, probs = probs, type = 3L) 358s + 358s + # Remove Attributes 358s + if (!useNames || length(ans) == 0L) attributes(ans) <- NULL 358s + ans 358s + } # rowOrderStats_R() 358s > 358s > 358s > set.seed(1) 358s > 358s > 358s > # Simulate data in a matrix of any shape 358s > nrow <- 60L 358s > ncol <- 30L 358s > x <- rnorm(nrow * ncol) 358s > dim(x) <- c(nrow, ncol) 358s > probs <- 0.3 358s > which <- asWhich(probs, max = ncol) 358s > 358s > y0 <- rowOrderStats_R(x, probs = probs) 358s > y1 <- rowOrderStats(x, which = which) 358s > stopifnot(all.equal(y1, y0)) 358s > y2 <- colOrderStats(t(x), which = which) 358s > stopifnot(all.equal(y2, y0)) 358s > 358s > 358s > 358s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 358s > # Consistency checks 358s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 358s > for (mode in c("integer", "double")) { 358s + cat("Consistency checks without NAs:\n") 358s + for (kk in 1:3) { 358s + cat("Random test #", kk, "\n", sep = "") 358s + 358s + # Simulate data in a matrix of any shape 358s + nrow <- sample(20L, size = 1L) 358s + ncol <- sample(20L, size = 1L) 358s + x <- rnorm(nrow * ncol) 358s + dim(x) <- c(nrow, ncol) 358s + 358s + cat("mode: ", mode, "\n", sep = "") 358s + storage.mode(x) <- mode 358s + str(x) 358s + 358s + probs <- runif(1) 358s + which <- asWhich(probs, max = ncol) 358s + 358s + y0 <- rowOrderStats_R(x, probs = probs) 358s + y1 <- rowOrderStats(x, which = which) 358s + stopifnot(all.equal(y1, y0)) 358s + y2 <- colOrderStats(t(x), which = which) 358s + stopifnot(all.equal(y2, y0)) 358s + } # for (kk in ...) 358s + } # for (mode ...) 358s Consistency checks without NAs: 358s Random test #1 358s mode: integer 358s int [1:14, 1:6] 0 0 1 0 2 -1 1 0 0 0 ... 358s Random test #2 358s mode: integer 358s int [1:8, 1:13] 0 0 1 -2 0 0 0 0 1 0 ... 358s Random test #3 358s mode: integer 358s int [1:20, 1:17] 0 0 0 0 1 0 1 0 0 -1 ... 358s Consistency checks without NAs: 358s Random test #1 358s mode: double 358s num [1:9, 1:5] -1.4286 -0.00386 -0.70456 -0.29242 -0.49607 ... 358s Random test #2 358s mode: double 358s num [1:11, 1:20] -0.796 0.482 -0.952 0.5 1.242 ... 358s Random test #3 358s mode: double 358s num [1:7, 1:18] 1.553 -2.405 0.167 -0.403 -1.746 ... 358s > 358s > 358s > # Check names attribute 358s > x <- matrix(1:9 + 0.1, nrow = 3L, ncol = 3L) 358s > 358s > probs <- runif(1) 358s > which <- asWhich(probs, max = ncol(x)) 358s > 358s > dimnames <- list(letters[1:3], LETTERS[1:3]) 358s > 358s > # Test with and without dimnames on x 358s > for (setDimnames in c(TRUE, FALSE)) { 358s + if (setDimnames) dimnames(x) <- dimnames 358s + else dimnames(x) <- NULL 358s + # Check names attribute 358s + for (useNames in c(TRUE, FALSE)) { 358s + y0 <- rowOrderStats_R(x, probs = probs, useNames = useNames) 358s + y1 <- rowOrderStats(x, which = which, useNames = useNames) 358s + stopifnot(all.equal(y1, y0)) 358s + y2 <- colOrderStats(t(x), which = which, useNames = useNames) 358s + stopifnot(all.equal(y2, y0)) 358s + } 358s + } 358s > 358s 358s R version 4.4.3 (2025-02-28) -- "Trophy Case" 358s Copyright (C) 2025 The R Foundation for Statistical Computing 358s Platform: aarch64-unknown-linux-gnu 358s 358s R is free software and comes with ABSOLUTELY NO WARRANTY. 358s You are welcome to redistribute it under certain conditions. 358s Type 'license()' or 'licence()' for distribution details. 358s 358s R is a collaborative project with many contributors. 358s Type 'contributors()' for more information and 358s 'citation()' on how to cite R or R packages in publications. 358s 358s Type 'demo()' for some demos, 'help()' for on-line help, or 358s 'help.start()' for an HTML browser interface to help. 358s Type 'q()' to quit R. 358s 358s > library("matrixStats") 358s > 358s > rowOrderStats_R <- function(x, probs, ..., useNames = TRUE) { 358s + ans <- apply(x, MARGIN = 1L, FUN = quantile, probs = probs, type = 3L) 358s + 358s + # Remove Attributes 358s + if (!useNames || length(ans) == 0L) attributes(ans) <- NULL 358s + ans 358s + } # rowOrderStats_R() 358s > 358s > 358s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 358s > # Subsetted tests 358s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 358s > source("utils/validateIndicesFramework.R") 358s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 358s > storage.mode(x) <- "integer" 358s > 358s > # To check names attribute 358s > dimnames <- list(letters[1:6], LETTERS[1:6]) 358s > 358s > probs <- 0.3 358s > # Test with and without dimnames on x 358s > for (setDimnames in c(TRUE, FALSE)) { 358s + if (setDimnames) dimnames(x) <- dimnames 358s + else dimnames(x) <- NULL 358s + for (rows in index_cases) { 358s + for (cols in index_cases) { 358s + # Check names attribute 358s + for (useNames in c(TRUE, FALSE)) { 358s + if (is.null(cols)) which <- round(probs * ncol(x)) 358s + else { 358s + xxrows <- rows 358s + suppressWarnings({ 358s + xx <- tryCatch(x[, cols, drop = FALSE], error = function(c) "error") 358s + if (identical(xx, "error")) which <- 0L 358s + else which <- round(probs * ncol(xx)) 358s + }) 358s + } 358s + if (which == 0L) next 358s + 358s + validateIndicesTestMatrix(x, rows, cols, 358s + ftest = rowOrderStats, fsure = rowOrderStats_R, 358s + which = which, probs = probs, useNames = useNames) 358s + validateIndicesTestMatrix(x, rows, cols, 358s + fcoltest = colOrderStats, fsure = rowOrderStats_R, 358s + which = which, probs = probs, useNames = useNames) 358s + } 358s + } 358s + } 358s + } 359s > 359s 359s R version 4.4.3 (2025-02-28) -- "Trophy Case" 359s Copyright (C) 2025 The R Foundation for Statistical Computing 359s Platform: aarch64-unknown-linux-gnu 359s 359s R is free software and comes with ABSOLUTELY NO WARRANTY. 359s You are welcome to redistribute it under certain conditions. 359s Type 'license()' or 'licence()' for distribution details. 359s 359s R is a collaborative project with many contributors. 359s Type 'contributors()' for more information and 359s 'citation()' on how to cite R or R packages in publications. 359s 359s Type 'demo()' for some demos, 'help()' for on-line help, or 359s 'help.start()' for an HTML browser interface to help. 359s Type 'q()' to quit R. 359s 359s > library("matrixStats") 359s > 359s > rowProds_R <- function(x, FUN = prod, na.rm = FALSE, ..., useNames = TRUE) { 359s + res <- apply(x, MARGIN = 1L, FUN = FUN, na.rm = na.rm) 359s + if (!useNames) names(res) <- NULL 359s + res 359s + } 359s > 359s > all.equal.na <- function(target, current, ...) { 360s + # Computations involving NaN may return NaN or NA, cf. ?is.nan 360s + current[is.nan(current)] <- NA_real_ 360s + target[is.nan(target)] <- NA_real_ 360s + all.equal(target, current, ...) 360s + } 360s > 360s > for (mode in c("integer", "double")) { 360s + # Missing values 360s + x <- matrix(c(1, NA, NaN, 1, 1, 0, 1, 0), nrow = 4, ncol = 2) 360s + cat("mode: ", mode, "\n", sep = "") 360s + storage.mode(x) <- mode 360s + str(x) 360s + 360s + # To check names attribute 360s + dimnames <- list(letters[1:4], LETTERS[1:2]) 360s + 360s + # Test with and without dimnames on x 360s + for (setDimnames in c(TRUE, FALSE)) { 360s + if (setDimnames) dimnames(x) <- dimnames 360s + else dimnames(x) <- NULL 360s + # Check names attribute 360s + for (useNames in c(TRUE, FALSE)) { 360s + y0 <- rowProds_R(x, na.rm = TRUE, useNames = useNames) 360s + print(y0) 360s + y1 <- rowProds(x, na.rm = TRUE, useNames = useNames) 360s + print(y1) 360s + y2 <- colProds(t(x), na.rm = TRUE, useNames = useNames) 360s + print(y2) 360s + stopifnot(all.equal(y1, y0)) 360s + stopifnot(all.equal(y2, y1)) 360s + 360s + # Missing values 360s + y0 <- rowProds_R(x, na.rm = FALSE, useNames = useNames) 360s + print(y0) 360s + y1 <- rowProds(x, na.rm = FALSE, useNames = useNames) 360s + print(y1) 360s + y2 <- colProds(t(x), na.rm = FALSE, useNames = useNames) 360s + print(y2) 360s + stopifnot(all.equal(y1, y0)) 360s + stopifnot(all.equal(y2, y1)) 360s + 360s + # "Empty" rows 360s + y0 <- rowProds_R(x[integer(0), , drop = FALSE], na.rm = FALSE, useNames = useNames) 360s + print(y0) 360s + y1 <- rowProds(x[integer(0), , drop = FALSE], na.rm = FALSE, useNames = useNames) 360s + print(y1) 360s + y2 <- colProds(t(x[integer(0), , drop = FALSE]), na.rm = FALSE, useNames = useNames) 360s + print(y2) 360s + stopifnot(all.equal.na(y1, y0)) 360s + stopifnot(all.equal(y2, y1)) 360s + stopifnot(length(y1) == 0L) 360s + 360s + # Using product() 360s + y1 <- rowProds(x, method = "expSumLog", na.rm = FALSE, useNames = useNames) 360s + print(y1) 360s + y2 <- colProds(t(x), method = "expSumLog", na.rm = FALSE, useNames = useNames) 360s + print(y2) 360s + stopifnot(all.equal(y2, y1)) 360s + } 360s + } 360s + } # for (mode ...) 360s mode: integer 360s int [1:4, 1:2] 1 NA NA 1 1 0 1 0 360s a b c d 360s 1 0 1 0 360s a b c d 360s 1 0 1 0 360s a b c d 360s 1 0 1 0 360s a b c d 360s 1 NA NA 0 360s a b c d 360s 1 NA NA 0 360s a b c d 360s 1 NA NA 0 360s numeric(0) 360s numeric(0) 360s numeric(0) 360s a b c d 360s 1 NA NA 0 360s a b c d 360s 1 NA NA 0 360s [1] 1 0 1 0 360s [1] 1 0 1 0 360s [1] 1 0 1 0 360s [1] 1 NA NA 0 360s [1] 1 NA NA 0 360s [1] 1 NA NA 0 360s numeric(0) 360s numeric(0) 360s numeric(0) 360s [1] 1 NA NA 0 360s [1] 1 NA NA 0 360s [1] 1 0 1 0 360s [1] 1 0 1 0 360s [1] 1 0 1 0 360s [1] 1 NA NA 0 360s [1] 1 NA NA 0 360s [1] 1 NA NA 0 360s numeric(0) 360s numeric(0) 360s numeric(0) 360s [1] 1 NA NA 0 360s [1] 1 NA NA 0 360s [1] 1 0 1 0 360s [1] 1 0 1 0 360s [1] 1 0 1 0 360s [1] 1 NA NA 0 360s [1] 1 NA NA 0 360s [1] 1 NA NA 0 360s numeric(0) 360s numeric(0) 360s numeric(0) 360s [1] 1 NA NA 0 360s [1] 1 NA NA 0 360s mode: double 360s num [1:4, 1:2] 1 NA NaN 1 1 0 1 0 360s a b c d 360s 1 0 1 0 360s a b c d 360s 1 0 1 0 360s a b c d 360s 1 0 1 0 360s a b c d 360s 1 NA NaN 0 360s a b c d 360s 1 NA NaN 0 360s a b c d 360s 1 NA NaN 0 360s numeric(0) 360s numeric(0) 360s numeric(0) 360s a b c d 360s 1 NA NA 0 360s a b c d 360s 1 NA NA 0 360s [1] 1 0 1 0 360s [1] 1 0 1 0 360s [1] 1 0 1 0 360s [1] 1 NA NaN 0 360s [1] 1 NA NaN 0 360s [1] 1 NA NaN 0 360s numeric(0) 360s numeric(0) 360s numeric(0) 360s [1] 1 NA NA 0 360s [1] 1 NA NA 0 360s [1] 1 0 1 0 360s [1] 1 0 1 0 360s [1] 1 0 1 0 360s [1] 1 NA NaN 0 360s [1] 1 NA NaN 0 360s [1] 1 NA NaN 0 360s numeric(0) 360s numeric(0) 360s numeric(0) 360s [1] 1 NA NA 0 360s [1] 1 NA NA 0 360s [1] 1 0 1 0 360s [1] 1 0 1 0 360s [1] 1 0 1 0 360s [1] 1 NA NaN 0 360s [1] 1 NA NaN 0 360s [1] 1 NA NaN 0 360s numeric(0) 360s numeric(0) 360s numeric(0) 360s [1] 1 NA NA 0 360s [1] 1 NA NA 0 360s > 360s > 360s > # Bug report 2012-06-25 360s > x <- matrix(c(1, 1, 1, 1, 1, 0, 1, 0), nrow = 4, ncol = 2) 360s > y0 <- rowProds_R(x) 360s > print(y0) 360s [1] 1 0 1 0 360s > y1 <- rowProds(x) 360s > print(y1) 360s [1] 1 0 1 0 360s > y2 <- colProds(t(x)) 360s > print(y2) 360s [1] 1 0 1 0 360s > stopifnot(all.equal.na(y1, y0)) 360s > stopifnot(all.equal.na(y1, x[, 1] * x[, 2])) 360s > stopifnot(all.equal.na(y2, y1)) 360s > # Check names attribute 360s > dimnames(x) <- dimnames 360s > y0 <- rowProds_R(x, useNames = TRUE) 360s > print(y0) 360s a b c d 360s 1 0 1 0 360s > y1 <- rowProds(x, useNames = TRUE) 360s > print(y1) 360s a b c d 360s 1 0 1 0 360s > y2 <- colProds(t(x), useNames = TRUE) 360s > print(y2) 360s a b c d 360s 1 0 1 0 360s > stopifnot(all.equal.na(y1, y0)) 360s > stopifnot(all.equal.na(y1, x[, 1] * x[, 2])) 360s > stopifnot(all.equal.na(y2, y1)) 360s > 360s > # Bug report 2014-03-25 ("all rows contains a zero") 360s > x <- matrix(c(0, 1, 1, 0), nrow = 2, ncol = 2) 360s > # To check names attribute 360s > dimnames <- list(letters[1:2], LETTERS[1:2]) 360s > y0 <- rowProds_R(x) 360s > print(y0) 360s [1] 0 0 360s > y1 <- rowProds(x) 360s > print(y1) 360s [1] 0 0 360s > y2 <- colProds(t(x)) 360s > print(y2) 360s [1] 0 0 360s > stopifnot(all.equal.na(y1, y0)) 360s > stopifnot(all.equal.na(y1, c(0, 0))) 360s > stopifnot(all.equal.na(y2, y1)) 360s > # Check names attribute 360s > dimnames(x) <- dimnames 360s > y0 <- rowProds_R(x, useNames = TRUE) 360s > print(y0) 360s a b 360s 0 0 360s > y1 <- rowProds(x, useNames = TRUE) 360s > print(y1) 360s a b 360s 0 0 360s > y2 <- colProds(t(x), useNames = TRUE) 360s > print(y2) 360s a b 360s 0 0 360s > stopifnot(all.equal.na(y1, y0)) 360s > stopifnot(all.equal.na(y2, y1)) 360s > 360s 360s R version 4.4.3 (2025-02-28) -- "Trophy Case" 360s Copyright (C) 2025 The R Foundation for Statistical Computing 360s Platform: aarch64-unknown-linux-gnu 360s 360s R is free software and comes with ABSOLUTELY NO WARRANTY. 360s You are welcome to redistribute it under certain conditions. 360s Type 'license()' or 'licence()' for distribution details. 360s 360s R is a collaborative project with many contributors. 360s Type 'contributors()' for more information and 360s 'citation()' on how to cite R or R packages in publications. 360s 360s Type 'demo()' for some demos, 'help()' for on-line help, or 360s 'help.start()' for an HTML browser interface to help. 360s Type 'q()' to quit R. 360s 360s > library("matrixStats") 360s > 360s > rowProds_R <- function(x, FUN = prod, na.rm = FALSE, ..., useNames = TRUE) { 360s + res <- apply(x, MARGIN = 1L, FUN = FUN, na.rm = na.rm) 360s + if (!useNames) names(res) <- NULL 360s + res 360s + } 360s > 360s > 360s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 360s > # Subsetted tests 360s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 360s > source("utils/validateIndicesFramework.R") 360s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 360s > storage.mode(x) <- "integer" 360s > 360s > # To check names attribute 360s > dimnames <- list(letters[1:6], LETTERS[1:6]) 360s > 360s > # Test with and without dimnames on x 360s > for (setDimnames in c(TRUE, FALSE)) { 360s + if (setDimnames) dimnames(x) <- dimnames 360s + else dimnames(x) <- NULL 360s + for (rows in index_cases) { 360s + for (cols in index_cases) { 360s + for (na.rm in c(TRUE, FALSE)) { 360s + for (useNames in c(TRUE, FALSE)) { 360s + validateIndicesTestMatrix(x, rows, cols, 360s + ftest = rowProds, fsure = rowProds_R, 360s + method = "expSumLog", 360s + FUN = product, na.rm = na.rm, useNames = useNames) 360s + validateIndicesTestMatrix(x, rows, cols, 360s + fcoltest = colProds, fsure = rowProds_R, 360s + method = "expSumLog", 360s + FUN = product, na.rm = na.rm, useNames = useNames) 360s + } 360s + } 360s + } 360s + } 360s + } 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: aarch64-unknown-linux-gnu 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 > ## Create isFALSE() if running on an old version of R 361s > if (!exists("isFALSE", mode="function")) { 361s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 361s + } 361s > 361s > rowQuantiles_R <- function(x, probs = c(0, 0.25, 0.50, 0.75, 1), na.rm = FALSE, drop = TRUE, type = 7L, ..., useNames = TRUE) { 361s + q <- apply(x, MARGIN = 1L, FUN = function(x, probs, na.rm) { 361s + if (!na.rm && any(is.na(x))) { 361s + na_value <- NA_real_ 361s + if (type != 7L) storage.mode(na_value) <- storage.mode(x) 361s + rep(na_value, times = length(probs)) 361s + } else { 361s + as.vector(quantile(x, probs = probs, na.rm = na.rm, type = type, names = FALSE, ...)) 361s + } 361s + }, probs = probs, na.rm = na.rm) 361s + 361s + if (!is.null(dim(q))) q <- t(q) 361s + else dim(q) <- c(nrow(x), length(probs)) 361s + 361s + colnames(q) <- matrixStats:::quantile_probs_names(probs) 361s + rownames(q) <- rownames(x) 361s + if (isFALSE(useNames)) dimnames(q) <- NULL 361s + 361s + if (drop) q <- drop(q) 361s + q 361s + } 361s > 361s > 361s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 361s > # Test with multiple quantiles 361s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 361s > for (mode in c("logical", "integer", "double")) { 361s + cat("mode: ", mode, "\n", sep = "") 361s + x <- matrix(1:40 + 0.1, nrow = 8, ncol = 5) 361s + storage.mode(x) <- mode 361s + dimnames <- lapply(dim(x), FUN = function(n) letters[seq_len(n)]) 361s + str(x) 361s + 361s + probs <- c(0, 0.5, 1) 361s + # Test with and without dimnames on x 361s + for (setDimnames in c(TRUE, FALSE)) { 361s + if (setDimnames) dimnames(x) <- dimnames 361s + else dimnames(x) <- NULL 361s + # Check names attribute 361s + for (useNames in c(TRUE, FALSE)) { 361s + q0 <- rowQuantiles_R(x, probs = probs, useNames = useNames) 361s + print(q0) 361s + q1 <- rowQuantiles(x, probs = probs, useNames = useNames) 361s + print(q1) 361s + stopifnot(all.equal(q1, q0)) 361s + q2 <- colQuantiles(t(x), probs = probs, useNames = useNames) 361s + stopifnot(all.equal(q2, q0)) 361s + } 361s + } 361s + } # for (mode ...) 361s mode: logical 361s logi [1:8, 1:5] TRUE TRUE TRUE TRUE TRUE TRUE ... 361s 0% 50% 100% 361s a 1 1 1 361s b 1 1 1 361s c 1 1 1 361s d 1 1 1 361s e 1 1 1 361s f 1 1 1 361s g 1 1 1 361s h 1 1 1 361s 0% 50% 100% 361s a 1 1 1 361s b 1 1 1 361s c 1 1 1 361s d 1 1 1 361s e 1 1 1 361s f 1 1 1 361s g 1 1 1 361s h 1 1 1 361s [,1] [,2] [,3] 361s [1,] 1 1 1 361s [2,] 1 1 1 361s [3,] 1 1 1 361s [4,] 1 1 1 361s [5,] 1 1 1 361s [6,] 1 1 1 361s [7,] 1 1 1 361s [8,] 1 1 1 361s [,1] [,2] [,3] 361s [1,] 1 1 1 361s [2,] 1 1 1 361s [3,] 1 1 1 361s [4,] 1 1 1 361s [5,] 1 1 1 361s [6,] 1 1 1 361s [7,] 1 1 1 361s [8,] 1 1 1 361s 0% 50% 100% 361s [1,] 1 1 1 361s [2,] 1 1 1 361s [3,] 1 1 1 361s [4,] 1 1 1 361s [5,] 1 1 1 361s [6,] 1 1 1 361s [7,] 1 1 1 361s [8,] 1 1 1 361s 0% 50% 100% 361s [1,] 1 1 1 361s [2,] 1 1 1 361s [3,] 1 1 1 361s [4,] 1 1 1 361s [5,] 1 1 1 361s [6,] 1 1 1 361s [7,] 1 1 1 361s [8,] 1 1 1 361s [,1] [,2] [,3] 361s [1,] 1 1 1 361s [2,] 1 1 1 361s [3,] 1 1 1 361s [4,] 1 1 1 361s [5,] 1 1 1 361s [6,] 1 1 1 361s [7,] 1 1 1 361s [8,] 1 1 1 361s [,1] [,2] [,3] 361s [1,] 1 1 1 361s [2,] 1 1 1 361s [3,] 1 1 1 361s [4,] 1 1 1 361s [5,] 1 1 1 361s [6,] 1 1 1 361s [7,] 1 1 1 361s [8,] 1 1 1 361s mode: integer 361s int [1:8, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 361s 0% 50% 100% 361s a 1 17 33 361s b 2 18 34 361s c 3 19 35 361s d 4 20 36 361s e 5 21 37 361s f 6 22 38 361s g 7 23 39 361s h 8 24 40 361s 0% 50% 100% 361s a 1 17 33 361s b 2 18 34 361s c 3 19 35 361s d 4 20 36 361s e 5 21 37 361s f 6 22 38 361s g 7 23 39 361s h 8 24 40 361s [,1] [,2] [,3] 361s [1,] 1 17 33 361s [2,] 2 18 34 361s [3,] 3 19 35 361s [4,] 4 20 36 361s [5,] 5 21 37 361s [6,] 6 22 38 361s [7,] 7 23 39 361s [8,] 8 24 40 361s [,1] [,2] [,3] 361s [1,] 1 17 33 361s [2,] 2 18 34 361s [3,] 3 19 35 361s [4,] 4 20 36 361s [5,] 5 21 37 361s [6,] 6 22 38 361s [7,] 7 23 39 361s [8,] 8 24 40 361s 0% 50% 100% 361s [1,] 1 17 33 361s [2,] 2 18 34 361s [3,] 3 19 35 361s [4,] 4 20 36 361s [5,] 5 21 37 361s [6,] 6 22 38 361s [7,] 7 23 39 361s [8,] 8 24 40 361s 0% 50% 100% 361s [1,] 1 17 33 361s [2,] 2 18 34 361s [3,] 3 19 35 361s [4,] 4 20 36 361s [5,] 5 21 37 361s [6,] 6 22 38 361s [7,] 7 23 39 361s [8,] 8 24 40 361s [,1] [,2] [,3] 361s [1,] 1 17 33 361s [2,] 2 18 34 361s [3,] 3 19 35 361s [4,] 4 20 36 361s [5,] 5 21 37 361s [6,] 6 22 38 361s [7,] 7 23 39 361s [8,] 8 24 40 361s [,1] [,2] [,3] 361s [1,] 1 17 33 361s [2,] 2 18 34 361s [3,] 3 19 35 361s [4,] 4 20 36 361s [5,] 5 21 37 361s [6,] 6 22 38 361s [7,] 7 23 39 361s [8,] 8 24 40 361s mode: double 361s 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 ... 361s 0% 50% 100% 361s a 1.1 17.1 33.1 361s b 2.1 18.1 34.1 361s c 3.1 19.1 35.1 361s d 4.1 20.1 36.1 361s e 5.1 21.1 37.1 361s f 6.1 22.1 38.1 361s g 7.1 23.1 39.1 361s h 8.1 24.1 40.1 361s 0% 50% 100% 361s a 1.1 17.1 33.1 361s b 2.1 18.1 34.1 361s c 3.1 19.1 35.1 361s d 4.1 20.1 36.1 361s e 5.1 21.1 37.1 361s f 6.1 22.1 38.1 361s g 7.1 23.1 39.1 361s h 8.1 24.1 40.1 361s [,1] [,2] [,3] 361s [1,] 1.1 17.1 33.1 361s [2,] 2.1 18.1 34.1 361s [3,] 3.1 19.1 35.1 361s [4,] 4.1 20.1 36.1 361s [5,] 5.1 21.1 37.1 361s [6,] 6.1 22.1 38.1 361s [7,] 7.1 23.1 39.1 361s [8,] 8.1 24.1 40.1 361s [,1] [,2] [,3] 361s [1,] 1.1 17.1 33.1 361s [2,] 2.1 18.1 34.1 361s [3,] 3.1 19.1 35.1 361s [4,] 4.1 20.1 36.1 361s [5,] 5.1 21.1 37.1 361s [6,] 6.1 22.1 38.1 361s [7,] 7.1 23.1 39.1 361s [8,] 8.1 24.1 40.1 361s 0% 50% 100% 361s [1,] 1.1 17.1 33.1 361s [2,] 2.1 18.1 34.1 361s [3,] 3.1 19.1 35.1 361s [4,] 4.1 20.1 36.1 361s [5,] 5.1 21.1 37.1 361s [6,] 6.1 22.1 38.1 361s [7,] 7.1 23.1 39.1 361s [8,] 8.1 24.1 40.1 361s 0% 50% 100% 361s [1,] 1.1 17.1 33.1 361s [2,] 2.1 18.1 34.1 361s [3,] 3.1 19.1 35.1 361s [4,] 4.1 20.1 36.1 361s [5,] 5.1 21.1 37.1 361s [6,] 6.1 22.1 38.1 361s [7,] 7.1 23.1 39.1 361s [8,] 8.1 24.1 40.1 361s [,1] [,2] [,3] 361s [1,] 1.1 17.1 33.1 361s [2,] 2.1 18.1 34.1 361s [3,] 3.1 19.1 35.1 361s [4,] 4.1 20.1 36.1 361s [5,] 5.1 21.1 37.1 361s [6,] 6.1 22.1 38.1 361s [7,] 7.1 23.1 39.1 361s [8,] 8.1 24.1 40.1 361s [,1] [,2] [,3] 361s [1,] 1.1 17.1 33.1 361s [2,] 2.1 18.1 34.1 361s [3,] 3.1 19.1 35.1 361s [4,] 4.1 20.1 36.1 361s [5,] 5.1 21.1 37.1 361s [6,] 6.1 22.1 38.1 361s [7,] 7.1 23.1 39.1 361s [8,] 8.1 24.1 40.1 361s > 361s > 361s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 361s > # Test with a single quantile 361s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 361s > for (mode in c("logical", "integer", "double")) { 361s + cat("mode: ", mode, "\n", sep = "") 361s + x <- matrix(1:40, nrow = 8, ncol = 5) 361s + storage.mode(x) <- mode 361s + dimnames <- lapply(dim(x), FUN = function(n) letters[seq_len(n)]) 361s + str(x) 361s + 361s + probs <- c(0.5) 361s + # Test with and without dimnames on x 361s + for (setDimnames in c(TRUE, FALSE)) { 361s + if (setDimnames) dimnames(x) <- dimnames 361s + else dimnames(x) <- NULL 361s + # Check names attribute 361s + for (useNames in c(TRUE, FALSE)) { 361s + q0 <- rowQuantiles_R(x, probs = probs, useNames = useNames) 361s + print(q0) 361s + q1 <- rowQuantiles(x, probs = probs, useNames = useNames) 361s + print(q1) 361s + stopifnot(all.equal(q1, q0)) 361s + q2 <- colQuantiles(t(x), probs = probs, useNames = useNames) 361s + stopifnot(all.equal(q2, q0)) 361s + } 361s + } 361s + } # for (mode ...) 361s mode: logical 361s logi [1:8, 1:5] TRUE TRUE TRUE TRUE TRUE TRUE ... 361s a b c d e f g h 361s 1 1 1 1 1 1 1 1 361s a b c d e f g h 361s 1 1 1 1 1 1 1 1 361s [1] 1 1 1 1 1 1 1 1 361s [1] 1 1 1 1 1 1 1 1 361s [1] 1 1 1 1 1 1 1 1 361s [1] 1 1 1 1 1 1 1 1 361s [1] 1 1 1 1 1 1 1 1 361s [1] 1 1 1 1 1 1 1 1 361s mode: integer 361s int [1:8, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 361s a b c d e f g h 361s 17 18 19 20 21 22 23 24 361s a b c d e f g h 361s 17 18 19 20 21 22 23 24 361s [1] 17 18 19 20 21 22 23 24 361s [1] 17 18 19 20 21 22 23 24 361s [1] 17 18 19 20 21 22 23 24 361s [1] 17 18 19 20 21 22 23 24 361s [1] 17 18 19 20 21 22 23 24 361s [1] 17 18 19 20 21 22 23 24 361s mode: double 361s num [1:8, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 361s a b c d e f g h 361s 17 18 19 20 21 22 23 24 361s a b c d e f g h 361s 17 18 19 20 21 22 23 24 361s [1] 17 18 19 20 21 22 23 24 361s [1] 17 18 19 20 21 22 23 24 361s [1] 17 18 19 20 21 22 23 24 361s [1] 17 18 19 20 21 22 23 24 361s [1] 17 18 19 20 21 22 23 24 361s [1] 17 18 19 20 21 22 23 24 361s > 361s > 361s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 361s > # Consistency checks 361s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 361s > set.seed(1) 361s > 361s > probs <- seq(from = 0, to = 1, by = 0.25) 361s > 361s > cat("Consistency checks:\n") 361s Consistency checks: 361s > n_sims <- if (Sys.getenv("_R_CHECK_USE_VALGRIND_") != "") 6L else 24L 361s > for (kk in seq_len(n_sims)) { 361s + cat("Random test #", kk, "\n", sep = "") 361s + 361s + # Simulate data in a matrix of any shape 361s + dim <- sample(20:60, size = 2L) 361s + n <- prod(dim) 361s + x <- rnorm(n, sd = 100) 361s + dim(x) <- dim 361s + dimnames <- lapply(dim(x), FUN = function(n) rep(letters, length.out = n)) 361s + 361s + # Add NAs? 361s + has_na <- ((kk %% 2) == 0L) 361s + if (has_na) { 361s + cat("Adding NAs\n") 361s + nna <- sample(n, size = 1) 361s + na_values <- c(NA_real_, NaN) 361s + t <- sample(na_values, size = nna, replace = TRUE) 361s + x[sample(length(x), size = nna)] <- t 361s + } 361s + 361s + # Logical, integer, or double? 361s + mode <- "numeric" 361s + if ((kk %% 6) %in% 1:2) { 361s + cat("Coercing to logical\n") 361s + mode <- "logical" 361s + } else if ((kk %% 6) %in% 3:4) { 361s + cat("Coercing to integers\n") 361s + mode <- "integer" 361s + } 361s + storage.mode(x) <- mode 361s + 361s + str(x) 361s + 361s + # rowQuantiles(): 361s + for (type in 1:9) { 361s + cat(sprintf("type=%d, has_na=%s:\n", type, has_na)) 361s + # Test with and without dimnames on x 361s + for (setDimnames in c(TRUE, FALSE)) { 361s + if (setDimnames) dimnames(x) <- dimnames 361s + else dimnames(x) <- NULL 361s + # Check names attribute 361s + for (useNames in c(TRUE, FALSE)) { 361s + q0 <- rowQuantiles_R(x, probs = probs, na.rm = has_na, type = type, useNames = useNames) 361s + q1 <- rowQuantiles(x, probs = probs, na.rm = has_na, type = type, useNames = useNames) 361s + stopifnot(all.equal(q1, q0)) 361s + q2 <- colQuantiles(t(x), probs = probs, na.rm = has_na, type = type, useNames = useNames) 361s + stopifnot(all.equal(q2, q0)) 361s + } 361s + } 361s + } 361s + } # for (kk ...) 361s Random test #1 361s Coercing to logical 361s logi [1:23, 1:58] TRUE TRUE TRUE TRUE TRUE TRUE ... 361s type=1, has_na=FALSE: 361s type=2, has_na=FALSE: 361s type=3, has_na=FALSE: 361s type=4, has_na=FALSE: 361s type=5, has_na=FALSE: 361s type=6, has_na=FALSE: 361s type=7, has_na=FALSE: 361s type=8, has_na=FALSE: 361s type=9, has_na=FALSE: 361s Random test #2 361s Adding NAs 361s Coercing to logical 361s logi [1:58, 1:33] TRUE TRUE TRUE TRUE TRUE NA ... 361s type=1, has_na=TRUE: 362s type=2, has_na=TRUE: 362s type=3, has_na=TRUE: 362s type=4, has_na=TRUE: 362s type=5, has_na=TRUE: 362s type=6, has_na=TRUE: 362s type=7, has_na=TRUE: 362s type=8, has_na=TRUE: 362s type=9, has_na=TRUE: 362s Random test #3 362s Coercing to integers 362s int [1:28, 1:60] 119 -164 115 -129 209 -175 2 -32 120 -28 ... 362s type=1, has_na=FALSE: 362s type=2, has_na=FALSE: 362s type=3, has_na=FALSE: 362s type=4, has_na=FALSE: 362s type=5, has_na=FALSE: 362s type=6, has_na=FALSE: 362s type=7, has_na=FALSE: 362s type=8, has_na=FALSE: 362s type=9, has_na=FALSE: 362s Random test #4 362s Adding NAs 362s Coercing to integers 362s int [1:54, 1:35] 147 11 116 -50 NA -69 132 NA 114 NA ... 362s type=1, has_na=TRUE: 362s type=2, has_na=TRUE: 362s type=3, has_na=TRUE: 363s type=4, has_na=TRUE: 363s type=5, has_na=TRUE: 363s type=6, has_na=TRUE: 363s type=7, has_na=TRUE: 363s type=8, has_na=TRUE: 363s type=9, has_na=TRUE: 363s Random test #5 363s num [1:39, 1:53] 5.94 -27.16 -30.78 173 126.05 ... 363s type=1, has_na=FALSE: 363s type=2, has_na=FALSE: 363s type=3, has_na=FALSE: 363s type=4, has_na=FALSE: 363s type=5, has_na=FALSE: 363s type=6, has_na=FALSE: 363s type=7, has_na=FALSE: 363s type=8, has_na=FALSE: 363s type=9, has_na=FALSE: 363s Random test #6 363s Adding NAs 363s num [1:46, 1:22] 197 -107 15 148 -110 ... 363s type=1, has_na=TRUE: 363s type=2, has_na=TRUE: 363s type=3, has_na=TRUE: 363s type=4, has_na=TRUE: 363s type=5, has_na=TRUE: 364s type=6, has_na=TRUE: 364s type=7, has_na=TRUE: 364s type=8, has_na=TRUE: 364s type=9, has_na=TRUE: 364s Random test #7 364s Coercing to logical 364s logi [1:21, 1:51] TRUE TRUE TRUE TRUE TRUE TRUE ... 364s type=1, has_na=FALSE: 364s type=2, has_na=FALSE: 364s type=3, has_na=FALSE: 364s type=4, has_na=FALSE: 364s type=5, has_na=FALSE: 364s type=6, has_na=FALSE: 364s type=7, has_na=FALSE: 364s type=8, has_na=FALSE: 364s type=9, has_na=FALSE: 364s Random test #8 364s Adding NAs 364s Coercing to logical 364s logi [1:33, 1:53] NA NA TRUE TRUE TRUE TRUE ... 364s type=1, has_na=TRUE: 364s type=2, has_na=TRUE: 364s type=3, has_na=TRUE: 364s type=4, has_na=TRUE: 364s type=5, has_na=TRUE: 364s type=6, has_na=TRUE: 364s type=7, has_na=TRUE: 364s type=8, has_na=TRUE: 364s type=9, has_na=TRUE: 364s Random test #9 364s Coercing to integers 364s int [1:53, 1:24] -73 10 -73 -5 44 -107 -100 95 58 -50 ... 364s type=1, has_na=FALSE: 364s type=2, has_na=FALSE: 364s type=3, has_na=FALSE: 364s type=4, has_na=FALSE: 364s type=5, has_na=FALSE: 365s type=6, has_na=FALSE: 365s type=7, has_na=FALSE: 365s type=8, has_na=FALSE: 365s type=9, has_na=FALSE: 365s Random test #10 365s Adding NAs 365s Coercing to integers 365s int [1:44, 1:20] NA -140 NA -57 -252 NA NA 20 NA NA ... 365s type=1, has_na=TRUE: 365s type=2, has_na=TRUE: 365s type=3, has_na=TRUE: 365s type=4, has_na=TRUE: 365s type=5, has_na=TRUE: 365s type=6, has_na=TRUE: 365s type=7, has_na=TRUE: 365s type=8, has_na=TRUE: 365s type=9, has_na=TRUE: 365s Random test #11 365s num [1:54, 1:23] -160.87 74.13 196.08 7.27 4.92 ... 365s type=1, has_na=FALSE: 365s type=2, has_na=FALSE: 365s type=3, has_na=FALSE: 365s type=4, has_na=FALSE: 365s type=5, has_na=FALSE: 365s type=6, has_na=FALSE: 366s type=7, has_na=FALSE: 366s type=8, has_na=FALSE: 366s type=9, has_na=FALSE: 366s Random test #12 366s Adding NAs 366s num [1:59, 1:27] -139.2 -86.3 NA -40.7 NA ... 366s type=1, has_na=TRUE: 366s type=2, has_na=TRUE: 366s type=3, has_na=TRUE: 366s type=4, has_na=TRUE: 366s type=5, has_na=TRUE: 366s type=6, has_na=TRUE: 366s type=7, has_na=TRUE: 366s type=8, has_na=TRUE: 366s type=9, has_na=TRUE: 366s Random test #13 366s Coercing to logical 366s logi [1:53, 1:60] TRUE TRUE TRUE TRUE TRUE TRUE ... 366s type=1, has_na=FALSE: 366s type=2, has_na=FALSE: 366s type=3, has_na=FALSE: 366s type=4, has_na=FALSE: 367s type=5, has_na=FALSE: 367s type=6, has_na=FALSE: 367s type=7, has_na=FALSE: 367s type=8, has_na=FALSE: 367s type=9, has_na=FALSE: 367s Random test #14 367s Adding NAs 367s Coercing to logical 367s logi [1:22, 1:57] TRUE TRUE TRUE TRUE TRUE TRUE ... 367s type=1, has_na=TRUE: 367s type=2, has_na=TRUE: 367s type=3, has_na=TRUE: 367s type=4, has_na=TRUE: 367s type=5, has_na=TRUE: 367s type=6, has_na=TRUE: 367s type=7, has_na=TRUE: 367s type=8, has_na=TRUE: 367s type=9, has_na=TRUE: 367s Random test #15 367s Coercing to integers 367s int [1:20, 1:34] 78 -41 183 190 -71 37 0 -4 -86 27 ... 367s type=1, has_na=FALSE: 367s type=2, has_na=FALSE: 367s type=3, has_na=FALSE: 367s type=4, has_na=FALSE: 367s type=5, has_na=FALSE: 367s type=6, has_na=FALSE: 367s type=7, has_na=FALSE: 367s type=8, has_na=FALSE: 367s type=9, has_na=FALSE: 367s Random test #16 367s Adding NAs 367s Coercing to integers 367s int [1:42, 1:37] NA 12 -15 41 -28 17 NA -74 NA NA ... 367s type=1, has_na=TRUE: 367s type=2, has_na=TRUE: 367s type=3, has_na=TRUE: 367s type=4, has_na=TRUE: 367s type=5, has_na=TRUE: 367s type=6, has_na=TRUE: 367s type=7, has_na=TRUE: 368s type=8, has_na=TRUE: 368s type=9, has_na=TRUE: 368s Random test #17 368s num [1:42, 1:29] -50.51 -6.51 -117.59 135.58 226.87 ... 368s type=1, has_na=FALSE: 368s type=2, has_na=FALSE: 368s type=3, has_na=FALSE: 368s type=4, has_na=FALSE: 368s type=5, has_na=FALSE: 368s type=6, has_na=FALSE: 368s type=7, has_na=FALSE: 368s type=8, has_na=FALSE: 368s type=9, has_na=FALSE: 368s Random test #18 368s Adding NAs 368s num [1:57, 1:39] 223 156.8 -44.6 -127.5 -147.7 ... 368s type=1, has_na=TRUE: 368s type=2, has_na=TRUE: 368s type=3, has_na=TRUE: 368s type=4, has_na=TRUE: 368s type=5, has_na=TRUE: 368s type=6, has_na=TRUE: 368s type=7, has_na=TRUE: 368s type=8, has_na=TRUE: 369s type=9, has_na=TRUE: 369s Random test #19 369s Coercing to logical 369s logi [1:52, 1:57] TRUE TRUE TRUE TRUE TRUE TRUE ... 369s type=1, has_na=FALSE: 369s type=2, has_na=FALSE: 369s type=3, has_na=FALSE: 369s type=4, has_na=FALSE: 369s type=5, has_na=FALSE: 369s type=6, has_na=FALSE: 369s type=7, has_na=FALSE: 369s type=8, has_na=FALSE: 369s type=9, has_na=FALSE: 369s Random test #20 369s Adding NAs 369s Coercing to logical 369s logi [1:25, 1:48] NA TRUE NA NA NA NA ... 369s type=1, has_na=TRUE: 369s type=2, has_na=TRUE: 369s type=3, has_na=TRUE: 369s type=4, has_na=TRUE: 369s type=5, has_na=TRUE: 369s type=6, has_na=TRUE: 369s type=7, has_na=TRUE: 369s type=8, has_na=TRUE: 369s type=9, has_na=TRUE: 369s Random test #21 369s Coercing to integers 369s int [1:53, 1:27] 3 -30 203 -49 19 -45 -138 28 46 -44 ... 369s type=1, has_na=FALSE: 369s type=2, has_na=FALSE: 369s type=3, has_na=FALSE: 369s type=4, has_na=FALSE: 370s type=5, has_na=FALSE: 370s type=6, has_na=FALSE: 370s type=7, has_na=FALSE: 370s type=8, has_na=FALSE: 370s type=9, has_na=FALSE: 370s Random test #22 370s Adding NAs 370s Coercing to integers 370s int [1:48, 1:36] -131 NA NA -201 45 -17 NA 57 NA NA ... 370s type=1, has_na=TRUE: 370s type=2, has_na=TRUE: 370s type=3, has_na=TRUE: 370s type=4, has_na=TRUE: 370s type=5, has_na=TRUE: 370s type=6, has_na=TRUE: 370s type=7, has_na=TRUE: 370s type=8, has_na=TRUE: 370s type=9, has_na=TRUE: 370s Random test #23 370s num [1:23, 1:43] -99.2 -68.8 -86.7 -104.2 48 ... 370s type=1, has_na=FALSE: 370s type=2, has_na=FALSE: 370s type=3, has_na=FALSE: 370s type=4, has_na=FALSE: 370s type=5, has_na=FALSE: 370s type=6, has_na=FALSE: 370s type=7, has_na=FALSE: 370s type=8, has_na=FALSE: 370s type=9, has_na=FALSE: 370s Random test #24 370s Adding NAs 370s num [1:53, 1:29] NaN -67.6 10.8 -88.4 130.1 ... 370s type=1, has_na=TRUE: 371s type=2, has_na=TRUE: 371s type=3, has_na=TRUE: 371s type=4, has_na=TRUE: 371s type=5, has_na=TRUE: 371s type=6, has_na=TRUE: 371s type=7, has_na=TRUE: 371s type=8, has_na=TRUE: 371s type=9, has_na=TRUE: 371s > 371s > 371s > 371s > for (mode in c("logical", "integer", "double")) { 371s + naValue <- NA_real_ 371s + storage.mode(naValue) <- mode 371s + 371s + someValue <- 1 371s + storage.mode(someValue) <- mode 371s + 371s + for (type in 1:9) { 371s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 371s + # All NA 371s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 371s + x <- matrix(naValue, nrow = 3L, ncol = 4L) 371s + dimnames <- lapply(dim(x), FUN = function(n) letters[seq_len(n)]) 371s + # Test with and without dimnames on x 371s + for (setDimnames in c(TRUE, FALSE)) { 371s + if (setDimnames) dimnames(x) <- dimnames 371s + else dimnames(x) <- NULL 371s + # Check names attribute 371s + for (useNames in c(TRUE, FALSE)) { 371s + qr0 <- rowQuantiles_R(x, type = type, useNames = useNames) 371s + 371s + qr <- rowQuantiles(x, type = type, useNames = useNames) 371s + stopifnot(identical(qr, qr0)) 371s + 371s + # x <- matrix(naValue, nrow = 4L, ncol = 3L) 371s + qc <- colQuantiles(t(x), type = type, useNames = useNames) 371s + 371s + stopifnot(identical(qc, qr)) 371s + } 371s + } 371s + 371s + 371s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 371s + # Empty matrices 371s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 371s + probs <- c(0, 0.25, 0.75, 1) 371s + x <- matrix(naValue, nrow = 0L, ncol = 0L) 371s + dimnames(x) <- lapply(dim(x), FUN = function(n) letters[seq_len(n)]) 371s + q <- rowQuantiles(x, probs = probs, type = type, useNames = TRUE) 371s + stopifnot(identical(dim(q), c(nrow(x), length(probs)))) 371s + q <- colQuantiles(x, probs = probs, type = type, useNames = TRUE) 371s + stopifnot(identical(dim(q), c(ncol(x), length(probs)))) 371s + 371s + x <- matrix(naValue, nrow = 2L, ncol = 0L) 371s + dimnames(x) <- lapply(dim(x), FUN = function(n) letters[seq_len(n)]) 371s + q <- rowQuantiles(x, probs = probs, type = type, useNames = TRUE) 371s + stopifnot(identical(dim(q), c(nrow(x), length(probs)))) 371s + 371s + x <- matrix(naValue, nrow = 0L, ncol = 2L) 371s + dimnames(x) <- lapply(dim(x), FUN = function(n) letters[seq_len(n)]) 371s + q <- colQuantiles(x, probs = probs, type = type, useNames = TRUE) 371s + stopifnot(identical(dim(q), c(ncol(x), length(probs)))) 371s + 371s + 371s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 371s + # Single column matrices 371s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 371s + probs <- c(0, 0.25, 0.75, 1) 371s + x <- matrix(someValue, nrow = 2L, ncol = 1L) 371s + dimnames(x) <- lapply(dim(x), FUN = function(n) letters[seq_len(n)]) 371s + qr <- rowQuantiles(x, probs = probs, type = type, useNames = TRUE) 371s + print(qr) 371s + 371s + x <- matrix(someValue, nrow = 1L, ncol = 2L) 371s + dimnames(x) <- lapply(dim(x), FUN = function(n) letters[seq_len(n)]) 371s + qc <- colQuantiles(x, probs = probs, type = type, useNames = TRUE) 371s + print(qc) 371s + 371s + stopifnot(identical(qc, qr)) 371s + } 371s + } 371s 0% 25% 75% 100% 371s a 1 1 1 1 371s b 1 1 1 1 371s 0% 25% 75% 100% 371s a 1 1 1 1 371s b 1 1 1 1 371s 0% 25% 75% 100% 371s a 1 1 1 1 371s b 1 1 1 1 371s 0% 25% 75% 100% 371s a 1 1 1 1 371s b 1 1 1 1 371s 0% 25% 75% 100% 371s a 1 1 1 1 371s b 1 1 1 1 371s 0% 25% 75% 100% 371s a 1 1 1 1 371s b 1 1 1 1 371s 0% 25% 75% 100% 371s a 1 1 1 1 371s b 1 1 1 1 371s 0% 25% 75% 100% 371s a 1 1 1 1 371s b 1 1 1 1 371s 0% 25% 75% 100% 371s a 1 1 1 1 371s b 1 1 1 1 371s 0% 25% 75% 100% 371s a 1 1 1 1 371s b 1 1 1 1 371s 0% 25% 75% 100% 371s a 1 1 1 1 371s b 1 1 1 1 371s 0% 25% 75% 100% 371s a 1 1 1 1 371s b 1 1 1 1 371s 0% 25% 75% 100% 371s a 1 1 1 1 371s b 1 1 1 1 371s 0% 25% 75% 100% 371s a 1 1 1 1 371s b 1 1 1 1 371s 0% 25% 75% 100% 371s a 1 1 1 1 371s b 1 1 1 1 371s 0% 25% 75% 100% 371s a 1 1 1 1 371s b 1 1 1 1 371s 0% 25% 75% 100% 371s a 1 1 1 1 371s b 1 1 1 1 371s 0% 25% 75% 100% 371s a 1 1 1 1 371s b 1 1 1 1 371s 0% 25% 75% 100% 371s a 1 1 1 1 371s b 1 1 1 1 371s 0% 25% 75% 100% 371s a 1 1 1 1 371s b 1 1 1 1 371s 0% 25% 75% 100% 371s a 1 1 1 1 371s b 1 1 1 1 371s 0% 25% 75% 100% 371s a 1 1 1 1 371s b 1 1 1 1 371s 0% 25% 75% 100% 371s a 1 1 1 1 371s b 1 1 1 1 371s 0% 25% 75% 100% 371s a 1 1 1 1 371s b 1 1 1 1 371s 0% 25% 75% 100% 371s a 1 1 1 1 371s b 1 1 1 1 371s 0% 25% 75% 100% 371s a 1 1 1 1 371s b 1 1 1 1 371s 0% 25% 75% 100% 371s a 1 1 1 1 371s b 1 1 1 1 371s 0% 25% 75% 100% 371s a 1 1 1 1 371s b 1 1 1 1 371s 0% 25% 75% 100% 371s a 1 1 1 1 371s b 1 1 1 1 371s 0% 25% 75% 100% 371s a 1 1 1 1 371s b 1 1 1 1 371s 0% 25% 75% 100% 371s a 1 1 1 1 371s b 1 1 1 1 371s 0% 25% 75% 100% 371s a 1 1 1 1 371s b 1 1 1 1 371s 0% 25% 75% 100% 371s a 1 1 1 1 371s b 1 1 1 1 371s 0% 25% 75% 100% 371s a 1 1 1 1 371s b 1 1 1 1 371s 0% 25% 75% 100% 371s a 1 1 1 1 371s b 1 1 1 1 371s 0% 25% 75% 100% 371s a 1 1 1 1 371s b 1 1 1 1 371s 0% 25% 75% 100% 371s a 1 1 1 1 371s b 1 1 1 1 371s 0% 25% 75% 100% 371s a 1 1 1 1 371s b 1 1 1 1 371s 0% 25% 75% 100% 371s a 1 1 1 1 371s b 1 1 1 1 371s 0% 25% 75% 100% 371s a 1 1 1 1 371s b 1 1 1 1 371s 0% 25% 75% 100% 371s a 1 1 1 1 371s b 1 1 1 1 371s 0% 25% 75% 100% 371s a 1 1 1 1 371s b 1 1 1 1 371s 0% 25% 75% 100% 371s a 1 1 1 1 371s b 1 1 1 1 371s 0% 25% 75% 100% 371s a 1 1 1 1 371s b 1 1 1 1 371s 0% 25% 75% 100% 371s a 1 1 1 1 371s b 1 1 1 1 371s 0% 25% 75% 100% 371s a 1 1 1 1 371s b 1 1 1 1 371s 0% 25% 75% 100% 371s a 1 1 1 1 371s b 1 1 1 1 371s 0% 25% 75% 100% 371s a 1 1 1 1 371s b 1 1 1 1 371s 0% 25% 75% 100% 371s a 1 1 1 1 371s b 1 1 1 1 371s 0% 25% 75% 100% 371s a 1 1 1 1 371s b 1 1 1 1 371s 0% 25% 75% 100% 371s a 1 1 1 1 371s b 1 1 1 1 371s 0% 25% 75% 100% 371s a 1 1 1 1 371s b 1 1 1 1 371s 0% 25% 75% 100% 371s a 1 1 1 1 371s b 1 1 1 1 371s 0% 25% 75% 100% 371s a 1 1 1 1 371s b 1 1 1 1 371s > 371s 371s R version 4.4.3 (2025-02-28) -- "Trophy Case" 371s Copyright (C) 2025 The R Foundation for Statistical Computing 371s Platform: aarch64-unknown-linux-gnu 371s 371s R is free software and comes with ABSOLUTELY NO WARRANTY. 371s You are welcome to redistribute it under certain conditions. 371s Type 'license()' or 'licence()' for distribution details. 371s 371s R is a collaborative project with many contributors. 371s Type 'contributors()' for more information and 371s 'citation()' on how to cite R or R packages in publications. 371s 371s Type 'demo()' for some demos, 'help()' for on-line help, or 371s 'help.start()' for an HTML browser interface to help. 371s Type 'q()' to quit R. 371s 371s > library("matrixStats") 371s > 371s > ## Create isFALSE() if running on an old version of R 371s > if (!exists("isFALSE", mode="function")) { 371s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 371s + } 371s > 371s > rowQuantiles_R <- function(x, probs, na.rm = FALSE, drop = TRUE, ..., useNames = TRUE) { 371s + q <- apply(x, MARGIN = 1L, FUN = function(x, probs, na.rm) { 371s + if (!na.rm && any(is.na(x))) { 371s + na_value <- NA_real_ 371s + storage.mode(na_value) <- storage.mode(x) 371s + rep(na_value, times = length(probs)) 371s + 371s + } else { 371s + as.vector(quantile(x, probs = probs, na.rm = na.rm, names = FALSE, ...)) 371s + } 371s + }, probs = probs, na.rm = na.rm) 371s + 371s + if (!is.null(dim(q))) q <- t(q) 371s + else dim(q) <- c(nrow(x), length(probs)) 371s + 371s + colnames(q) <- matrixStats:::quantile_probs_names(probs) 371s + rownames(q) <- rownames(x) 371s + if (isFALSE(useNames)) dimnames(q) <- NULL 371s + 371s + if (drop) q <- drop(q) 371s + q 371s + } 371s > 371s > 371s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 371s > # Subsetted tests 371s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 371s > source("utils/validateIndicesFramework.R") 371s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 371s > dimnames <- lapply(dim(x), FUN = function(n) letters[seq_len(n)]) 371s > probs <- c(0, 0.25, 0.75, 1) 371s > # Test with and without dimnames on x 371s > for (setDimnames in c(TRUE, FALSE)) { 371s + if (setDimnames) dimnames(x) <- dimnames 371s + else dimnames(x) <- NULL 371s + 371s + count <- 0L 371s + for (rows in index_cases) { 371s + for (cols in index_cases) { 371s + count <- count + 1L 371s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 371s + useNames <- c(TRUE, FALSE) 371s + useNames <- useNames[count %% length(useNames) + 1] 371s + 371s + validateIndicesTestMatrix(x, rows, cols, 371s + ftest = rowQuantiles, fsure = rowQuantiles_R, 371s + probs = probs, na.rm = na.rm, drop = FALSE, useNames = useNames) 371s + validateIndicesTestMatrix(x, rows, cols, 371s + fcoltest = colQuantiles, fsure = rowQuantiles_R, 371s + probs = probs, na.rm = na.rm, drop = FALSE, useNames = useNames) 371s + } 371s + } 371s + } 373s > 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: aarch64-unknown-linux-gnu 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 > rowMins_R <- function(x, ..., useNames = TRUE) { 373s + suppressWarnings({ 373s + res <- apply(x, MARGIN = 1L, FUN = min, ...) 373s + }) 373s + if (!useNames) names(res) <- NULL 373s + res 373s + } # rowMins_R() 373s > 373s > rowMaxs_R <- function(x, ..., useNames = TRUE) { 373s + suppressWarnings({ 373s + res <- apply(x, MARGIN = 1L, FUN = max, ...) 373s + }) 373s + if (!useNames) names(res) <- NULL 373s + res 373s + } # rowMaxs_R() 373s > 373s > rowRanges_R <- function(x, ..., useNames = TRUE) { 373s + suppressWarnings({ 373s + ans <- t(apply(x, MARGIN = 1L, FUN = range, ...)) 373s + }) 373s + 373s + # Preserve rownames attribute 373s + dim <- c(dim(x)[1], 2L) 373s + if (!isTRUE(all.equal(dim(ans), dim))) { 373s + dim(ans) <- dim 373s + rownames <- rownames(x) 373s + if (!is.null(dimnames)) rownames(ans) <- rownames 373s + } 373s + if (!useNames) dimnames(ans) <- NULL 373s + ans 373s + } # rowRanges_R() 373s > 373s > 373s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 373s > # With and without some NAs 373s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 373s > for (mode in c("integer", "double")) { 373s + cat("mode: ", mode, "\n", sep = "") 373s + 373s + for (add_na in c(FALSE, TRUE)) { 373s + cat("add_na = ", add_na, "\n", sep = "") 373s + 373s + x <- matrix(1:50 + 0.1, nrow = 10L, ncol = 5L) 373s + if (add_na) { 373s + x[3:7, c(2, 4)] <- NA_real_ 373s + } 373s + storage.mode(x) <- mode 373s + str(x) 373s + 373s + # To check names attribute 373s + dimnames <- list(letters[1:10], LETTERS[1:5]) 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 + # Row/column extremes 373s + for (na.rm in c(FALSE, TRUE)) { 373s + # Check names attribute 373s + for (useNames in c(TRUE, FALSE)) { 373s + cat("na.rm = ", na.rm, "\n", sep = "") 373s + 373s + # Ranges 373s + cat("range:\n") 373s + r0 <- rowRanges_R(x, na.rm = na.rm, useNames = useNames) 373s + r1 <- rowRanges(x, na.rm = na.rm, useNames = useNames) 373s + r2 <- colRanges(t(x), na.rm = na.rm, useNames = useNames) 373s + stopifnot(all.equal(r1, r2)) 373s + stopifnot(all.equal(r1, r0)) 373s + 373s + # Min 373s + cat("min:\n") 373s + m0 <- rowMins_R(x, na.rm = na.rm, useNames = useNames) 373s + m1 <- rowMins(x, na.rm = na.rm, useNames = useNames) 373s + m2 <- colMins(t(x), na.rm = na.rm, useNames = useNames) 373s + stopifnot(all.equal(m1, m2)) 373s + stopifnot(all.equal(m1, m0)) 373s + 373s + # Max 373s + cat("max:\n") 373s + m0 <- rowMaxs_R(x, na.rm = na.rm, useNames = useNames) 373s + m1 <- rowMaxs(x, na.rm = na.rm, useNames = useNames) 373s + m2 <- colMaxs(t(x), na.rm = na.rm, useNames = useNames) 373s + stopifnot(all.equal(m1, m2)) 373s + stopifnot(all.equal(m1, m0)) 373s + } 373s + } 373s + } 373s + } # for (add_na ...) 373s + } # for (mode ...) 373s mode: integer 373s add_na = FALSE 373s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 373s na.rm = FALSE 373s range: 373s min: 373s max: 373s na.rm = FALSE 373s range: 373s min: 373s max: 373s na.rm = TRUE 373s range: 373s min: 373s max: 373s na.rm = TRUE 373s range: 373s min: 373s max: 373s na.rm = FALSE 373s range: 373s min: 373s max: 373s na.rm = FALSE 373s range: 373s min: 373s max: 373s na.rm = TRUE 373s range: 373s min: 373s max: 373s na.rm = TRUE 373s range: 373s min: 373s max: 373s add_na = TRUE 373s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 373s na.rm = FALSE 373s range: 373s min: 373s max: 373s na.rm = FALSE 373s range: 373s min: 373s max: 373s na.rm = TRUE 373s range: 373s min: 373s max: 373s na.rm = TRUE 373s range: 373s min: 373s max: 373s na.rm = FALSE 373s range: 373s min: 373s max: 373s na.rm = FALSE 373s range: 373s min: 373s max: 373s na.rm = TRUE 373s range: 373s min: 373s max: 373s na.rm = TRUE 373s range: 373s min: 373s max: 373s mode: double 373s add_na = FALSE 373s 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 ... 373s na.rm = FALSE 373s range: 373s min: 373s max: 373s na.rm = FALSE 373s range: 373s min: 373s max: 373s na.rm = TRUE 373s range: 373s min: 373s max: 373s na.rm = TRUE 373s range: 373s min: 373s max: 373s na.rm = FALSE 373s range: 373s min: 373s max: 373s na.rm = FALSE 373s range: 373s min: 373s max: 373s na.rm = TRUE 373s range: 373s min: 373s max: 373s na.rm = TRUE 373s range: 373s min: 373s max: 373s add_na = TRUE 373s 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 ... 373s na.rm = FALSE 373s range: 373s min: 373s max: 373s na.rm = FALSE 373s range: 373s min: 373s max: 373s na.rm = TRUE 373s range: 373s min: 373s max: 373s na.rm = TRUE 373s range: 373s min: 373s max: 373s na.rm = FALSE 373s range: 373s min: 373s max: 373s na.rm = FALSE 373s range: 373s min: 373s max: 373s na.rm = TRUE 373s range: 373s min: 373s max: 373s na.rm = TRUE 373s range: 373s min: 373s max: 373s > 373s > 373s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 373s > # All NAs 373s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 373s > for (mode in c("integer", "double")) { 373s + cat("mode: ", mode, "\n", sep = "") 373s + x <- matrix(NA_real_, nrow = 10L, ncol = 5L) 373s + storage.mode(x) <- mode 373s + str(x) 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 (na.rm in c(FALSE, TRUE)) { 373s + # Check names attribute 373s + for (useNames in c(TRUE, FALSE)) { 373s + cat("na.rm = ", na.rm, "\n", sep = "") 373s + r0 <- rowRanges_R(x, na.rm = na.rm, useNames = useNames) 373s + r1 <- rowRanges(x, na.rm = na.rm, useNames = useNames) 373s + r2 <- colRanges(t(x), na.rm = na.rm, useNames = useNames) 373s + stopifnot(all.equal(r1, r2)) 373s + stopifnot(all.equal(r1, r0)) 373s + } 373s + } 373s + } 373s + } # for (mode ...) 373s mode: integer 373s int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 373s na.rm = FALSE 373s na.rm = FALSE 373s na.rm = TRUE 373s na.rm = TRUE 373s na.rm = FALSE 373s na.rm = FALSE 373s na.rm = TRUE 373s na.rm = TRUE 373s mode: double 373s num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 373s na.rm = FALSE 373s na.rm = FALSE 373s na.rm = TRUE 373s na.rm = TRUE 373s na.rm = FALSE 373s na.rm = FALSE 373s na.rm = TRUE 373s na.rm = TRUE 373s > 373s > 373s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 373s > # Special cases 373s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 373s > # Nx0 matrix 373s > x <- matrix(double(0L), nrow = 5L, ncol = 0L) 373s > r0 <- rowRanges_R(x) 373s > #r1 <- rowRanges(x) 373s > #r_truth <- matrix(c(Inf, -Inf), nrow = nrow(x), ncol = 2L, byrow = TRUE) 373s > #stopifnot(all.equal(r1, r_truth)) 373s > 373s > # 0xN matrix 373s > x <- t(x) 373s > #r1 <- colRanges(x) 373s > #stopifnot(all.equal(r1, r_truth)) 373s > 373s > # Nx1 matrix 373s > x <- matrix(1:5, nrow = 5L, ncol = 1L) 373s > # To check names attribute 373s > dimnames <- list(letters[1:5], "A") 373s > r1 <- rowRanges(x) 373s > r_truth <- matrix(1:5, nrow = nrow(x), ncol = 2L, byrow = FALSE) 373s > stopifnot(all.equal(r1, r_truth)) 373s > # Check names attribute 373s > dimnames(x) <- dimnames 373s > r0 <- rowRanges_R(x, useNames = TRUE) 373s > r1 <- rowRanges(x, useNames = TRUE) 373s > stopifnot(all.equal(r1, r0)) 373s > dimnames(x) <- NULL 373s > 373s > # 1xN matrix 373s > x <- t(x) 373s > r1 <- colRanges(x) 373s > stopifnot(all.equal(r1, r_truth)) 373s > # Check names attribute 373s > dimnames(x) <- list("a", LETTERS[1:5]) 373s > r1 <- colRanges(x, useNames = TRUE) 373s > stopifnot(identical(rownames(r1), colnames(x))) 373s > 373s > 373s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 373s > # Additional tests with NA_integer_, NA_real, NaN, -Inf, +Inf 373s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 373s > x <- matrix(1:12, nrow = 4L, ncol = 3L) 373s > 373s > na_list <- list( 373s + "integer" = matrix(1:12, nrow = 4L, ncol = 3L), 373s + "integer w/ NA" = matrix(NA_integer_, nrow = 4L, ncol = 3L), 373s + "real" = matrix(as.double(1:12), nrow = 4L, ncol = 3L), 373s + "real w/ NA" = matrix(NA_real_, nrow = 4L, ncol = 3L) 373s + ) 373s > 373s > na <- na_list[["real"]] 373s > na[2, 2] <- NA 373s > na_list[["real + NA cell"]] <- na 373s > 373s > na <- na_list[["real"]] 373s > na[2, ] <- NA 373s > na_list[["real + NA row"]] <- na 373s > 373s > na <- na_list[["real"]] 373s > na[2, ] <- NaN 373s > na_list[["real + NaN row"]] <- na 373s > 373s > na <- na_list[["real"]] 373s > na[2, 2] <- Inf 373s > na_list[["real + Inf cell"]] <- na 373s > 373s > na <- na_list[["real"]] 373s > na[2, ] <- Inf 373s > na_list[["real + Inf row"]] <- na 373s > 373s > na <- na_list[["real"]] 373s > na[2, 2] <- NaN 373s > na_list[["real + NaN cell"]] <- na 373s > 373s > na <- na_list[["real w/ NA"]] 373s > na[2, 2] <- NaN 373s > na_list[["real w/ NA + NaN cell"]] <- na 373s > 373s > na <- na_list[["real w/ NA"]] 373s > na[2, ] <- NaN 373s > na_list[["real w/ NA + NaN row"]] <- na 373s > 373s > # To check names attribute 373s > dimnames <- list(letters[1:4], LETTERS[1:3]) 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 (na.rm in c(FALSE, TRUE)) { 373s + for (name in names(na_list)) { 373s + # Check names attribute 373s + for (useNames in c(TRUE, FALSE)) { 373s + na <- na_list[[name]] 373s + cat(sprintf("%s (%s) w/ na.rm = %s:\n", name, typeof(na), na.rm)) 373s + print(na) 373s + 373s + cat(" min:\n") 373s + y0 <- rowMins_R(na, na.rm = na.rm, useNames = useNames) 373s + str(y0) 373s + y1 <- rowMins(na, na.rm = na.rm, useNames = useNames) 373s + str(y1) 373s + stopifnot(all.equal(y1, y0)) 373s + y1c <- colMins(t(na), na.rm = na.rm, useNames = useNames) 373s + str(y1c) 373s + stopifnot(all.equal(y1c, y1)) 373s + 373s + cat(" max:\n") 373s + y0 <- rowMaxs_R(na, na.rm = na.rm, useNames = useNames) 373s + str(y0) 373s + y1 <- rowMaxs(na, na.rm = na.rm, useNames = useNames) 373s + str(y1) 373s + stopifnot(all.equal(y1, y0)) 373s + y1c <- colMaxs(t(na), na.rm = na.rm, useNames = useNames) 373s + str(y1c) 373s + stopifnot(all.equal(y1c, y1)) 373s + 373s + cat(" range:\n") 373s + y0 <- rowRanges_R(na, na.rm = na.rm, useNames = useNames) 373s + str(y0) 373s + y1 <- rowRanges(na, na.rm = na.rm, useNames = useNames) 373s + str(y1) 373s + stopifnot(all.equal(y1, y0)) 373s + y1c <- colRanges(t(na), na.rm = na.rm, useNames = useNames) 373s + str(y1c) 373s + stopifnot(all.equal(y1c, y1)) 373s + } 373s + } # for (name ...) 373s + } # for (na.rm ...) 373s + } 373s integer (integer) w/ na.rm = FALSE: 373s [,1] [,2] [,3] 373s [1,] 1 5 9 373s [2,] 2 6 10 373s [3,] 3 7 11 373s [4,] 4 8 12 373s min: 373s int [1:4] 1 2 3 4 373s int [1:4] 1 2 3 4 373s int [1:4] 1 2 3 4 373s max: 373s int [1:4] 9 10 11 12 373s int [1:4] 9 10 11 12 373s int [1:4] 9 10 11 12 373s range: 373s int [1:4, 1:2] 1 2 3 4 9 10 11 12 373s int [1:4, 1:2] 1 2 3 4 9 10 11 12 373s int [1:4, 1:2] 1 2 3 4 9 10 11 12 373s integer (integer) w/ na.rm = FALSE: 373s [,1] [,2] [,3] 373s [1,] 1 5 9 373s [2,] 2 6 10 373s [3,] 3 7 11 373s [4,] 4 8 12 373s min: 373s int [1:4] 1 2 3 4 373s int [1:4] 1 2 3 4 373s int [1:4] 1 2 3 4 373s max: 373s int [1:4] 9 10 11 12 373s int [1:4] 9 10 11 12 373s int [1:4] 9 10 11 12 373s range: 373s int [1:4, 1:2] 1 2 3 4 9 10 11 12 373s int [1:4, 1:2] 1 2 3 4 9 10 11 12 373s int [1:4, 1:2] 1 2 3 4 9 10 11 12 373s integer w/ NA (integer) w/ na.rm = FALSE: 373s [,1] [,2] [,3] 373s [1,] NA NA NA 373s [2,] NA NA NA 373s [3,] NA NA NA 373s [4,] NA NA NA 373s min: 373s int [1:4] NA NA NA NA 373s int [1:4] NA NA NA NA 373s int [1:4] NA NA NA NA 373s max: 373s int [1:4] NA NA NA NA 373s int [1:4] NA NA NA NA 373s int [1:4] NA NA NA NA 373s range: 373s int [1:4, 1:2] NA NA NA NA NA NA NA NA 373s int [1:4, 1:2] NA NA NA NA NA NA NA NA 373s int [1:4, 1:2] NA NA NA NA NA NA NA NA 373s integer w/ NA (integer) w/ na.rm = FALSE: 373s [,1] [,2] [,3] 373s [1,] NA NA NA 373s [2,] NA NA NA 373s [3,] NA NA NA 373s [4,] NA NA NA 373s min: 373s int [1:4] NA NA NA NA 373s int [1:4] NA NA NA NA 373s int [1:4] NA NA NA NA 373s max: 373s int [1:4] NA NA NA NA 373s int [1:4] NA NA NA NA 373s int [1:4] NA NA NA NA 373s range: 373s int [1:4, 1:2] NA NA NA NA NA NA NA NA 373s int [1:4, 1:2] NA NA NA NA NA NA NA NA 373s int [1:4, 1:2] NA NA NA NA NA NA NA NA 373s real (double) w/ na.rm = FALSE: 373s [,1] [,2] [,3] 373s [1,] 1 5 9 373s [2,] 2 6 10 373s [3,] 3 7 11 373s [4,] 4 8 12 373s min: 373s num [1:4] 1 2 3 4 373s num [1:4] 1 2 3 4 373s num [1:4] 1 2 3 4 373s max: 373s num [1:4] 9 10 11 12 373s num [1:4] 9 10 11 12 373s num [1:4] 9 10 11 12 373s range: 373s num [1:4, 1:2] 1 2 3 4 9 10 11 12 373s num [1:4, 1:2] 1 2 3 4 9 10 11 12 373s num [1:4, 1:2] 1 2 3 4 9 10 11 12 373s real (double) w/ na.rm = FALSE: 373s [,1] [,2] [,3] 373s [1,] 1 5 9 373s [2,] 2 6 10 373s [3,] 3 7 11 373s [4,] 4 8 12 373s min: 373s num [1:4] 1 2 3 4 373s num [1:4] 1 2 3 4 373s num [1:4] 1 2 3 4 373s max: 373s num [1:4] 9 10 11 12 373s num [1:4] 9 10 11 12 373s num [1:4] 9 10 11 12 373s range: 373s num [1:4, 1:2] 1 2 3 4 9 10 11 12 373s num [1:4, 1:2] 1 2 3 4 9 10 11 12 373s num [1:4, 1:2] 1 2 3 4 9 10 11 12 373s real w/ NA (double) w/ na.rm = FALSE: 373s [,1] [,2] [,3] 373s [1,] NA NA NA 373s [2,] NA NA NA 373s [3,] NA NA NA 373s [4,] NA NA NA 373s min: 373s num [1:4] NA NA NA NA 373s num [1:4] NA NA NA NA 373s num [1:4] NA NA NA NA 373s max: 373s num [1:4] NA NA NA NA 373s num [1:4] NA NA NA NA 373s num [1:4] NA NA NA NA 373s range: 373s num [1:4, 1:2] NA NA NA NA NA NA NA NA 373s num [1:4, 1:2] NA NA NA NA NA NA NA NA 373s num [1:4, 1:2] NA NA NA NA NA NA NA NA 373s real w/ NA (double) w/ na.rm = FALSE: 373s [,1] [,2] [,3] 373s [1,] NA NA NA 373s [2,] NA NA NA 373s [3,] NA NA NA 373s [4,] NA NA NA 373s min: 373s num [1:4] NA NA NA NA 373s num [1:4] NA NA NA NA 373s num [1:4] NA NA NA NA 373s max: 373s num [1:4] NA NA NA NA 373s num [1:4] NA NA NA NA 373s num [1:4] NA NA NA NA 373s range: 373s num [1:4, 1:2] NA NA NA NA NA NA NA NA 373s num [1:4, 1:2] NA NA NA NA NA NA NA NA 373s num [1:4, 1:2] NA NA NA NA NA NA NA NA 373s real + NA cell (double) w/ na.rm = FALSE: 373s [,1] [,2] [,3] 373s [1,] 1 5 9 373s [2,] 2 NA 10 373s [3,] 3 7 11 373s [4,] 4 8 12 373s min: 373s num [1:4] 1 NA 3 4 373s num [1:4] 1 NA 3 4 373s num [1:4] 1 NA 3 4 373s max: 373s num [1:4] 9 NA 11 12 373s num [1:4] 9 NA 11 12 373s num [1:4] 9 NA 11 12 373s range: 373s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 373s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 373s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 373s real + NA cell (double) w/ na.rm = FALSE: 373s [,1] [,2] [,3] 373s [1,] 1 5 9 373s [2,] 2 NA 10 373s [3,] 3 7 11 373s [4,] 4 8 12 373s min: 373s num [1:4] 1 NA 3 4 373s num [1:4] 1 NA 3 4 373s num [1:4] 1 NA 3 4 373s max: 373s num [1:4] 9 NA 11 12 373s num [1:4] 9 NA 11 12 373s num [1:4] 9 NA 11 12 373s range: 373s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 373s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 373s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 373s real + NA row (double) w/ na.rm = FALSE: 373s [,1] [,2] [,3] 373s [1,] 1 5 9 373s [2,] NA NA NA 373s [3,] 3 7 11 373s [4,] 4 8 12 373s min: 373s num [1:4] 1 NA 3 4 373s num [1:4] 1 NA 3 4 373s num [1:4] 1 NA 3 4 373s max: 373s num [1:4] 9 NA 11 12 373s num [1:4] 9 NA 11 12 373s num [1:4] 9 NA 11 12 373s range: 373s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 373s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 373s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 373s real + NA row (double) w/ na.rm = FALSE: 373s [,1] [,2] [,3] 373s [1,] 1 5 9 373s [2,] NA NA NA 373s [3,] 3 7 11 373s [4,] 4 8 12 373s min: 373s num [1:4] 1 NA 3 4 373s num [1:4] 1 NA 3 4 373s num [1:4] 1 NA 3 4 373s max: 373s num [1:4] 9 NA 11 12 373s num [1:4] 9 NA 11 12 373s num [1:4] 9 NA 11 12 373s range: 373s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 373s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 373s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 373s real + NaN row (double) w/ na.rm = FALSE: 373s [,1] [,2] [,3] 373s [1,] 1 5 9 373s [2,] NaN NaN NaN 373s [3,] 3 7 11 373s [4,] 4 8 12 373s min: 373s num [1:4] 1 NaN 3 4 373s num [1:4] 1 NaN 3 4 373s num [1:4] 1 NaN 3 4 373s max: 373s num [1:4] 9 NaN 11 12 373s num [1:4] 9 NaN 11 12 373s num [1:4] 9 NaN 11 12 373s range: 373s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 373s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 373s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 373s real + NaN row (double) w/ na.rm = FALSE: 373s [,1] [,2] [,3] 373s [1,] 1 5 9 373s [2,] NaN NaN NaN 373s [3,] 3 7 11 373s [4,] 4 8 12 373s min: 373s num [1:4] 1 NaN 3 4 373s num [1:4] 1 NaN 3 4 373s num [1:4] 1 NaN 3 4 373s max: 373s num [1:4] 9 NaN 11 12 373s num [1:4] 9 NaN 11 12 373s num [1:4] 9 NaN 11 12 373s range: 373s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 373s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 373s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 373s real + Inf cell (double) w/ na.rm = FALSE: 373s [,1] [,2] [,3] 373s [1,] 1 5 9 373s [2,] 2 Inf 10 373s [3,] 3 7 11 373s [4,] 4 8 12 373s min: 373s num [1:4] 1 2 3 4 373s num [1:4] 1 2 3 4 373s num [1:4] 1 2 3 4 373s max: 373s num [1:4] 9 Inf 11 12 373s num [1:4] 9 Inf 11 12 373s num [1:4] 9 Inf 11 12 373s range: 373s num [1:4, 1:2] 1 2 3 4 9 ... 373s num [1:4, 1:2] 1 2 3 4 9 ... 373s num [1:4, 1:2] 1 2 3 4 9 ... 373s real + Inf cell (double) w/ na.rm = FALSE: 373s [,1] [,2] [,3] 373s [1,] 1 5 9 373s [2,] 2 Inf 10 373s [3,] 3 7 11 373s [4,] 4 8 12 373s min: 373s num [1:4] 1 2 3 4 373s num [1:4] 1 2 3 4 373s num [1:4] 1 2 3 4 373s max: 373s num [1:4] 9 Inf 11 12 373s num [1:4] 9 Inf 11 12 373s num [1:4] 9 Inf 11 12 373s range: 373s num [1:4, 1:2] 1 2 3 4 9 ... 373s num [1:4, 1:2] 1 2 3 4 9 ... 373s num [1:4, 1:2] 1 2 3 4 9 ... 373s real + Inf row (double) w/ na.rm = FALSE: 373s [,1] [,2] [,3] 373s [1,] 1 5 9 373s [2,] Inf Inf Inf 373s [3,] 3 7 11 373s [4,] 4 8 12 373s min: 373s num [1:4] 1 Inf 3 4 373s num [1:4] 1 Inf 3 4 373s num [1:4] 1 Inf 3 4 373s max: 373s num [1:4] 9 Inf 11 12 373s num [1:4] 9 Inf 11 12 373s num [1:4] 9 Inf 11 12 373s range: 373s num [1:4, 1:2] 1 Inf 3 4 9 ... 373s num [1:4, 1:2] 1 Inf 3 4 9 ... 373s num [1:4, 1:2] 1 Inf 3 4 9 ... 373s real + Inf row (double) w/ na.rm = FALSE: 373s [,1] [,2] [,3] 373s [1,] 1 5 9 373s [2,] Inf Inf Inf 373s [3,] 3 7 11 373s [4,] 4 8 12 373s min: 373s num [1:4] 1 Inf 3 4 373s num [1:4] 1 Inf 3 4 373s num [1:4] 1 Inf 3 4 373s max: 373s num [1:4] 9 Inf 11 12 373s num [1:4] 9 Inf 11 12 373s num [1:4] 9 Inf 11 12 373s range: 373s num [1:4, 1:2] 1 Inf 3 4 9 ... 373s num [1:4, 1:2] 1 Inf 3 4 9 ... 373s num [1:4, 1:2] 1 Inf 3 4 9 ... 373s real + NaN cell (double) w/ na.rm = FALSE: 373s [,1] [,2] [,3] 373s [1,] 1 5 9 373s [2,] 2 NaN 10 373s [3,] 3 7 11 373s [4,] 4 8 12 373s min: 373s num [1:4] 1 NaN 3 4 373s num [1:4] 1 NaN 3 4 373s num [1:4] 1 NaN 3 4 373s max: 373s num [1:4] 9 NaN 11 12 373s num [1:4] 9 NaN 11 12 373s num [1:4] 9 NaN 11 12 373s range: 373s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 373s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 373s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 373s real + NaN cell (double) w/ na.rm = FALSE: 373s [,1] [,2] [,3] 373s [1,] 1 5 9 373s [2,] 2 NaN 10 373s [3,] 3 7 11 373s [4,] 4 8 12 373s min: 373s num [1:4] 1 NaN 3 4 373s num [1:4] 1 NaN 3 4 373s num [1:4] 1 NaN 3 4 373s max: 373s num [1:4] 9 NaN 11 12 373s num [1:4] 9 NaN 11 12 373s num [1:4] 9 NaN 11 12 373s range: 373s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 373s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 373s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 373s real w/ NA + NaN cell (double) w/ na.rm = FALSE: 373s [,1] [,2] [,3] 373s [1,] NA NA NA 373s [2,] NA NaN NA 373s [3,] NA NA NA 373s [4,] NA NA NA 373s min: 373s num [1:4] NA NA NA NA 373s num [1:4] NA NA NA NA 373s num [1:4] NA NA NA NA 373s max: 373s num [1:4] NA NA NA NA 373s num [1:4] NA NA NA NA 373s num [1:4] NA NA NA NA 373s range: 373s num [1:4, 1:2] NA NA NA NA NA NA NA NA 373s num [1:4, 1:2] NA NA NA NA NA NA NA NA 373s num [1:4, 1:2] NA NA NA NA NA NA NA NA 373s real w/ NA + NaN cell (double) w/ na.rm = FALSE: 373s [,1] [,2] [,3] 373s [1,] NA NA NA 373s [2,] NA NaN NA 373s [3,] NA NA NA 373s [4,] NA NA NA 373s min: 373s num [1:4] NA NA NA NA 373s num [1:4] NA NA NA NA 373s num [1:4] NA NA NA NA 373s max: 373s num [1:4] NA NA NA NA 373s num [1:4] NA NA NA NA 373s num [1:4] NA NA NA NA 373s range: 373s num [1:4, 1:2] NA NA NA NA NA NA NA NA 373s num [1:4, 1:2] NA NA NA NA NA NA NA NA 373s num [1:4, 1:2] NA NA NA NA NA NA NA NA 373s real w/ NA + NaN row (double) w/ na.rm = FALSE: 373s [,1] [,2] [,3] 373s [1,] NA NA NA 373s [2,] NaN NaN NaN 373s [3,] NA NA NA 373s [4,] NA NA NA 373s min: 373s num [1:4] NA NaN NA NA 373s num [1:4] NA NaN NA NA 373s num [1:4] NA NaN NA NA 373s max: 373s num [1:4] NA NaN NA NA 373s num [1:4] NA NaN NA NA 373s num [1:4] NA NaN NA NA 373s range: 373s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 373s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 373s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 373s real w/ NA + NaN row (double) w/ na.rm = FALSE: 373s [,1] [,2] [,3] 373s [1,] NA NA NA 373s [2,] NaN NaN NaN 373s [3,] NA NA NA 373s [4,] NA NA NA 373s min: 373s num [1:4] NA NaN NA NA 373s num [1:4] NA NaN NA NA 373s num [1:4] NA NaN NA NA 373s max: 373s num [1:4] NA NaN NA NA 373s num [1:4] NA NaN NA NA 373s num [1:4] NA NaN NA NA 373s range: 373s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 373s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 373s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 373s integer (integer) w/ na.rm = TRUE: 373s [,1] [,2] [,3] 373s [1,] 1 5 9 373s [2,] 2 6 10 373s [3,] 3 7 11 373s [4,] 4 8 12 373s min: 373s int [1:4] 1 2 3 4 373s int [1:4] 1 2 3 4 373s int [1:4] 1 2 3 4 373s max: 373s int [1:4] 9 10 11 12 373s int [1:4] 9 10 11 12 373s int [1:4] 9 10 11 12 373s range: 373s int [1:4, 1:2] 1 2 3 4 9 10 11 12 373s int [1:4, 1:2] 1 2 3 4 9 10 11 12 373s int [1:4, 1:2] 1 2 3 4 9 10 11 12 373s integer (integer) w/ na.rm = TRUE: 373s [,1] [,2] [,3] 373s [1,] 1 5 9 373s [2,] 2 6 10 373s [3,] 3 7 11 373s [4,] 4 8 12 373s min: 373s int [1:4] 1 2 3 4 373s int [1:4] 1 2 3 4 373s int [1:4] 1 2 3 4 373s max: 373s int [1:4] 9 10 11 12 373s int [1:4] 9 10 11 12 373s int [1:4] 9 10 11 12 373s range: 373s int [1:4, 1:2] 1 2 3 4 9 10 11 12 373s int [1:4, 1:2] 1 2 3 4 9 10 11 12 373s int [1:4, 1:2] 1 2 3 4 9 10 11 12 373s integer w/ NA (integer) w/ na.rm = TRUE: 373s [,1] [,2] [,3] 373s [1,] NA NA NA 373s [2,] NA NA NA 373s [3,] NA NA NA 373s [4,] NA NA NA 373s min: 373s num [1:4] Inf Inf Inf Inf 373s num [1:4] Inf Inf Inf Inf 373s num [1:4] Inf Inf Inf Inf 373s max: 373s num [1:4] -Inf -Inf -Inf -Inf 373s num [1:4] -Inf -Inf -Inf -Inf 373s num [1:4] -Inf -Inf -Inf -Inf 373s range: 373s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 373s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 373s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 373s integer w/ NA (integer) w/ na.rm = TRUE: 373s [,1] [,2] [,3] 373s [1,] NA NA NA 373s [2,] NA NA NA 373s [3,] NA NA NA 373s [4,] NA NA NA 373s min: 373s num [1:4] Inf Inf Inf Inf 373s num [1:4] Inf Inf Inf Inf 373s num [1:4] Inf Inf Inf Inf 373s max: 373s num [1:4] -Inf -Inf -Inf -Inf 373s num [1:4] -Inf -Inf -Inf -Inf 373s num [1:4] -Inf -Inf -Inf -Inf 373s range: 373s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 373s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 373s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 373s real (double) w/ na.rm = TRUE: 373s [,1] [,2] [,3] 373s [1,] 1 5 9 373s [2,] 2 6 10 373s [3,] 3 7 11 373s [4,] 4 8 12 373s min: 373s num [1:4] 1 2 3 4 373s num [1:4] 1 2 3 4 373s num [1:4] 1 2 3 4 373s max: 373s num [1:4] 9 10 11 12 373s num [1:4] 9 10 11 12 373s num [1:4] 9 10 11 12 373s range: 373s num [1:4, 1:2] 1 2 3 4 9 10 11 12 373s num [1:4, 1:2] 1 2 3 4 9 10 11 12 373s num [1:4, 1:2] 1 2 3 4 9 10 11 12 373s real (double) w/ na.rm = TRUE: 373s [,1] [,2] [,3] 373s [1,] 1 5 9 373s [2,] 2 6 10 373s [3,] 3 7 11 373s [4,] 4 8 12 373s min: 373s num [1:4] 1 2 3 4 373s num [1:4] 1 2 3 4 373s num [1:4] 1 2 3 4 373s max: 373s num [1:4] 9 10 11 12 373s num [1:4] 9 10 11 12 373s num [1:4] 9 10 11 12 373s range: 373s num [1:4, 1:2] 1 2 3 4 9 10 11 12 373s num [1:4, 1:2] 1 2 3 4 9 10 11 12 373s num [1:4, 1:2] 1 2 3 4 9 10 11 12 373s real w/ NA (double) w/ na.rm = TRUE: 373s [,1] [,2] [,3] 373s [1,] NA NA NA 373s [2,] NA NA NA 373s [3,] NA NA NA 373s [4,] NA NA NA 373s min: 373s num [1:4] Inf Inf Inf Inf 373s num [1:4] Inf Inf Inf Inf 373s num [1:4] Inf Inf Inf Inf 373s max: 373s num [1:4] -Inf -Inf -Inf -Inf 373s num [1:4] -Inf -Inf -Inf -Inf 373s num [1:4] -Inf -Inf -Inf -Inf 373s range: 373s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 373s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 373s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 373s real w/ NA (double) w/ na.rm = TRUE: 373s [,1] [,2] [,3] 373s [1,] NA NA NA 373s [2,] NA NA NA 373s [3,] NA NA NA 373s [4,] NA NA NA 373s min: 373s num [1:4] Inf Inf Inf Inf 373s num [1:4] Inf Inf Inf Inf 373s num [1:4] Inf Inf Inf Inf 373s max: 373s num [1:4] -Inf -Inf -Inf -Inf 373s num [1:4] -Inf -Inf -Inf -Inf 373s num [1:4] -Inf -Inf -Inf -Inf 373s range: 373s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 373s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 373s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 373s real + NA cell (double) w/ na.rm = TRUE: 373s [,1] [,2] [,3] 373s [1,] 1 5 9 373s [2,] 2 NA 10 373s [3,] 3 7 11 373s [4,] 4 8 12 373s min: 373s num [1:4] 1 2 3 4 373s num [1:4] 1 2 3 4 373s num [1:4] 1 2 3 4 373s max: 373s num [1:4] 9 10 11 12 373s num [1:4] 9 10 11 12 373s num [1:4] 9 10 11 12 373s range: 373s num [1:4, 1:2] 1 2 3 4 9 10 11 12 373s num [1:4, 1:2] 1 2 3 4 9 10 11 12 373s num [1:4, 1:2] 1 2 3 4 9 10 11 12 373s real + NA cell (double) w/ na.rm = TRUE: 373s [,1] [,2] [,3] 373s [1,] 1 5 9 373s [2,] 2 NA 10 373s [3,] 3 7 11 373s [4,] 4 8 12 373s min: 373s num [1:4] 1 2 3 4 373s num [1:4] 1 2 3 4 373s num [1:4] 1 2 3 4 373s max: 373s num [1:4] 9 10 11 12 373s num [1:4] 9 10 11 12 373s num [1:4] 9 10 11 12 373s range: 373s num [1:4, 1:2] 1 2 3 4 9 10 11 12 373s num [1:4, 1:2] 1 2 3 4 9 10 11 12 373s num [1:4, 1:2] 1 2 3 4 9 10 11 12 373s real + NA row (double) w/ na.rm = TRUE: 373s [,1] [,2] [,3] 373s [1,] 1 5 9 373s [2,] NA NA NA 373s [3,] 3 7 11 373s [4,] 4 8 12 373s min: 373s num [1:4] 1 Inf 3 4 373s num [1:4] 1 Inf 3 4 373s num [1:4] 1 Inf 3 4 373s max: 373s num [1:4] 9 -Inf 11 12 373s num [1:4] 9 -Inf 11 12 373s num [1:4] 9 -Inf 11 12 373s range: 373s num [1:4, 1:2] 1 Inf 3 4 9 ... 373s num [1:4, 1:2] 1 Inf 3 4 9 ... 373s num [1:4, 1:2] 1 Inf 3 4 9 ... 373s real + NA row (double) w/ na.rm = TRUE: 373s [,1] [,2] [,3] 373s [1,] 1 5 9 373s [2,] NA NA NA 373s [3,] 3 7 11 373s [4,] 4 8 12 373s min: 373s num [1:4] 1 Inf 3 4 373s num [1:4] 1 Inf 3 4 373s num [1:4] 1 Inf 3 4 373s max: 373s num [1:4] 9 -Inf 11 12 373s num [1:4] 9 -Inf 11 12 373s num [1:4] 9 -Inf 11 12 373s range: 373s num [1:4, 1:2] 1 Inf 3 4 9 ... 373s num [1:4, 1:2] 1 Inf 3 4 9 ... 373s num [1:4, 1:2] 1 Inf 3 4 9 ... 373s real + NaN row (double) w/ na.rm = TRUE: 373s [,1] [,2] [,3] 373s [1,] 1 5 9 373s [2,] NaN NaN NaN 373s [3,] 3 7 11 373s [4,] 4 8 12 373s min: 373s num [1:4] 1 Inf 3 4 373s num [1:4] 1 Inf 3 4 373s num [1:4] 1 Inf 3 4 373s max: 373s num [1:4] 9 -Inf 11 12 373s num [1:4] 9 -Inf 11 12 373s num [1:4] 9 -Inf 11 12 373s range: 373s num [1:4, 1:2] 1 Inf 3 4 9 ... 373s num [1:4, 1:2] 1 Inf 3 4 9 ... 373s num [1:4, 1:2] 1 Inf 3 4 9 ... 373s real + NaN row (double) w/ na.rm = TRUE: 373s [,1] [,2] [,3] 373s [1,] 1 5 9 373s [2,] NaN NaN NaN 373s [3,] 3 7 11 373s [4,] 4 8 12 373s min: 373s num [1:4] 1 Inf 3 4 373s num [1:4] 1 Inf 3 4 373s num [1:4] 1 Inf 3 4 373s max: 373s num [1:4] 9 -Inf 11 12 373s num [1:4] 9 -Inf 11 12 373s num [1:4] 9 -Inf 11 12 373s range: 373s num [1:4, 1:2] 1 Inf 3 4 9 ... 373s num [1:4, 1:2] 1 Inf 3 4 9 ... 373s num [1:4, 1:2] 1 Inf 3 4 9 ... 373s real + Inf cell (double) w/ na.rm = TRUE: 373s [,1] [,2] [,3] 373s [1,] 1 5 9 373s [2,] 2 Inf 10 373s [3,] 3 7 11 373s [4,] 4 8 12 373s min: 373s num [1:4] 1 2 3 4 373s num [1:4] 1 2 3 4 373s num [1:4] 1 2 3 4 373s max: 373s num [1:4] 9 Inf 11 12 373s num [1:4] 9 Inf 11 12 373s num [1:4] 9 Inf 11 12 373s range: 373s num [1:4, 1:2] 1 2 3 4 9 ... 373s num [1:4, 1:2] 1 2 3 4 9 ... 373s num [1:4, 1:2] 1 2 3 4 9 ... 373s real + Inf cell (double) w/ na.rm = TRUE: 373s [,1] [,2] [,3] 373s [1,] 1 5 9 373s [2,] 2 Inf 10 373s [3,] 3 7 11 373s [4,] 4 8 12 373s min: 373s num [1:4] 1 2 3 4 373s num [1:4] 1 2 3 4 373s num [1:4] 1 2 3 4 373s max: 373s num [1:4] 9 Inf 11 12 373s num [1:4] 9 Inf 11 12 373s num [1:4] 9 Inf 11 12 373s range: 373s num [1:4, 1:2] 1 2 3 4 9 ... 373s num [1:4, 1:2] 1 2 3 4 9 ... 373s num [1:4, 1:2] 1 2 3 4 9 ... 373s real + Inf row (double) w/ na.rm = TRUE: 373s [,1] [,2] [,3] 373s [1,] 1 5 9 373s [2,] Inf Inf Inf 373s [3,] 3 7 11 373s [4,] 4 8 12 373s min: 373s num [1:4] 1 Inf 3 4 373s num [1:4] 1 Inf 3 4 373s num [1:4] 1 Inf 3 4 373s max: 373s num [1:4] 9 Inf 11 12 373s num [1:4] 9 Inf 11 12 373s num [1:4] 9 Inf 11 12 373s range: 373s num [1:4, 1:2] 1 Inf 3 4 9 ... 373s num [1:4, 1:2] 1 Inf 3 4 9 ... 373s num [1:4, 1:2] 1 Inf 3 4 9 ... 373s real + Inf row (double) w/ na.rm = TRUE: 373s [,1] [,2] [,3] 373s [1,] 1 5 9 373s [2,] Inf Inf Inf 373s [3,] 3 7 11 373s [4,] 4 8 12 373s min: 373s num [1:4] 1 Inf 3 4 373s num [1:4] 1 Inf 3 4 373s num [1:4] 1 Inf 3 4 373s max: 373s num [1:4] 9 Inf 11 12 373s num [1:4] 9 Inf 11 12 373s num [1:4] 9 Inf 11 12 373s range: 373s num [1:4, 1:2] 1 Inf 3 4 9 ... 373s num [1:4, 1:2] 1 Inf 3 4 9 ... 373s num [1:4, 1:2] 1 Inf 3 4 9 ... 373s real + NaN cell (double) w/ na.rm = TRUE: 373s [,1] [,2] [,3] 373s [1,] 1 5 9 373s [2,] 2 NaN 10 373s [3,] 3 7 11 373s [4,] 4 8 12 373s min: 373s num [1:4] 1 2 3 4 373s num [1:4] 1 2 3 4 373s num [1:4] 1 2 3 4 373s max: 373s num [1:4] 9 10 11 12 373s num [1:4] 9 10 11 12 373s num [1:4] 9 10 11 12 373s range: 373s num [1:4, 1:2] 1 2 3 4 9 10 11 12 373s num [1:4, 1:2] 1 2 3 4 9 10 11 12 373s num [1:4, 1:2] 1 2 3 4 9 10 11 12 373s real + NaN cell (double) w/ na.rm = TRUE: 373s [,1] [,2] [,3] 373s [1,] 1 5 9 373s [2,] 2 NaN 10 373s [3,] 3 7 11 373s [4,] 4 8 12 373s min: 373s num [1:4] 1 2 3 4 373s num [1:4] 1 2 3 4 373s num [1:4] 1 2 3 4 373s max: 373s num [1:4] 9 10 11 12 373s num [1:4] 9 10 11 12 373s num [1:4] 9 10 11 12 373s range: 373s num [1:4, 1:2] 1 2 3 4 9 10 11 12 373s num [1:4, 1:2] 1 2 3 4 9 10 11 12 373s num [1:4, 1:2] 1 2 3 4 9 10 11 12 373s real w/ NA + NaN cell (double) w/ na.rm = TRUE: 373s [,1] [,2] [,3] 373s [1,] NA NA NA 373s [2,] NA NaN NA 373s [3,] NA NA NA 373s [4,] NA NA NA 373s min: 373s num [1:4] Inf Inf Inf Inf 373s num [1:4] Inf Inf Inf Inf 373s num [1:4] Inf Inf Inf Inf 373s max: 373s num [1:4] -Inf -Inf -Inf -Inf 373s num [1:4] -Inf -Inf -Inf -Inf 373s num [1:4] -Inf -Inf -Inf -Inf 373s range: 373s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 373s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 373s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 373s real w/ NA + NaN cell (double) w/ na.rm = TRUE: 373s [,1] [,2] [,3] 373s [1,] NA NA NA 373s [2,] NA NaN NA 373s [3,] NA NA NA 373s [4,] NA NA NA 373s min: 373s num [1:4] Inf Inf Inf Inf 373s num [1:4] Inf Inf Inf Inf 373s num [1:4] Inf Inf Inf Inf 373s max: 373s num [1:4] -Inf -Inf -Inf -Inf 373s num [1:4] -Inf -Inf -Inf -Inf 373s num [1:4] -Inf -Inf -Inf -Inf 373s range: 373s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 373s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 373s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 373s real w/ NA + NaN row (double) w/ na.rm = TRUE: 373s [,1] [,2] [,3] 373s [1,] NA NA NA 373s [2,] NaN NaN NaN 373s [3,] NA NA NA 373s [4,] NA NA NA 373s min: 373s num [1:4] Inf Inf Inf Inf 373s num [1:4] Inf Inf Inf Inf 373s num [1:4] Inf Inf Inf Inf 373s max: 373s num [1:4] -Inf -Inf -Inf -Inf 373s num [1:4] -Inf -Inf -Inf -Inf 373s num [1:4] -Inf -Inf -Inf -Inf 373s range: 373s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 373s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 373s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 373s real w/ NA + NaN row (double) w/ na.rm = TRUE: 373s [,1] [,2] [,3] 373s [1,] NA NA NA 373s [2,] NaN NaN NaN 373s [3,] NA NA NA 373s [4,] NA NA NA 373s min: 373s num [1:4] Inf Inf Inf Inf 373s num [1:4] Inf Inf Inf Inf 373s num [1:4] Inf Inf Inf Inf 373s max: 373s num [1:4] -Inf -Inf -Inf -Inf 373s num [1:4] -Inf -Inf -Inf -Inf 373s num [1:4] -Inf -Inf -Inf -Inf 373s range: 373s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 373s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 373s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 373s integer (integer) w/ na.rm = FALSE: 373s [,1] [,2] [,3] 373s [1,] 1 5 9 373s [2,] 2 6 10 373s [3,] 3 7 11 373s [4,] 4 8 12 373s min: 373s int [1:4] 1 2 3 4 373s int [1:4] 1 2 3 4 373s int [1:4] 1 2 3 4 373s max: 373s int [1:4] 9 10 11 12 373s int [1:4] 9 10 11 12 373s int [1:4] 9 10 11 12 373s range: 373s int [1:4, 1:2] 1 2 3 4 9 10 11 12 373s int [1:4, 1:2] 1 2 3 4 9 10 11 12 373s int [1:4, 1:2] 1 2 3 4 9 10 11 12 373s integer (integer) w/ na.rm = FALSE: 373s [,1] [,2] [,3] 373s [1,] 1 5 9 373s [2,] 2 6 10 373s [3,] 3 7 11 373s [4,] 4 8 12 373s min: 373s int [1:4] 1 2 3 4 373s int [1:4] 1 2 3 4 373s int [1:4] 1 2 3 4 373s max: 373s int [1:4] 9 10 11 12 373s int [1:4] 9 10 11 12 373s int [1:4] 9 10 11 12 373s range: 373s int [1:4, 1:2] 1 2 3 4 9 10 11 12 373s int [1:4, 1:2] 1 2 3 4 9 10 11 12 373s int [1:4, 1:2] 1 2 3 4 9 10 11 12 373s integer w/ NA (integer) w/ na.rm = FALSE: 373s [,1] [,2] [,3] 373s [1,] NA NA NA 373s [2,] NA NA NA 373s [3,] NA NA NA 373s [4,] NA NA NA 373s min: 373s int [1:4] NA NA NA NA 373s int [1:4] NA NA NA NA 373s int [1:4] NA NA NA NA 373s max: 373s int [1:4] NA NA NA NA 373s int [1:4] NA NA NA NA 373s int [1:4] NA NA NA NA 373s range: 373s int [1:4, 1:2] NA NA NA NA NA NA NA NA 373s int [1:4, 1:2] NA NA NA NA NA NA NA NA 373s int [1:4, 1:2] NA NA NA NA NA NA NA NA 373s integer w/ NA (integer) w/ na.rm = FALSE: 373s [,1] [,2] [,3] 373s [1,] NA NA NA 373s [2,] NA NA NA 373s [3,] NA NA NA 373s [4,] NA NA NA 373s min: 373s int [1:4] NA NA NA NA 373s int [1:4] NA NA NA NA 373s int [1:4] NA NA NA NA 373s max: 373s int [1:4] NA NA NA NA 373s int [1:4] NA NA NA NA 373s int [1:4] NA NA NA NA 373s range: 373s int [1:4, 1:2] NA NA NA NA NA NA NA NA 373s int [1:4, 1:2] NA NA NA NA NA NA NA NA 373s int [1:4, 1:2] NA NA NA NA NA NA NA NA 373s real (double) w/ na.rm = FALSE: 373s [,1] [,2] [,3] 373s [1,] 1 5 9 373s [2,] 2 6 10 373s [3,] 3 7 11 373s [4,] 4 8 12 373s min: 373s num [1:4] 1 2 3 4 373s num [1:4] 1 2 3 4 373s num [1:4] 1 2 3 4 373s max: 373s num [1:4] 9 10 11 12 373s num [1:4] 9 10 11 12 373s num [1:4] 9 10 11 12 373s range: 373s num [1:4, 1:2] 1 2 3 4 9 10 11 12 373s num [1:4, 1:2] 1 2 3 4 9 10 11 12 373s num [1:4, 1:2] 1 2 3 4 9 10 11 12 373s real (double) w/ na.rm = FALSE: 373s [,1] [,2] [,3] 373s [1,] 1 5 9 373s [2,] 2 6 10 373s [3,] 3 7 11 373s [4,] 4 8 12 373s min: 373s num [1:4] 1 2 3 4 373s num [1:4] 1 2 3 4 373s num [1:4] 1 2 3 4 373s max: 373s num [1:4] 9 10 11 12 373s num [1:4] 9 10 11 12 373s num [1:4] 9 10 11 12 373s range: 373s num [1:4, 1:2] 1 2 3 4 9 10 11 12 373s num [1:4, 1:2] 1 2 3 4 9 10 11 12 373s num [1:4, 1:2] 1 2 3 4 9 10 11 12 373s real w/ NA (double) w/ na.rm = FALSE: 373s [,1] [,2] [,3] 373s [1,] NA NA NA 373s [2,] NA NA NA 373s [3,] NA NA NA 373s [4,] NA NA NA 373s min: 373s num [1:4] NA NA NA NA 373s num [1:4] NA NA NA NA 373s num [1:4] NA NA NA NA 373s max: 373s num [1:4] NA NA NA NA 373s num [1:4] NA NA NA NA 373s num [1:4] NA NA NA NA 373s range: 373s num [1:4, 1:2] NA NA NA NA NA NA NA NA 373s num [1:4, 1:2] NA NA NA NA NA NA NA NA 373s num [1:4, 1:2] NA NA NA NA NA NA NA NA 373s real w/ NA (double) w/ na.rm = FALSE: 373s [,1] [,2] [,3] 373s [1,] NA NA NA 373s [2,] NA NA NA 373s [3,] NA NA NA 373s [4,] NA NA NA 373s min: 373s num [1:4] NA NA NA NA 373s num [1:4] NA NA NA NA 373s num [1:4] NA NA NA NA 373s max: 373s num [1:4] NA NA NA NA 373s num [1:4] NA NA NA NA 373s num [1:4] NA NA NA NA 373s range: 373s num [1:4, 1:2] NA NA NA NA NA NA NA NA 373s num [1:4, 1:2] NA NA NA NA NA NA NA NA 373s num [1:4, 1:2] NA NA NA NA NA NA NA NA 373s real + NA cell (double) w/ na.rm = FALSE: 373s [,1] [,2] [,3] 373s [1,] 1 5 9 373s [2,] 2 NA 10 373s [3,] 3 7 11 373s [4,] 4 8 12 373s min: 373s num [1:4] 1 NA 3 4 373s num [1:4] 1 NA 3 4 373s num [1:4] 1 NA 3 4 373s max: 373s num [1:4] 9 NA 11 12 373s num [1:4] 9 NA 11 12 373s num [1:4] 9 NA 11 12 373s range: 373s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 373s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 373s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 373s real + NA cell (double) w/ na.rm = FALSE: 373s [,1] [,2] [,3] 373s [1,] 1 5 9 373s [2,] 2 NA 10 373s [3,] 3 7 11 373s [4,] 4 8 12 373s min: 373s num [1:4] 1 NA 3 4 373s num [1:4] 1 NA 3 4 373s num [1:4] 1 NA 3 4 373s max: 373s num [1:4] 9 NA 11 12 373s num [1:4] 9 NA 11 12 373s num [1:4] 9 NA 11 12 373s range: 373s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 373s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 373s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 373s real + NA row (double) w/ na.rm = FALSE: 373s [,1] [,2] [,3] 373s [1,] 1 5 9 373s [2,] NA NA NA 373s [3,] 3 7 11 373s [4,] 4 8 12 373s min: 373s num [1:4] 1 NA 3 4 373s num [1:4] 1 NA 3 4 373s num [1:4] 1 NA 3 4 373s max: 373s num [1:4] 9 NA 11 12 373s num [1:4] 9 NA 11 12 373s num [1:4] 9 NA 11 12 373s range: 373s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 373s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 373s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 373s real + NA row (double) w/ na.rm = FALSE: 373s [,1] [,2] [,3] 373s [1,] 1 5 9 373s [2,] NA NA NA 373s [3,] 3 7 11 373s [4,] 4 8 12 373s min: 373s num [1:4] 1 NA 3 4 373s num [1:4] 1 NA 3 4 373s num [1:4] 1 NA 3 4 373s max: 373s num [1:4] 9 NA 11 12 373s num [1:4] 9 NA 11 12 373s num [1:4] 9 NA 11 12 373s range: 373s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 373s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 373s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 373s real + NaN row (double) w/ na.rm = FALSE: 373s [,1] [,2] [,3] 373s [1,] 1 5 9 373s [2,] NaN NaN NaN 373s [3,] 3 7 11 373s [4,] 4 8 12 373s min: 373s num [1:4] 1 NaN 3 4 373s num [1:4] 1 NaN 3 4 373s num [1:4] 1 NaN 3 4 373s max: 373s num [1:4] 9 NaN 11 12 373s num [1:4] 9 NaN 11 12 373s num [1:4] 9 NaN 11 12 373s range: 373s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 373s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 373s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 373s real + NaN row (double) w/ na.rm = FALSE: 373s [,1] [,2] [,3] 373s [1,] 1 5 9 373s [2,] NaN NaN NaN 373s [3,] 3 7 11 373s [4,] 4 8 12 373s min: 373s num [1:4] 1 NaN 3 4 373s num [1:4] 1 NaN 3 4 373s num [1:4] 1 NaN 3 4 373s max: 373s num [1:4] 9 NaN 11 12 373s num [1:4] 9 NaN 11 12 373s num [1:4] 9 NaN 11 12 373s range: 373s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 373s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 373s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 373s real + Inf cell (double) w/ na.rm = FALSE: 373s [,1] [,2] [,3] 373s [1,] 1 5 9 373s [2,] 2 Inf 10 373s [3,] 3 7 11 373s [4,] 4 8 12 373s min: 373s num [1:4] 1 2 3 4 373s num [1:4] 1 2 3 4 373s num [1:4] 1 2 3 4 373s max: 373s num [1:4] 9 Inf 11 12 373s num [1:4] 9 Inf 11 12 373s num [1:4] 9 Inf 11 12 373s range: 373s num [1:4, 1:2] 1 2 3 4 9 ... 373s num [1:4, 1:2] 1 2 3 4 9 ... 373s num [1:4, 1:2] 1 2 3 4 9 ... 373s real + Inf cell (double) w/ na.rm = FALSE: 373s [,1] [,2] [,3] 373s [1,] 1 5 9 373s [2,] 2 Inf 10 373s [3,] 3 7 11 373s [4,] 4 8 12 373s min: 373s num [1:4] 1 2 3 4 373s num [1:4] 1 2 3 4 373s num [1:4] 1 2 3 4 373s max: 373s num [1:4] 9 Inf 11 12 373s num [1:4] 9 Inf 11 12 373s num [1:4] 9 Inf 11 12 373s range: 373s num [1:4, 1:2] 1 2 3 4 9 ... 373s num [1:4, 1:2] 1 2 3 4 9 ... 373s num [1:4, 1:2] 1 2 3 4 9 ... 373s real + Inf row (double) w/ na.rm = FALSE: 373s [,1] [,2] [,3] 373s [1,] 1 5 9 373s [2,] Inf Inf Inf 373s [3,] 3 7 11 373s [4,] 4 8 12 373s min: 373s num [1:4] 1 Inf 3 4 373s num [1:4] 1 Inf 3 4 373s num [1:4] 1 Inf 3 4 373s max: 373s num [1:4] 9 Inf 11 12 373s num [1:4] 9 Inf 11 12 373s num [1:4] 9 Inf 11 12 373s range: 373s num [1:4, 1:2] 1 Inf 3 4 9 ... 373s num [1:4, 1:2] 1 Inf 3 4 9 ... 373s num [1:4, 1:2] 1 Inf 3 4 9 ... 373s real + Inf row (double) w/ na.rm = FALSE: 373s [,1] [,2] [,3] 373s [1,] 1 5 9 373s [2,] Inf Inf Inf 373s [3,] 3 7 11 373s [4,] 4 8 12 373s min: 373s num [1:4] 1 Inf 3 4 373s num [1:4] 1 Inf 3 4 373s num [1:4] 1 Inf 3 4 373s max: 373s num [1:4] 9 Inf 11 12 373s num [1:4] 9 Inf 11 12 373s num [1:4] 9 Inf 11 12 373s range: 373s num [1:4, 1:2] 1 Inf 3 4 9 ... 373s num [1:4, 1:2] 1 Inf 3 4 9 ... 373s num [1:4, 1:2] 1 Inf 3 4 9 ... 373s real + NaN cell (double) w/ na.rm = FALSE: 373s [,1] [,2] [,3] 373s [1,] 1 5 9 373s [2,] 2 NaN 10 373s [3,] 3 7 11 373s [4,] 4 8 12 373s min: 373s num [1:4] 1 NaN 3 4 373s num [1:4] 1 NaN 3 4 373s num [1:4] 1 NaN 3 4 373s max: 373s num [1:4] 9 NaN 11 12 373s num [1:4] 9 NaN 11 12 373s num [1:4] 9 NaN 11 12 373s range: 373s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 373s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 373s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 373s real + NaN cell (double) w/ na.rm = FALSE: 373s [,1] [,2] [,3] 373s [1,] 1 5 9 373s [2,] 2 NaN 10 373s [3,] 3 7 11 373s [4,] 4 8 12 373s min: 373s num [1:4] 1 NaN 3 4 373s num [1:4] 1 NaN 3 4 374s num [1:4] 1 NaN 3 4 374s max: 374s num [1:4] 9 NaN 11 12 374s num [1:4] 9 NaN 11 12 374s num [1:4] 9 NaN 11 12 374s range: 374s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 374s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 374s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 374s real w/ NA + NaN cell (double) w/ na.rm = FALSE: 374s [,1] [,2] [,3] 374s [1,] NA NA NA 374s [2,] NA NaN NA 374s [3,] NA NA NA 374s [4,] NA NA NA 374s min: 374s num [1:4] NA NA NA NA 374s num [1:4] NA NA NA NA 374s num [1:4] NA NA NA NA 374s max: 374s num [1:4] NA NA NA NA 374s num [1:4] NA NA NA NA 374s num [1:4] NA NA NA NA 374s range: 374s num [1:4, 1:2] NA NA NA NA NA NA NA NA 374s num [1:4, 1:2] NA NA NA NA NA NA NA NA 374s num [1:4, 1:2] NA NA NA NA NA NA NA NA 374s real w/ NA + NaN cell (double) w/ na.rm = FALSE: 374s [,1] [,2] [,3] 374s [1,] NA NA NA 374s [2,] NA NaN NA 374s [3,] NA NA NA 374s [4,] NA NA NA 374s min: 374s num [1:4] NA NA NA NA 374s num [1:4] NA NA NA NA 374s num [1:4] NA NA NA NA 374s max: 374s num [1:4] NA NA NA NA 374s num [1:4] NA NA NA NA 374s num [1:4] NA NA NA NA 374s range: 374s num [1:4, 1:2] NA NA NA NA NA NA NA NA 374s num [1:4, 1:2] NA NA NA NA NA NA NA NA 374s num [1:4, 1:2] NA NA NA NA NA NA NA NA 374s real w/ NA + NaN row (double) w/ na.rm = FALSE: 374s [,1] [,2] [,3] 374s [1,] NA NA NA 374s [2,] NaN NaN NaN 374s [3,] NA NA NA 374s [4,] NA NA NA 374s min: 374s num [1:4] NA NaN NA NA 374s num [1:4] NA NaN NA NA 374s num [1:4] NA NaN NA NA 374s max: 374s num [1:4] NA NaN NA NA 374s num [1:4] NA NaN NA NA 374s num [1:4] NA NaN NA NA 374s range: 374s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 374s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 374s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 374s real w/ NA + NaN row (double) w/ na.rm = FALSE: 374s [,1] [,2] [,3] 374s [1,] NA NA NA 374s [2,] NaN NaN NaN 374s [3,] NA NA NA 374s [4,] NA NA NA 374s min: 374s num [1:4] NA NaN NA NA 374s num [1:4] NA NaN NA NA 374s num [1:4] NA NaN NA NA 374s max: 374s num [1:4] NA NaN NA NA 374s num [1:4] NA NaN NA NA 374s num [1:4] NA NaN NA NA 374s range: 374s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 374s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 374s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 374s integer (integer) w/ na.rm = TRUE: 374s [,1] [,2] [,3] 374s [1,] 1 5 9 374s [2,] 2 6 10 374s [3,] 3 7 11 374s [4,] 4 8 12 374s min: 374s int [1:4] 1 2 3 4 374s int [1:4] 1 2 3 4 374s int [1:4] 1 2 3 4 374s max: 374s int [1:4] 9 10 11 12 374s int [1:4] 9 10 11 12 374s int [1:4] 9 10 11 12 374s range: 374s int [1:4, 1:2] 1 2 3 4 9 10 11 12 374s int [1:4, 1:2] 1 2 3 4 9 10 11 12 374s int [1:4, 1:2] 1 2 3 4 9 10 11 12 374s integer (integer) w/ na.rm = TRUE: 374s [,1] [,2] [,3] 374s [1,] 1 5 9 374s [2,] 2 6 10 374s [3,] 3 7 11 374s [4,] 4 8 12 374s min: 374s int [1:4] 1 2 3 4 374s int [1:4] 1 2 3 4 374s int [1:4] 1 2 3 4 374s max: 374s int [1:4] 9 10 11 12 374s int [1:4] 9 10 11 12 374s int [1:4] 9 10 11 12 374s range: 374s int [1:4, 1:2] 1 2 3 4 9 10 11 12 374s int [1:4, 1:2] 1 2 3 4 9 10 11 12 374s int [1:4, 1:2] 1 2 3 4 9 10 11 12 374s integer w/ NA (integer) w/ na.rm = TRUE: 374s [,1] [,2] [,3] 374s [1,] NA NA NA 374s [2,] NA NA NA 374s [3,] NA NA NA 374s [4,] NA NA NA 374s min: 374s num [1:4] Inf Inf Inf Inf 374s num [1:4] Inf Inf Inf Inf 374s num [1:4] Inf Inf Inf Inf 374s max: 374s num [1:4] -Inf -Inf -Inf -Inf 374s num [1:4] -Inf -Inf -Inf -Inf 374s num [1:4] -Inf -Inf -Inf -Inf 374s range: 374s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 374s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 374s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 374s integer w/ NA (integer) w/ na.rm = TRUE: 374s [,1] [,2] [,3] 374s [1,] NA NA NA 374s [2,] NA NA NA 374s [3,] NA NA NA 374s [4,] NA NA NA 374s min: 374s num [1:4] Inf Inf Inf Inf 374s num [1:4] Inf Inf Inf Inf 374s num [1:4] Inf Inf Inf Inf 374s max: 374s num [1:4] -Inf -Inf -Inf -Inf 374s num [1:4] -Inf -Inf -Inf -Inf 374s num [1:4] -Inf -Inf -Inf -Inf 374s range: 374s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 374s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 374s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 374s real (double) w/ na.rm = TRUE: 374s [,1] [,2] [,3] 374s [1,] 1 5 9 374s [2,] 2 6 10 374s [3,] 3 7 11 374s [4,] 4 8 12 374s min: 374s num [1:4] 1 2 3 4 374s num [1:4] 1 2 3 4 374s num [1:4] 1 2 3 4 374s max: 374s num [1:4] 9 10 11 12 374s num [1:4] 9 10 11 12 374s num [1:4] 9 10 11 12 374s range: 374s num [1:4, 1:2] 1 2 3 4 9 10 11 12 374s num [1:4, 1:2] 1 2 3 4 9 10 11 12 374s num [1:4, 1:2] 1 2 3 4 9 10 11 12 374s real (double) w/ na.rm = TRUE: 374s [,1] [,2] [,3] 374s [1,] 1 5 9 374s [2,] 2 6 10 374s [3,] 3 7 11 374s [4,] 4 8 12 374s min: 374s num [1:4] 1 2 3 4 374s num [1:4] 1 2 3 4 374s num [1:4] 1 2 3 4 374s max: 374s num [1:4] 9 10 11 12 374s num [1:4] 9 10 11 12 374s num [1:4] 9 10 11 12 374s range: 374s num [1:4, 1:2] 1 2 3 4 9 10 11 12 374s num [1:4, 1:2] 1 2 3 4 9 10 11 12 374s num [1:4, 1:2] 1 2 3 4 9 10 11 12 374s real w/ NA (double) w/ na.rm = TRUE: 374s [,1] [,2] [,3] 374s [1,] NA NA NA 374s [2,] NA NA NA 374s [3,] NA NA NA 374s [4,] NA NA NA 374s min: 374s num [1:4] Inf Inf Inf Inf 374s num [1:4] Inf Inf Inf Inf 374s num [1:4] Inf Inf Inf Inf 374s max: 374s num [1:4] -Inf -Inf -Inf -Inf 374s num [1:4] -Inf -Inf -Inf -Inf 374s num [1:4] -Inf -Inf -Inf -Inf 374s range: 374s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 374s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 374s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 374s real w/ NA (double) w/ na.rm = TRUE: 374s [,1] [,2] [,3] 374s [1,] NA NA NA 374s [2,] NA NA NA 374s [3,] NA NA NA 374s [4,] NA NA NA 374s min: 374s num [1:4] Inf Inf Inf Inf 374s num [1:4] Inf Inf Inf Inf 374s num [1:4] Inf Inf Inf Inf 374s max: 374s num [1:4] -Inf -Inf -Inf -Inf 374s num [1:4] -Inf -Inf -Inf -Inf 374s num [1:4] -Inf -Inf -Inf -Inf 374s range: 374s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 374s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 374s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 374s real + NA cell (double) w/ na.rm = TRUE: 374s [,1] [,2] [,3] 374s [1,] 1 5 9 374s [2,] 2 NA 10 374s [3,] 3 7 11 374s [4,] 4 8 12 374s min: 374s num [1:4] 1 2 3 4 374s num [1:4] 1 2 3 4 374s num [1:4] 1 2 3 4 374s max: 374s num [1:4] 9 10 11 12 374s num [1:4] 9 10 11 12 374s num [1:4] 9 10 11 12 374s range: 374s num [1:4, 1:2] 1 2 3 4 9 10 11 12 374s num [1:4, 1:2] 1 2 3 4 9 10 11 12 374s num [1:4, 1:2] 1 2 3 4 9 10 11 12 374s real + NA cell (double) w/ na.rm = TRUE: 374s [,1] [,2] [,3] 374s [1,] 1 5 9 374s [2,] 2 NA 10 374s [3,] 3 7 11 374s [4,] 4 8 12 374s min: 374s num [1:4] 1 2 3 4 374s num [1:4] 1 2 3 4 374s num [1:4] 1 2 3 4 374s max: 374s num [1:4] 9 10 11 12 374s num [1:4] 9 10 11 12 374s num [1:4] 9 10 11 12 374s range: 374s num [1:4, 1:2] 1 2 3 4 9 10 11 12 374s num [1:4, 1:2] 1 2 3 4 9 10 11 12 374s num [1:4, 1:2] 1 2 3 4 9 10 11 12 374s real + NA row (double) w/ na.rm = TRUE: 374s [,1] [,2] [,3] 374s [1,] 1 5 9 374s [2,] NA NA NA 374s [3,] 3 7 11 374s [4,] 4 8 12 374s min: 374s num [1:4] 1 Inf 3 4 374s num [1:4] 1 Inf 3 4 374s num [1:4] 1 Inf 3 4 374s max: 374s num [1:4] 9 -Inf 11 12 374s num [1:4] 9 -Inf 11 12 374s num [1:4] 9 -Inf 11 12 374s range: 374s num [1:4, 1:2] 1 Inf 3 4 9 ... 374s num [1:4, 1:2] 1 Inf 3 4 9 ... 374s num [1:4, 1:2] 1 Inf 3 4 9 ... 374s real + NA row (double) w/ na.rm = TRUE: 374s [,1] [,2] [,3] 374s [1,] 1 5 9 374s [2,] NA NA NA 374s [3,] 3 7 11 374s [4,] 4 8 12 374s min: 374s num [1:4] 1 Inf 3 4 374s num [1:4] 1 Inf 3 4 374s num [1:4] 1 Inf 3 4 374s max: 374s num [1:4] 9 -Inf 11 12 374s num [1:4] 9 -Inf 11 12 374s num [1:4] 9 -Inf 11 12 374s range: 374s num [1:4, 1:2] 1 Inf 3 4 9 ... 374s num [1:4, 1:2] 1 Inf 3 4 9 ... 374s num [1:4, 1:2] 1 Inf 3 4 9 ... 374s real + NaN row (double) w/ na.rm = TRUE: 374s [,1] [,2] [,3] 374s [1,] 1 5 9 374s [2,] NaN NaN NaN 374s [3,] 3 7 11 374s [4,] 4 8 12 374s min: 374s num [1:4] 1 Inf 3 4 374s num [1:4] 1 Inf 3 4 374s num [1:4] 1 Inf 3 4 374s max: 374s num [1:4] 9 -Inf 11 12 374s num [1:4] 9 -Inf 11 12 374s num [1:4] 9 -Inf 11 12 374s range: 374s num [1:4, 1:2] 1 Inf 3 4 9 ... 374s num [1:4, 1:2] 1 Inf 3 4 9 ... 374s num [1:4, 1:2] 1 Inf 3 4 9 ... 374s real + NaN row (double) w/ na.rm = TRUE: 374s [,1] [,2] [,3] 374s [1,] 1 5 9 374s [2,] NaN NaN NaN 374s [3,] 3 7 11 374s [4,] 4 8 12 374s min: 374s num [1:4] 1 Inf 3 4 374s num [1:4] 1 Inf 3 4 374s num [1:4] 1 Inf 3 4 374s max: 374s num [1:4] 9 -Inf 11 12 374s num [1:4] 9 -Inf 11 12 374s num [1:4] 9 -Inf 11 12 374s range: 374s num [1:4, 1:2] 1 Inf 3 4 9 ... 374s num [1:4, 1:2] 1 Inf 3 4 9 ... 374s num [1:4, 1:2] 1 Inf 3 4 9 ... 374s real + Inf cell (double) w/ na.rm = TRUE: 374s [,1] [,2] [,3] 374s [1,] 1 5 9 374s [2,] 2 Inf 10 374s [3,] 3 7 11 374s [4,] 4 8 12 374s min: 374s num [1:4] 1 2 3 4 374s num [1:4] 1 2 3 4 374s num [1:4] 1 2 3 4 374s max: 374s num [1:4] 9 Inf 11 12 374s num [1:4] 9 Inf 11 12 374s num [1:4] 9 Inf 11 12 374s range: 374s num [1:4, 1:2] 1 2 3 4 9 ... 374s num [1:4, 1:2] 1 2 3 4 9 ... 374s num [1:4, 1:2] 1 2 3 4 9 ... 374s real + Inf cell (double) w/ na.rm = TRUE: 374s [,1] [,2] [,3] 374s [1,] 1 5 9 374s [2,] 2 Inf 10 374s [3,] 3 7 11 374s [4,] 4 8 12 374s min: 374s num [1:4] 1 2 3 4 374s num [1:4] 1 2 3 4 374s num [1:4] 1 2 3 4 374s max: 374s num [1:4] 9 Inf 11 12 374s num [1:4] 9 Inf 11 12 374s num [1:4] 9 Inf 11 12 374s range: 374s num [1:4, 1:2] 1 2 3 4 9 ... 374s num [1:4, 1:2] 1 2 3 4 9 ... 374s num [1:4, 1:2] 1 2 3 4 9 ... 374s real + Inf row (double) w/ na.rm = TRUE: 374s [,1] [,2] [,3] 374s [1,] 1 5 9 374s [2,] Inf Inf Inf 374s [3,] 3 7 11 374s [4,] 4 8 12 374s min: 374s num [1:4] 1 Inf 3 4 374s num [1:4] 1 Inf 3 4 374s num [1:4] 1 Inf 3 4 374s max: 374s num [1:4] 9 Inf 11 12 374s num [1:4] 9 Inf 11 12 374s num [1:4] 9 Inf 11 12 374s range: 374s num [1:4, 1:2] 1 Inf 3 4 9 ... 374s num [1:4, 1:2] 1 Inf 3 4 9 ... 374s num [1:4, 1:2] 1 Inf 3 4 9 ... 374s real + Inf row (double) w/ na.rm = TRUE: 374s [,1] [,2] [,3] 374s [1,] 1 5 9 374s [2,] Inf Inf Inf 374s [3,] 3 7 11 374s [4,] 4 8 12 374s min: 374s num [1:4] 1 Inf 3 4 374s num [1:4] 1 Inf 3 4 374s num [1:4] 1 Inf 3 4 374s max: 374s num [1:4] 9 Inf 11 12 374s num [1:4] 9 Inf 11 12 374s num [1:4] 9 Inf 11 12 374s range: 374s num [1:4, 1:2] 1 Inf 3 4 9 ... 374s num [1:4, 1:2] 1 Inf 3 4 9 ... 374s num [1:4, 1:2] 1 Inf 3 4 9 ... 374s real + NaN cell (double) w/ na.rm = TRUE: 374s [,1] [,2] [,3] 374s [1,] 1 5 9 374s [2,] 2 NaN 10 374s [3,] 3 7 11 374s [4,] 4 8 12 374s min: 374s num [1:4] 1 2 3 4 374s num [1:4] 1 2 3 4 374s num [1:4] 1 2 3 4 374s max: 374s num [1:4] 9 10 11 12 374s num [1:4] 9 10 11 12 374s num [1:4] 9 10 11 12 374s range: 374s num [1:4, 1:2] 1 2 3 4 9 10 11 12 374s num [1:4, 1:2] 1 2 3 4 9 10 11 12 374s num [1:4, 1:2] 1 2 3 4 9 10 11 12 374s real + NaN cell (double) w/ na.rm = TRUE: 374s [,1] [,2] [,3] 374s [1,] 1 5 9 374s [2,] 2 NaN 10 374s [3,] 3 7 11 374s [4,] 4 8 12 374s min: 374s num [1:4] 1 2 3 4 374s num [1:4] 1 2 3 4 374s num [1:4] 1 2 3 4 374s max: 374s num [1:4] 9 10 11 12 374s num [1:4] 9 10 11 12 374s num [1:4] 9 10 11 12 374s range: 374s num [1:4, 1:2] 1 2 3 4 9 10 11 12 374s num [1:4, 1:2] 1 2 3 4 9 10 11 12 374s num [1:4, 1:2] 1 2 3 4 9 10 11 12 374s real w/ NA + NaN cell (double) w/ na.rm = TRUE: 374s [,1] [,2] [,3] 374s [1,] NA NA NA 374s [2,] NA NaN NA 374s [3,] NA NA NA 374s [4,] NA NA NA 374s min: 374s num [1:4] Inf Inf Inf Inf 374s num [1:4] Inf Inf Inf Inf 374s num [1:4] Inf Inf Inf Inf 374s max: 374s num [1:4] -Inf -Inf -Inf -Inf 374s num [1:4] -Inf -Inf -Inf -Inf 374s num [1:4] -Inf -Inf -Inf -Inf 374s range: 374s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 374s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 374s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 374s real w/ NA + NaN cell (double) w/ na.rm = TRUE: 374s [,1] [,2] [,3] 374s [1,] NA NA NA 374s [2,] NA NaN NA 374s [3,] NA NA NA 374s [4,] NA NA NA 374s min: 374s num [1:4] Inf Inf Inf Inf 374s num [1:4] Inf Inf Inf Inf 374s num [1:4] Inf Inf Inf Inf 374s max: 374s num [1:4] -Inf -Inf -Inf -Inf 374s num [1:4] -Inf -Inf -Inf -Inf 374s num [1:4] -Inf -Inf -Inf -Inf 374s range: 374s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 374s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 374s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 374s real w/ NA + NaN row (double) w/ na.rm = TRUE: 374s [,1] [,2] [,3] 374s [1,] NA NA NA 374s [2,] NaN NaN NaN 374s [3,] NA NA NA 374s [4,] NA NA NA 374s min: 374s num [1:4] Inf Inf Inf Inf 374s num [1:4] Inf Inf Inf Inf 374s num [1:4] Inf Inf Inf Inf 374s max: 374s num [1:4] -Inf -Inf -Inf -Inf 374s num [1:4] -Inf -Inf -Inf -Inf 374s num [1:4] -Inf -Inf -Inf -Inf 374s range: 374s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 374s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 374s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 374s real w/ NA + NaN row (double) w/ na.rm = TRUE: 374s [,1] [,2] [,3] 374s [1,] NA NA NA 374s [2,] NaN NaN NaN 374s [3,] NA NA NA 374s [4,] NA NA NA 374s min: 374s num [1:4] Inf Inf Inf Inf 374s num [1:4] Inf Inf Inf Inf 374s num [1:4] Inf Inf Inf Inf 374s max: 374s num [1:4] -Inf -Inf -Inf -Inf 374s num [1:4] -Inf -Inf -Inf -Inf 374s num [1:4] -Inf -Inf -Inf -Inf 374s range: 374s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 374s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 374s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 374s > 374s 374s R version 4.4.3 (2025-02-28) -- "Trophy Case" 374s Copyright (C) 2025 The R Foundation for Statistical Computing 374s Platform: aarch64-unknown-linux-gnu 374s 374s R is free software and comes with ABSOLUTELY NO WARRANTY. 374s You are welcome to redistribute it under certain conditions. 374s Type 'license()' or 'licence()' for distribution details. 374s 374s R is a collaborative project with many contributors. 374s Type 'contributors()' for more information and 374s 'citation()' on how to cite R or R packages in publications. 374s 374s Type 'demo()' for some demos, 'help()' for on-line help, or 374s 'help.start()' for an HTML browser interface to help. 374s Type 'q()' to quit R. 374s 374s > library("matrixStats") 374s > 374s > rowMins_R <- function(x, ..., useNames = TRUE) { 374s + suppressWarnings({ 374s + res <- apply(x, MARGIN = 1L, FUN = min, ...) 374s + }) 374s + if (!useNames) names(res) <- NULL 374s + res 374s + } # rowMins_R() 374s > 374s > rowMaxs_R <- function(x, ..., useNames = TRUE) { 374s + suppressWarnings({ 374s + res <- apply(x, MARGIN = 1L, FUN = max, ...) 374s + }) 374s + if (!useNames) names(res) <- NULL 374s + res 374s + } # rowMaxs_R() 374s > 374s > rowRanges_R <- function(x, ..., useNames = TRUE) { 374s + suppressWarnings({ 374s + ans <- t(apply(x, MARGIN = 1L, FUN = range, ...)) 374s + }) 374s + 374s + # Preserve rownames attribute 374s + dim <- c(dim(x)[1], 2L) 374s + if (!isTRUE(all.equal(dim(ans), dim))) { 374s + dim(ans) <- dim 374s + rownames <- rownames(x) 374s + if (!is.null(dimnames)) rownames(ans) <- rownames 374s + } 374s + if (!useNames) dimnames(ans) <- NULL 374s + ans 374s + } # rowRanges_R() 374s > 374s > 374s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 374s > # Subsetted tests 374s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 374s > source("utils/validateIndicesFramework.R") 374s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 374s > storage.mode(x) <- "integer" 374s > 374s > # To check rownames/names attributes 374s > dimnames <- list(letters[1:6], LETTERS[1:6]) 374s > 374s > # Test with and without dimnames on x 374s > for (setDimnames in c(TRUE, FALSE)) { 374s + if (setDimnames) dimnames(x) <- dimnames 374s + else dimnames(x) <- NULL 374s + 374s + count <- 0L 374s + for (rows in index_cases) { 374s + for (cols in index_cases) { 374s + count <- count + 1L 374s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 374s + useNames <- c(TRUE, FALSE) 374s + useNames <- useNames[count %% length(useNames) + 1] 374s + 374s + validateIndicesTestMatrix(x, rows, cols, 374s + ftest = rowRanges, fsure = rowRanges_R, 374s + na.rm = na.rm, useNames = useNames) 374s + validateIndicesTestMatrix(x, rows, cols, 374s + ftest = rowMins, fsure = rowMins_R, 374s + na.rm = na.rm, useNames = useNames) 374s + validateIndicesTestMatrix(x, rows, cols, 374s + ftest = rowMaxs, fsure = rowMaxs_R, 374s + na.rm = na.rm, useNames = useNames) 374s + 374s + validateIndicesTestMatrix(x, rows, cols, 374s + fcoltest = colRanges, fsure = rowRanges_R, 374s + na.rm = na.rm, useNames = useNames) 374s + validateIndicesTestMatrix(x, rows, cols, 374s + fcoltest = colMins, fsure = rowMins_R, 374s + na.rm = na.rm, useNames = useNames) 374s + validateIndicesTestMatrix(x, rows, cols, 374s + fcoltest = colMaxs, fsure = rowMaxs_R, 374s + na.rm = na.rm, useNames = useNames) 374s + } 374s + } 374s + } 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: aarch64-unknown-linux-gnu 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 > dense_rank <- function(x) match(x, table = sort(unique(x))) 375s > 375s > rowRanks_R <- function(x, ties.method, ..., useNames = TRUE) { 375s + if (ties.method == "dense") { 375s + res <- t(apply(x, MARGIN = 1L, FUN = dense_rank)) 375s + } else { 375s + res <- t(apply(x, MARGIN = 1L, FUN = rank, na.last = "keep", ties.method = ties.method)) 375s + } 375s + 375s + # Preserve dimnames attribute? 375s + dim(res) <- dim(x) 375s + dimnames(res) <- if (useNames) dimnames(x) else NULL 375s + 375s + res 375s + } 375s > 375s > colRanks_R <- function(x, ties.method, preserveShape = FALSE, ..., useNames = TRUE) { 375s + if (ties.method == "dense") { 375s + res <- t(apply(x, MARGIN = 2L, FUN = dense_rank)) 375s + } else { 375s + res <- t(apply(x, MARGIN = 2L, FUN = rank, na.last = "keep", ties.method = ties.method)) 375s + } 375s + 375s + # Preserve dimnames attribute? 375s + tx <- t(x) 375s + dim(res) <- dim(tx) 375s + dimnames(res) <- if (useNames) dimnames(tx) else NULL 375s + 375s + if (preserveShape) res <- t(res) 375s + res 375s + } 375s > 375s > set.seed(1) 375s > 375s > cat("Consistency checks:\n") 375s Consistency checks: 375s > xs <- vector("list", length = 4L) 375s > for (kk in 1:4) { 375s + 375s + # Simulate data in a matrix of any shape 375s + dim <- sample(40:80, size = 2L) 375s + n <- prod(dim) 375s + x <- rnorm(n, sd = 10) 375s + dim(x) <- dim 375s + 375s + # Add NAs? 375s + if ((kk %% 4) %in% c(3, 0)) { 375s + cat("Adding NAs\n") 375s + nna <- sample(n, size = 1L) 375s + x[sample(length(x), size = nna)] <- NA_real_ 375s + } 375s + 375s + # Integer or double? 375s + if ((kk %% 4) %in% c(2, 0)) { 375s + cat("Coercing to integers\n") 375s + storage.mode(x) <- "integer" 375s + } 375s + 375s + xs[[kk]] <- x 375s + } # for (kk ...) 375s Coercing to integers 375s Adding NAs 375s Adding NAs 375s Coercing to integers 375s > str(xs) 375s List of 4 375s $ : num [1:43, 1:78] 13.3 12.72 4.15 -15.4 -9.29 ... 375s $ : int [1:46, 1:61] 2 11 -16 -5 19 5 26 -13 1 -9 ... 375s $ : num [1:42, 1:47] NA -22.3 NA NA NA ... 375s $ : int [1:42, 1:78] NA NA NA NA NA NA NA NA NA NA ... 375s > 375s > for (kk in 1:4) { 375s + cat("Random test #", kk, "\n", sep = "") 375s + x <- xs[[kk]] 375s + tx <- t(x) 375s + 375s + for (ties in c("max", "min", "average", "first", "last", "dense")) { 375s + cat(sprintf("ties.method = %s\n", ties)) 375s + # rowRanks(): 375s + y1 <- matrixStats::rowRanks(x, ties.method = ties) 375s + y2 <- rowRanks_R(x, ties.method = ties) 375s + stopifnot(identical(y1, y2)) 375s + 375s + y3 <- matrixStats::colRanks(tx, ties.method = ties) 375s + stopifnot(identical(y1, y3)) 375s + 375s + # colRanks(): 375s + y1 <- matrixStats::colRanks(x, ties.method = ties) 375s + y2 <- colRanks_R(x, ties.method = ties) 375s + stopifnot(identical(y1, y2)) 375s + 375s + y3 <- matrixStats::rowRanks(tx, ties.method = ties) 375s + stopifnot(identical(y1, y3)) 375s + } 375s + } # for (kk ...) 375s Random test #1 375s ties.method = max 375s ties.method = min 375s ties.method = average 375s ties.method = first 375s ties.method = last 375s ties.method = dense 375s Random test #2 375s ties.method = max 375s ties.method = min 375s ties.method = average 375s ties.method = first 376s ties.method = last 376s ties.method = dense 376s Random test #3 376s ties.method = max 376s ties.method = min 376s ties.method = average 376s ties.method = first 376s ties.method = last 376s ties.method = dense 376s Random test #4 376s ties.method = max 376s ties.method = min 376s ties.method = average 376s ties.method = first 376s ties.method = last 376s ties.method = dense 376s > 376s > # Note, below we know ties.method %in% c("min", "max", "average") is correct 376s > 376s > cat("Consistency checks for random:\n") 376s Consistency checks for random: 376s > tolerance <- 0.1 376s > nsamples <- 10000 376s > for (kk in 1:4) { 376s + cat("Random test #", kk, "\n", sep = "") 376s + x <- xs[[kk]] 376s + tx <- t(x) 376s + 376s + for (ties in c("random")) { 376s + cat(sprintf("ties.method = %s\n", ties)) 376s + 376s + ## rowRanks(): 376s + y0 <- rowRanks_R(x, ties.method = ties) 376s + y1 <- matrixStats::rowRanks(x, ties.method = ties) 376s + 376s + ## Assert symmetric rank differences 376s + d <- y1 - y0 376s + stopifnot(all(rowSums(d) == 0, na.rm = TRUE)) 376s + 376s + ## Assert within [min, max] 376s + y2min <- matrixStats::rowRanks(x, ties.method = "min") 376s + y2max <- matrixStats::rowRanks(x, ties.method = "max") 376s + stopifnot(all(y1 >= y2min, na.rm = TRUE) && all(y1 <= y2max, na.rm = TRUE)) 376s + ## Assert near average 376s + y1list <- replicate(nsamples, matrixStats::rowRanks(x, ties.method = ties), simplify = FALSE) 376s + y1mean <- Reduce(`+`, y1list) / nsamples 376s + y2avg <- matrixStats::rowRanks(x, ties.method = "average") 376s + stopifnot(all(abs(y1mean - y2avg) < tolerance, na.rm = TRUE)) 376s + 376s + ## colRanks(): 376s + y0 <- colRanks_R(x, ties.method = ties) 376s + y1 <- matrixStats::colRanks(x, ties.method = ties) 376s + 376s + ## Assert symmetric rank differences 376s + d <- y1 - y0 376s + stopifnot(all(rowSums(d) == 0, na.rm = TRUE)) 376s + 376s + ## Assert within [min, max] 376s + y2min <- matrixStats::colRanks(x, ties.method = "min") 376s + y2max <- matrixStats::colRanks(x, ties.method = "max") 376s + stopifnot(all(y1 >= y2min, na.rm = TRUE) && all(y1 <= y2max, na.rm = TRUE)) 376s + y1list <- replicate(nsamples, matrixStats::colRanks(x, ties.method = ties), simplify = FALSE) 376s + y1mean <- Reduce(`+`, y1list) / nsamples 376s + ## Assert near average 376s + y2avg <- matrixStats::colRanks(x, ties.method = "average") 376s + stopifnot(all(abs(y1mean - y2avg) < tolerance, na.rm = TRUE)) 376s + } 376s + } # for (kk ...) 376s Random test #1 376s ties.method = random 378s Random test #2 378s ties.method = random 381s Random test #3 381s ties.method = random 381s Random test #4 381s ties.method = random 382s > 382s > 382s > ## Exception handling 382s > x <- matrix(1:12, nrow = 3L, ncol = 4L) 382s > y <- try(rowRanks(x, ties.method = "unknown"), silent = TRUE) 382s > stopifnot(inherits(y, "try-error")) 382s > 382s > y <- try(colRanks(x, ties.method = "unknown"), silent = TRUE) 382s > stopifnot(inherits(y, "try-error")) 382s > 382s > dimnames <- list(letters[1:3], LETTERS[1:4]) 382s > for (mode in c("integer", "double")){ 382s + storage.mode(x) <- mode 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 + for (ties in c("max", "min", "average", "first", "last", "dense", "random")) { 382s + cat(sprintf("ties.method = %s\n", ties)) 382s + # rowRanks(): 382s + y1 <- matrixStats::rowRanks(x, ties.method = ties, useNames = useNames) 382s + y2 <- rowRanks_R(x, ties.method = ties, useNames = useNames) 382s + stopifnot(identical(y1, y2)) 382s + 382s + y3 <- matrixStats::colRanks(t(x), ties.method = ties, useNames = useNames) 382s + stopifnot(identical(y1, y3)) 382s + 382s + # colRanks(): 382s + y1 <- matrixStats::colRanks(x, ties.method = ties, useNames = useNames) 382s + y2 <- colRanks_R(x, ties.method = ties, useNames = useNames) 382s + stopifnot(identical(y1, y2)) 382s + 382s + y3 <- matrixStats::rowRanks(t(x), ties.method = ties, useNames = useNames) 382s + stopifnot(identical(y1, y3)) 382s + 382s + # Check preserveShape 382s + y1 <- matrixStats::colRanks(x, ties.method = ties, preserveShape = TRUE, useNames = useNames) 382s + y2 <- colRanks_R(x, ties.method = ties, preserveShape = TRUE, useNames = useNames) 382s + stopifnot(identical(y1, y2)) 382s + } 382s + } 382s + } 382s + } 382s ties.method = max 382s ties.method = min 382s ties.method = average 382s ties.method = first 382s ties.method = last 382s ties.method = dense 382s ties.method = random 382s ties.method = max 382s ties.method = min 382s ties.method = average 382s ties.method = first 382s ties.method = last 382s ties.method = dense 382s ties.method = random 382s ties.method = max 382s ties.method = min 382s ties.method = average 382s ties.method = first 382s ties.method = last 382s ties.method = dense 382s ties.method = random 382s ties.method = max 382s ties.method = min 382s ties.method = average 382s ties.method = first 382s ties.method = last 382s ties.method = dense 382s ties.method = random 382s ties.method = max 382s ties.method = min 382s ties.method = average 382s ties.method = first 382s ties.method = last 382s ties.method = dense 382s ties.method = random 382s ties.method = max 382s ties.method = min 382s ties.method = average 382s ties.method = first 382s ties.method = last 382s ties.method = dense 382s ties.method = random 382s ties.method = max 382s ties.method = min 382s ties.method = average 382s ties.method = first 382s ties.method = last 382s ties.method = dense 382s ties.method = random 382s ties.method = max 382s ties.method = min 382s ties.method = average 382s ties.method = first 382s ties.method = last 382s ties.method = dense 382s ties.method = random 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: aarch64-unknown-linux-gnu 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 > rowRanks_R <- function(x, ties.method = "average", ..., useNames = TRUE) { 382s + ans <- t(apply(x, MARGIN = 1L, FUN = rank, na.last = "keep", 382s + ties.method = ties.method)) 382s + 382s + # Preserve dimnames attribute? 382s + dim(ans) <- dim(x) 382s + dimnames(ans) <- if (useNames) dimnames(x) else NULL 382s + 382s + ans 382s + } 382s > 382s > colRanks_R <- function(x, ties.method, preserveShape = FALSE, ..., useNames = TRUE) { 382s + ans <- t(apply(x, MARGIN = 2L, FUN = rank, na.last = "keep", ties.method = ties.method)) 382s + 382s + # Preserve dimnames attribute? 382s + tx <- t(x) 382s + dim(ans) <- dim(tx) 382s + dimnames(ans) <- if (useNames) dimnames(tx) else NULL 382s + 382s + if (preserveShape) ans <- t(ans) 382s + ans 382s + } 382s > 382s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 382s > # Subsetted tests 382s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 382s > source("utils/validateIndicesFramework.R") 382s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 382s > storage.mode(x) <- "integer" 382s > 382s > # To check dimnames attribute 382s > dimnames <- list(letters[1:6], LETTERS[1:6]) 382s > 382s > colRanks_R_t <- function(x, rows, cols, ..., useNames = TRUE) { 382s + t(colRanks(t(x), rows = cols, cols = rows, preserveShape = TRUE, ..., useNames = useNames)) 382s + } 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 = rowRanks, fsure = rowRanks_R, 382s + ties.method = "average", useNames = useNames) 382s + 382s + validateIndicesTestMatrix(x, rows, cols, 382s + ftest = colRanks_R_t, fsure = rowRanks_R, 382s + ties.method = "average", useNames = useNames) 382s + 382s + for (perserveShape in c(TRUE, FALSE)) { 382s + validateIndicesTestMatrix(x, rows, cols, 382s + ftest = colRanks, fsure = colRanks_R, 382s + ties.method = "average", perserveShape = perserveShape, 382s + useNames = useNames) 382s + } 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: aarch64-unknown-linux-gnu 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 > ## Always allow testing of the 'center' argument (as long as it's not defunct) 384s > options(matrixStats.center.onUse = "ignore") 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 > rowSds_R <- function(x, na.rm = FALSE, center = NULL, ..., useNames = TRUE) { 384s + suppressWarnings({ 384s + sigma <- apply(x, MARGIN = 1L, FUN = sd, na.rm = na.rm) 384s + }) 384s + stopifnot(!any(is.infinite(sigma))) 384s + 384s + # Keep naming support consistency same as rowSds() 384s + if (is.null(center) || ncol(x) <= 1L) { 384s + if (isFALSE(useNames)) names(sigma) <- NULL 384s + } 384s + else if (isFALSE(useNames)) names(sigma) <- NULL 384s + sigma 384s + } 384s > 384s > colSds_R <- function(x, na.rm = FALSE, center = NULL, ..., useNames = TRUE) { 384s + suppressWarnings({ 384s + sigma <- apply(x, MARGIN = 2L, FUN = sd, na.rm = na.rm) 384s + }) 384s + stopifnot(!any(is.infinite(sigma))) 384s + 384s + # Keep naming support consistency same as colSds() 384s + if (is.null(center) || nrow(x) <= 1L) { 384s + if (isFALSE(useNames)) names(sigma) <- NULL 384s + } 384s + if (isFALSE(useNames)) names(sigma) <- NULL 384s + sigma 384s + } 384s > 384s > 384s > rowSds_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) { 384s + center <- rowWeightedMeans(x, cols = cols, na.rm = na.rm, useNames = FALSE) 384s + sigma <- rowSds(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 384s + stopifnot(!any(is.infinite(sigma))) 384s + sigma 384s + } 384s > 384s > colSds_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) { 384s + center <- colWeightedMeans(x, rows = rows, na.rm = na.rm, useNames = FALSE) 384s + sigma <- colSds(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 384s + stopifnot(!any(is.infinite(sigma))) 384s + sigma 384s + } 384s > 384s > 384s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 384s > # With and without some NAs 384s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 384s > for (mode in c("integer", "double")) { 384s + for (add_na in c(FALSE, TRUE)) { 384s + cat("add_na = ", add_na, "\n", sep = "") 384s + 384s + x <- matrix(1:50 + 0.1, nrow = 10L, ncol = 5L) 384s + if (add_na) { 384s + x[3:7, c(2, 4)] <- NA_real_ 384s + } 384s + cat("mode: ", mode, "\n", sep = "") 384s + storage.mode(x) <- mode 384s + str(x) 384s + 384s + # To check names attribute 384s + dimnames <- list(letters[1:10], LETTERS[1:5]) 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 + # Row/column ranges 384s + for (na.rm in c(FALSE, TRUE)) { 384s + # Check names attribute 384s + for (useNames in c(TRUE, FALSE)) { 384s + r0 <- rowSds_R(x, na.rm = na.rm, useNames = useNames) 384s + r1 <- rowSds(x, na.rm = na.rm, useNames = useNames) 384s + r1b <- rowSds_center(x, na.rm = na.rm, useNames = useNames) 384s + r2 <- colSds(t(x), na.rm = na.rm, useNames = useNames) 384s + r2b <- colSds_center(t(x), na.rm = na.rm, useNames = useNames) 384s + stopifnot(all.equal(r1, r2)) 384s + stopifnot(all.equal(r1, r0)) 384s + stopifnot(all.equal(r2, r0)) 384s + stopifnot(all.equal(r1b, r2b)) 384s + stopifnot( 384s + !any(is.infinite(r1)), 384s + !any(is.infinite(r2)), 384s + !any(is.infinite(r1b)), 384s + !any(is.infinite(r2b)) 384s + ) 384s + } 384s + } 384s + } 384s + } # for (add_na ...) 384s + } 384s add_na = FALSE 384s mode: integer 384s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 384s add_na = TRUE 384s mode: integer 384s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 384s add_na = FALSE 384s mode: double 384s 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 ... 384s add_na = TRUE 384s mode: double 384s 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 ... 384s > 384s > 384s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 384s > # All NAs 384s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 384s > for (mode in c("integer", "double")) { 384s + x <- matrix(NA_real_, nrow = 10L, ncol = 5L) 384s + cat("mode: ", mode, "\n", sep = "") 384s + storage.mode(x) <- mode 384s + str(x) 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 + # Row/column ranges 384s + for (na.rm in c(FALSE, TRUE)) { 384s + # Check names attribute 384s + for (useNames in c(TRUE, FALSE)) { 384s + r0 <- rowSds_R(x, na.rm = na.rm, useNames = useNames) 384s + r1 <- rowSds(x, na.rm = na.rm, useNames = useNames) 384s + r1b <- rowSds_center(x, na.rm = na.rm, useNames = useNames) 384s + r2 <- colSds(t(x), na.rm = na.rm, useNames = useNames) 384s + r2b <- colSds_center(t(x), na.rm = na.rm, useNames = useNames) 384s + stopifnot(all.equal(r1, r2)) 384s + stopifnot(all.equal(r1, r0)) 384s + stopifnot(all.equal(r2, r0)) 384s + stopifnot(all.equal(r1b, r2b)) 384s + stopifnot( 384s + !any(is.infinite(r1)), 384s + !any(is.infinite(r2)), 384s + !any(is.infinite(r1b)), 384s + !any(is.infinite(r2b)) 384s + ) 384s + } 384s + } 384s + } 384s + } 384s mode: integer 384s int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 384s mode: double 384s num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 384s > 384s > 384s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 384s > # A 1x1 matrix 384s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 384s > x <- matrix(0, nrow = 1L, ncol = 1L) 384s > dimnames <- list("a", "A") 384s > for (na.rm in c(FALSE, TRUE)) { 384s + cat("na.rm = ", na.rm, "\n", sep = "") 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 + # Row/column ranges 384s + for (na.rm in c(FALSE, TRUE)) { 384s + # Check names attribute 384s + for (useNames in c(TRUE, FALSE)) { 384s + r0 <- rowSds_R(x, na.rm = na.rm, useNames = useNames) 384s + r1 <- rowSds(x, na.rm = na.rm, useNames = useNames) 384s + r1b <- rowSds_center(x, na.rm = na.rm, useNames = useNames) 384s + r2 <- colSds(t(x), na.rm = na.rm, useNames = useNames) 384s + r2b <- colSds_center(t(x), na.rm = na.rm, useNames = useNames) 384s + stopifnot(all.equal(r1, r2)) 384s + stopifnot(all.equal(r1, r0)) 384s + stopifnot(all.equal(r2, r0)) 384s + stopifnot(all.equal(r1b, r2b)) 384s + stopifnot( 384s + !any(is.infinite(r1)), 384s + !any(is.infinite(r2)), 384s + !any(is.infinite(r1b)), 384s + !any(is.infinite(r2b)) 384s + ) 384s + } 384s + } 384s + } 384s + } 384s na.rm = FALSE 384s na.rm = TRUE 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: aarch64-unknown-linux-gnu 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 > ## Always allow testing of the 'center' argument (as long as it's not defunct) 384s > options(matrixStats.center.onUse = "ignore") 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 > rowSds_R <- function(x, na.rm = FALSE, center = NULL, ..., useNames = TRUE) { 384s + suppressWarnings({ 384s + sigma <- apply(x, MARGIN = 1L, FUN = sd, na.rm = na.rm) 384s + }) 384s + stopifnot(!any(is.infinite(sigma))) 384s + 384s + # Keep naming support consistency same as rowSds() 384s + if (is.null(center) || ncol(x) <= 1L) { 384s + if (isFALSE(useNames)) names(sigma) <- NULL 384s + } 384s + else if (isFALSE(useNames)) names(sigma) <- NULL 384s + sigma 384s + } 384s > 384s > colSds_R <- function(x, na.rm = FALSE, center = NULL, ..., useNames = TRUE) { 384s + suppressWarnings({ 384s + sigma <- apply(x, MARGIN = 2L, FUN = sd, na.rm = na.rm) 384s + }) 384s + stopifnot(!any(is.infinite(sigma))) 384s + 384s + # Keep naming support consistency same as colSds() 384s + if (is.null(center) || nrow(x) <= 1L) { 384s + if (isFALSE(useNames)) names(sigma) <- NULL 384s + } 384s + else if (isFALSE(useNames)) names(sigma) <- NULL 384s + sigma 384s + } 384s > 384s > 384s > rowSds_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) { 384s + center <- rowWeightedMeans(x, cols = cols, na.rm = na.rm, useNames = FALSE) 384s + sigma <- rowSds(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 384s + stopifnot(!any(is.infinite(sigma))) 384s + sigma 384s + } 384s > 384s > colSds_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) { 384s + center <- colWeightedMeans(x, rows = rows, na.rm = na.rm, useNames = FALSE) 384s + sigma <- colSds(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 384s + stopifnot(!any(is.infinite(sigma))) 384s + sigma 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 > storage.mode(x) <- "integer" 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 + 384s + count <- 0L 384s + for (rows in index_cases) { 384s + for (cols in index_cases) { 384s + count <- count + 1L 384s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 384s + useNames <- c(TRUE, FALSE) 384s + useNames <- useNames[count %% length(useNames) + 1] 384s + 384s + validateIndicesTestMatrix(x, rows, cols, 384s + ftest = rowSds, fsure = rowSds_R, 384s + na.rm = na.rm, useNames = useNames) 384s + validateIndicesTestMatrix(x, rows, cols, 384s + ftest = rowSds_center, fsure = rowSds_R, 384s + na.rm = na.rm, center = TRUE, useNames = useNames) 384s + 384s + validateIndicesTestMatrix(x, rows, cols, 384s + fcoltest = colSds, fsure = rowSds_R, 384s + na.rm = na.rm, useNames = useNames) 384s + validateIndicesTestMatrix(x, rows, cols, 384s + fcoltest = colSds_center, fsure = rowSds_R, 384s + na.rm = na.rm, center = TRUE, useNames = useNames) 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: aarch64-unknown-linux-gnu 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 385s > library("matrixStats") 385s > 385s > rowSums2_R <- function(x, na.rm = FALSE, ..., useNames = TRUE) { 385s + ## FIXME: sum() may overflow for integers, whereas 385s + ## base::rowSums() doesn't. What should rowSums2() do? 385s + ## apply(x, MARGIN = 1L, FUN = sum, na.rm = na.rm) 385s + res <- rowSums(x, na.rm = na.rm) 385s + if (!useNames) names(res) <- NULL 385s + res 385s + } 385s > 385s > colSums2_R <- function(x, na.rm = FALSE, ..., useNames = TRUE) { 385s + ## FIXME: sum() may overflow for integers, whereas 385s + ## base::colSums() doesn't. What should colSums2() do? 385s + ## apply(x, MARGIN = 2L, FUN = sum, na.rm = na.rm) 385s + res <- colSums(x, na.rm = na.rm) 385s + if (!useNames) names(res) <- NULL 385s + res 385s + } 385s > 385s > for (mode in c("integer", "logical", "double")) { 385s + x <- matrix(-4:4, nrow = 3, ncol = 3) 385s + storage.mode(x) <- mode 385s + if (mode == "double") x <- x + 0.1 385s + 385s + # To check names attribute 385s + dimnames <- list(letters[1:3], LETTERS[1:3]) 385s + 385s + # Test with and without dimnames on x 385s + for (setDimnames in c(TRUE, FALSE)) { 385s + if (setDimnames) dimnames(x) <- dimnames 385s + else dimnames(x) <- NULL 385s + # Check names attribute 385s + for (useNames in c(TRUE, FALSE)) { 385s + y0 <- rowSums2_R(x, na.rm = FALSE, useNames = useNames) 385s + y1 <- rowSums2(x, na.rm = FALSE, useNames = useNames) 385s + stopifnot(all.equal(y1, y0)) 385s + 385s + y0 <- colSums2_R(x, na.rm = FALSE, useNames = useNames) 385s + y1 <- colSums2(x, na.rm = FALSE, useNames = useNames) 385s + stopifnot(all.equal(y1, y0)) 385s + } 385s + } 385s + } 385s > 385s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 385s > # Special case: Single-element matrix 385s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 385s > cat("Special case: Single-element matrix:\n") 385s Special case: Single-element matrix: 385s > for (mode in c("integer", "logical", "double")) { 385s + x <- matrix(1, nrow = 1, ncol = 1) 385s + storage.mode(x) <- mode 385s + 385s + # To check names attribute 385s + dimnames <- list("a", "A") 385s + 385s + # Test with and without dimnames on x 385s + for (setDimnames in c(TRUE, FALSE)) { 385s + if (setDimnames) dimnames(x) <- dimnames 385s + else dimnames(x) <- NULL 385s + # Check names attribute 385s + for (useNames in c(TRUE, FALSE)) { 385s + y0 <- rowSums2_R(x, na.rm = FALSE, useNames = useNames) 385s + y1 <- rowSums2(x, na.rm = FALSE, useNames = useNames) 385s + stopifnot(all.equal(y1, y0)) 385s + 385s + y0 <- colSums2_R(x, na.rm = FALSE, useNames = useNames) 385s + y1 <- colSums2(x, na.rm = FALSE, useNames = useNames) 385s + stopifnot(all.equal(y1, y0)) 385s + } 385s + } 385s + } 385s > 385s > 385s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 385s > # Special case: Empty matrix 385s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 385s > cat("Special case: Empty matrix:\n") 385s Special case: Empty matrix: 385s > for (mode in c("integer", "logical", "double")) { 385s + x <- matrix(integer(0), nrow = 0, ncol = 0) 385s + storage.mode(x) <- mode 385s + 385s + y0 <- rowSums2_R(x, na.rm = FALSE) 385s + y1 <- rowSums2(x, na.rm = FALSE) 385s + stopifnot(all.equal(y1, y0)) 385s + 385s + y0 <- colSums2_R(x, na.rm = FALSE) 385s + y1 <- colSums2(x, na.rm = FALSE) 385s + stopifnot(all.equal(y1, y0)) 385s + } 385s > 385s > 385s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 385s > # Special case: All NAs 385s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 385s > cat("Special case: All NAs:\n") 385s Special case: All NAs: 385s > for (mode in c("integer", "logical", "double")) { 385s + x <- matrix(NA_integer_, nrow = 3, ncol = 3) 385s + storage.mode(x) <- mode 385s + 385s + # To check names attribute 385s + dimnames <- list(letters[1:3], LETTERS[1:3]) 385s + 385s + # Test with and without dimnames on x 385s + for (setDimnames in c(TRUE, FALSE)) { 385s + if (setDimnames) dimnames(x) <- dimnames 385s + else dimnames(x) <- NULL 385s + # Check names attribute 385s + for (useNames in c(TRUE, FALSE)) { 385s + y0 <- rowSums2_R(x, na.rm = TRUE, useNames = useNames) 385s + y1 <- rowSums2(x, na.rm = TRUE, useNames = useNames) 385s + stopifnot(all.equal(y1, y0)) 385s + 385s + y0 <- colSums2_R(x, na.rm = TRUE, useNames = useNames) 385s + y1 <- colSums2(x, na.rm = TRUE, useNames = useNames) 385s + stopifnot(all.equal(y1, y0)) 385s + } 385s + } 385s + } 385s > 385s > 385s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 385s > # Special case: All NaNs 385s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 385s > cat("Special case: All NaNs:\n") 385s Special case: All NaNs: 385s > x <- matrix(NA_real_, nrow = 3, ncol = 3) 385s > 385s > # Test with and without dimnames on x 385s > for (setDimnames in c(TRUE, FALSE)) { 385s + if (setDimnames) dimnames(x) <- dimnames 385s + else dimnames(x) <- NULL 385s + # Check names attribute 385s + for (useNames in c(TRUE, FALSE)) { 385s + y0 <- rowSums2_R(x, na.rm = TRUE, useNames = useNames) 385s + y1 <- rowSums2(x, na.rm = TRUE, useNames = useNames) 385s + stopifnot(all.equal(y1, y0)) 385s + 385s + y0 <- colSums2_R(x, na.rm = TRUE, useNames = useNames) 385s + y1 <- colSums2(x, na.rm = TRUE, useNames = useNames) 385s + stopifnot(all.equal(y1, y0)) 385s + } 385s + } 385s > 385s > 385s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 385s > # Special case: All Infs 385s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 385s > cat("Special case: All Infs:\n") 385s Special case: All Infs: 385s > x <- matrix(Inf, nrow = 3, ncol = 3) 385s > 385s > # Test with and without dimnames on x 385s > for (setDimnames in c(TRUE, FALSE)) { 385s + if (setDimnames) dimnames(x) <- dimnames 385s + else dimnames(x) <- NULL 385s + # Check names attribute 385s + for (useNames in c(TRUE, FALSE)) { 385s + y0 <- rowSums2_R(x, na.rm = FALSE, useNames = useNames) 385s + y1 <- rowSums2(x, na.rm = FALSE, useNames = useNames) 385s + stopifnot(all.equal(y1, y0)) 385s + 385s + y0 <- colSums2_R(x, na.rm = FALSE, useNames = useNames) 385s + y1 <- colSums2(x, na.rm = FALSE, useNames = useNames) 385s + stopifnot(all.equal(y1, y0)) 385s + } 385s + } 385s > 385s > 385s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 385s > # Special case: All -Infs 385s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 385s > cat("Special case: All -Infs:\n") 385s Special case: All -Infs: 385s > x <- matrix(-Inf, nrow = 3, ncol = 3) 385s > 385s > # Test with and without dimnames on x 385s > for (setDimnames in c(TRUE, FALSE)) { 385s + if (setDimnames) dimnames(x) <- dimnames 385s + else dimnames(x) <- NULL 385s + # Check names attribute 385s + for (useNames in c(TRUE, FALSE)) { 385s + y0 <- rowSums2_R(x, na.rm = FALSE, useNames = useNames) 385s + y1 <- rowSums2(x, na.rm = FALSE, useNames = useNames) 385s + stopifnot(all.equal(y1, y0)) 385s + 385s + y0 <- colSums2_R(x, na.rm = FALSE, useNames = useNames) 385s + y1 <- colSums2(x, na.rm = FALSE, useNames = useNames) 385s + stopifnot(all.equal(y1, y0)) 385s + } 385s + } 385s > 385s > 385s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 385s > # Special case: Infs and -Infs 385s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 385s > cat("Special case: Infs and -Infs:\n") 385s Special case: Infs and -Infs: 385s > x <- matrix(c(-Inf, +Inf), nrow = 4, ncol = 4) 385s > 385s > # To check names attribute 385s > dimnames <- list(letters[1:4], LETTERS[1:4]) 385s > 385s > # Test with and without dimnames on x 385s > for (setDimnames in c(TRUE, FALSE)) { 385s + if (setDimnames) dimnames(x) <- dimnames 385s + else dimnames(x) <- NULL 385s + # Check names attribute 385s + for (useNames in c(TRUE, FALSE)) { 385s + y0 <- rowSums2_R(x, na.rm = FALSE, useNames = useNames) 385s + y1 <- rowSums2(x, na.rm = FALSE, useNames = useNames) 385s + stopifnot(all.equal(y1, y0)) 385s + 385s + y0 <- colSums2_R(x, na.rm = FALSE, useNames = useNames) 385s + y1 <- colSums2(x, na.rm = FALSE, useNames = useNames) 385s + stopifnot(all.equal(y1, y0)) 385s + } 385s + } 385s > 385s > 385s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 385s > # Special case: NaNs and NAs 385s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 385s > cat("Special case: Infs and -Infs:\n") 385s Special case: Infs and -Infs: 385s > x <- matrix(c(NaN, NA_real_), nrow = 4, ncol = 4) 385s > 385s > y0 <- rowSums(x, na.rm = FALSE) 385s > str(y0) 385s num [1:4] NaN NA NaN NA 385s > stopifnot(all(is.na(y0)), length(unique(y0)) >= 1L) 385s > y1 <- rowSums2(x, na.rm = FALSE) 385s > str(y0) 385s num [1:4] NaN NA NaN NA 385s > stopifnot(all(is.na(y1)), length(unique(y1)) >= 1L) 385s > stopifnot(all.equal(y1, y0)) 385s > 385s > y0 <- colSums(x, na.rm = FALSE) 385s > stopifnot(all(is.na(y0)), length(unique(y0)) == 1L) 385s > y1 <- colSums2(x, na.rm = FALSE) 385s > stopifnot(all(is.na(y1)), length(unique(y1)) == 1L) 385s > ## NOTE, due to compiler optimization, it is not guaranteed that NA is 385s > ## returned here (as one would expect). NaN might very well be returned, 385s > ## when both NA and NaN are involved. This is an accepted feature in R, 385s > ## which is documented in help("is.nan"). See also 385s > ## https://stat.ethz.ch/pipermail/r-devel/2017-April/074009.html. 385s > ## Thus, we cannot guarantee that y1 is identical to y0. 385s > 385s > 385s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 385s > # Special case: Integer overflow with ties 385s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 385s > cat("Special case: Integer overflow with ties:\n") 385s Special case: Integer overflow with ties: 385s > x <- matrix(.Machine$integer.max, nrow = 4, ncol = 4) 385s > 385s > # Test with and without dimnames on x 385s > for (setDimnames in c(TRUE, FALSE)) { 385s + if (setDimnames) dimnames(x) <- dimnames 385s + else dimnames(x) <- NULL 385s + # Check names attribute 385s + for (useNames in c(TRUE, FALSE)) { 385s + y0 <- rowSums2_R(x, na.rm = FALSE, useNames = useNames) 385s + y1 <- rowSums2(x, na.rm = FALSE, useNames = useNames) 385s + stopifnot(all.equal(y1, y0)) 385s + 385s + y0 <- colSums2_R(x, na.rm = FALSE, useNames = useNames) 385s + y1 <- colSums2(x, na.rm = FALSE, useNames = useNames) 385s + stopifnot(all.equal(y1, y0)) 385s + } 385s + } 385s > 385s > 385s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 385s > # Consistency checks 385s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 385s > set.seed(1) 385s > 385s > cat("Consistency checks:\n") 385s Consistency checks: 385s > n_sims <- if (Sys.getenv("_R_CHECK_USE_VALGRIND_") != "") 4L else 20L 385s > for (kk in seq_len(n_sims)) { 385s + cat("Random test #", kk, "\n", sep = "") 385s + 385s + # Simulate data in a matrix of any shape 385s + dim <- sample(50:200, size = 2) 385s + n <- prod(dim) 385s + x <- rnorm(n, sd = 100) 385s + dim(x) <- dim 385s + 385s + # Add NAs? 385s + if ((kk %% 4) %in% c(3, 0)) { 385s + cat("Adding NAs\n") 385s + nna <- sample(n, size = 1) 385s + na_values <- c(NA_real_, NaN) 385s + t <- sample(na_values, size = nna, replace = TRUE) 385s + x[sample(length(x), size = nna)] <- t 385s + } 385s + 385s + # Mode? 385s + modes <- "double" 385s + if ((kk %% 4) %in% c(2, 0)) { 385s + modes <- c("integer", "logical") 385s + } 385s + 385s + for (mode in modes) { 385s + if (mode != "double") { 385s + cat(sprintf("Coercing from %s to %s\n", storage.mode(x), mode)) 385s + storage.mode(x) <- mode 385s + } 385s + 385s + na.rm <- sample(c(TRUE, FALSE), size = 1) 385s + 385s + # rowSums2(): 385s + y0 <- rowSums2_R(x, na.rm = na.rm) 385s + y1 <- rowSums2(x, na.rm = na.rm) 385s + stopifnot(all.equal(y1, y0)) 385s + y2 <- colSums2(t(x), na.rm = na.rm) 385s + stopifnot(all.equal(y2, y0)) 385s + 385s + # colSums2(): 385s + y0 <- colSums2_R(x, na.rm = na.rm) 385s + y1 <- colSums2(x, na.rm = na.rm) 385s + stopifnot(all.equal(y1, y0)) 385s + y2 <- rowSums2(t(x), na.rm = na.rm) 385s + stopifnot(all.equal(y2, y0)) 385s + } 385s + } # for (kk ...) 385s Random test #1 385s Random test #2 385s Coercing from double to integer 385s Coercing from integer to logical 385s Random test #3 385s Adding NAs 385s Random test #4 385s Adding NAs 385s Coercing from double to integer 385s Coercing from integer to logical 385s Random test #5 385s Random test #6 385s Coercing from double to integer 385s Coercing from integer to logical 385s Random test #7 385s Adding NAs 385s Random test #8 385s Adding NAs 385s Coercing from double to integer 385s Coercing from integer to logical 385s Random test #9 385s Random test #10 385s Coercing from double to integer 385s Coercing from integer to logical 385s Random test #11 385s Adding NAs 385s Random test #12 385s Adding NAs 385s Coercing from double to integer 385s Coercing from integer to logical 385s Random test #13 385s Random test #14 385s Coercing from double to integer 385s Coercing from integer to logical 385s Random test #15 385s Adding NAs 385s Random test #16 385s Adding NAs 385s Coercing from double to integer 385s Coercing from integer to logical 385s Random test #17 385s Random test #18 385s Coercing from double to integer 385s Coercing from integer to logical 385s Random test #19 385s Adding NAs 385s Random test #20 385s Adding NAs 385s Coercing from double to integer 385s Coercing from integer to logical 385s > 386s 386s R version 4.4.3 (2025-02-28) -- "Trophy Case" 386s Copyright (C) 2025 The R Foundation for Statistical Computing 386s Platform: aarch64-unknown-linux-gnu 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 386s > library("matrixStats") 386s > 386s > rowSums2_R <- function(x, na.rm = FALSE, ..., useNames = TRUE) { 386s + ## FIXME: sum() may overflow for integers, whereas 386s + ## base::rowSums() doesn't. What should rowSums2() do? 386s + ## apply(x, MARGIN = 1L, FUN = sum, na.rm = na.rm) 386s + res <- rowSums(x, na.rm = na.rm) 386s + if (!useNames) names(res) <- NULL 386s + res 386s + } 386s > 386s > colSums2_R <- function(x, na.rm = FALSE, ..., useNames = TRUE) { 386s + ## FIXME: sum() may overflow for integers, whereas 386s + ## base::colSums() doesn't. What should colSums2() do? 386s + ## apply(x, MARGIN = 2L, FUN = sum, na.rm = na.rm) 386s + res <- colSums(x, na.rm = na.rm) 386s + if (!useNames) names(res) <- NULL 386s + res 386s + } 386s > 386s > 386s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 386s > # Subsetted tests 386s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 386s > source("utils/validateIndicesFramework.R") 386s > x <- matrix(runif(6 * 6, min = -3, max = 3), nrow = 6, ncol = 6) 386s > storage.mode(x) <- "integer" 386s > 386s > # To check names attribute 386s > dimnames <- list(letters[1:6], LETTERS[1:6]) 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 + for (rows in index_cases) { 386s + for (cols in index_cases) { 386s + for (na.rm in c(TRUE, FALSE)) { 386s + for (useNames in c(TRUE, FALSE)) { 386s + validateIndicesTestMatrix(x, rows, cols, 386s + ftest = rowSums2, fsure = rowSums2_R, 386s + na.rm = na.rm, useNames = useNames) 386s + validateIndicesTestMatrix(x, rows, cols, 386s + fcoltest = colSums2, fsure = rowSums2_R, 386s + na.rm = na.rm, useNames = useNames) 386s + } 386s + } 386s + } 386s + } 386s + } 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: aarch64-unknown-linux-gnu 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 > nrow <- 6L 387s > ncol <- 5L 387s > data <- matrix(0:4, nrow = nrow, ncol = ncol) 387s > 387s > # To check names attribute 387s > dimnames <- list(letters[1:6], LETTERS[1:5]) 387s > 387s > modes <- c("integer", "logical", "raw") 387s > for (mode in modes) { 387s + cat(sprintf("Mode: %s...\n", mode)) 387s + 387s + x <- data 387s + if (mode == "logical") x <- x - 2L 387s + if (mode != "raw") x[c(2,5,7)] <- NA_integer_ 387s + storage.mode(x) <- mode 387s + print(x) 387s + 387s + unique_values <- unique(as.vector(x)) 387s + nbr_of_unique_values <- length(unique_values) 387s + 387s + y <- rowTabulates(x) 387s + print(y) 387s + stopifnot( 387s + identical(dim(y), c(nrow, nbr_of_unique_values)), 387s + all(y >= 0) 387s + ) 387s + if (mode != "raw") { 387s + y0 <- t(table(x, row(x), useNA = "always")[, seq_len(nrow(x))]) 387s + stopifnot(all(y == y0)) 387s + } 387s + # Check names attribute 387s + dimnames(x) <- dimnames 387s + y1 <- rowTabulates(x, useNames = FALSE) 387s + stopifnot(all.equal(y1, y)) 387s + y <- rowTabulates(x, useNames = TRUE) 387s + stopifnot(identical(rownames(y), rownames(x))) 387s + dimnames(x) <- NULL 387s + 387s + y <- colTabulates(x) 387s + print(y) 387s + stopifnot( 387s + identical(dim(y), c(ncol, nbr_of_unique_values)), 387s + all(y >= 0) 387s + ) 387s + if (mode != "raw") { 387s + y0 <- t(table(x, col(x), useNA = "always")[, seq_len(ncol(x))]) 387s + stopifnot(all(y == y0)) 387s + } 387s + # Check names attribute 387s + dimnames(x) <- dimnames 387s + y1 <- colTabulates(x, useNames = FALSE) 387s + stopifnot(all.equal(y1, y)) 387s + y <- colTabulates(x, useNames = TRUE) 387s + stopifnot(identical(rownames(y), colnames(x))) 387s + dimnames(x) <- NULL 387s + 387s + # Count only certain values 387s + if (mode == "integer") { 387s + subset <- c(0:2, NA_integer_) 387s + } else if (mode == "logical") { 387s + subset <- c(TRUE, FALSE, NA) 387s + } else { 387s + subset <- c(0:2) 387s + } 387s + y <- rowTabulates(x, values = subset) 387s + print(y) 387s + stopifnot(identical(dim(y), c(nrow, length(subset)))) 387s + # Check names attribute 387s + dimnames(x) <- dimnames 387s + y1 <- rowTabulates(x, values = subset, useNames = FALSE) 387s + stopifnot(all.equal(y1, y)) 387s + y <- rowTabulates(x, values = subset, useNames = TRUE) 387s + stopifnot(identical(rownames(y), rownames(x))) 387s + dimnames(x) <- NULL 387s + 387s + y <- colTabulates(x, values = subset) 387s + print(y) 387s + stopifnot(identical(dim(y), c(ncol, length(subset)))) 387s + # Check names attribute 387s + dimnames(x) <- dimnames 387s + y1 <- colTabulates(x, values = subset, useNames = FALSE) 387s + stopifnot(all.equal(y1, y)) 387s + y <- colTabulates(x, values = subset, useNames = TRUE) 387s + stopifnot(identical(rownames(y), colnames(x))) 387s + dimnames(x) <- NULL 387s + 387s + # Raw 387s + if (mode %in% c("integer", "raw")) { 387s + subset <- c(0:2) 387s + 387s + y <- rowTabulates(x, values = as.raw(subset)) 387s + print(y) 387s + stopifnot(identical(dim(y), c(nrow, length(subset)))) 387s + # Check names attribute 387s + dimnames(x) <- dimnames 387s + y1 <- rowTabulates(x, values = as.raw(subset), useNames = FALSE) 387s + stopifnot(all.equal(y1, y)) 387s + y3 <- rowTabulates(x, values = as.raw(subset), useNames = TRUE) 387s + stopifnot(identical(rownames(y3), rownames(x))) 387s + dimnames(x) <- NULL 387s + 387s + y2 <- colTabulates(t(x), values = as.raw(subset)) 387s + print(y2) 387s + stopifnot( 387s + identical(dim(y2), c(nrow, length(subset))), 387s + identical(y2, y) 387s + ) 387s + # Check names attribute 387s + dimnames(x) <- dimnames 387s + y1 <- colTabulates(t(x), values = as.raw(subset), useNames = FALSE) 387s + stopifnot(all.equal(y1, y)) 387s + y <- colTabulates(t(x), values = as.raw(subset), useNames = TRUE) 387s + stopifnot(identical(rownames(y), colnames(t(x)))) 387s + dimnames(x) <- NULL 387s + } 387s + 387s + cat(sprintf("Mode: %s...done\n", mode)) 387s + } # for (mode ...) 387s Mode: integer... 387s [,1] [,2] [,3] [,4] [,5] 387s [1,] 0 NA 2 3 4 387s [2,] NA 2 3 4 0 387s [3,] 2 3 4 0 1 387s [4,] 3 4 0 1 2 387s [5,] NA 0 1 2 3 387s [6,] 0 1 2 3 4 387s 0 1 2 3 4 387s [1,] 1 0 1 1 1 1 387s [2,] 1 0 1 1 1 1 387s [3,] 1 1 1 1 1 0 387s [4,] 1 1 1 1 1 0 387s [5,] 1 1 1 1 0 1 387s [6,] 1 1 1 1 1 0 387s 0 1 2 3 4 387s [1,] 2 0 1 1 0 2 387s [2,] 1 1 1 1 1 1 387s [3,] 1 1 2 1 1 0 387s [4,] 1 1 1 2 1 0 387s [5,] 1 1 1 1 2 0 387s 0 1 2 387s [1,] 1 0 1 1 387s [2,] 1 0 1 1 387s [3,] 1 1 1 0 387s [4,] 1 1 1 0 387s [5,] 1 1 1 1 387s [6,] 1 1 1 0 387s 0 1 2 387s [1,] 2 0 1 2 387s [2,] 1 1 1 1 387s [3,] 1 1 2 0 387s [4,] 1 1 1 0 387s [5,] 1 1 1 0 387s 0x0 0x1 0x2 387s [1,] 1 0 1 387s [2,] 1 0 1 387s [3,] 1 1 1 387s [4,] 1 1 1 387s [5,] 1 1 1 387s [6,] 1 1 1 387s 0x0 0x1 0x2 387s [1,] 1 0 1 387s [2,] 1 0 1 387s [3,] 1 1 1 387s [4,] 1 1 1 387s [5,] 1 1 1 387s [6,] 1 1 1 387s Mode: integer...done 387s Mode: logical... 387s [,1] [,2] [,3] [,4] [,5] 387s [1,] TRUE NA FALSE TRUE TRUE 387s [2,] NA FALSE TRUE TRUE TRUE 387s [3,] FALSE TRUE TRUE TRUE TRUE 387s [4,] TRUE TRUE TRUE TRUE FALSE 387s [5,] NA TRUE TRUE FALSE TRUE 387s [6,] TRUE TRUE FALSE TRUE TRUE 387s FALSE TRUE 387s [1,] 1 3 1 387s [2,] 1 3 1 387s [3,] 1 4 0 387s [4,] 1 4 0 387s [5,] 1 3 1 387s [6,] 1 4 0 387s FALSE TRUE 387s [1,] 1 3 2 387s [2,] 1 4 1 387s [3,] 2 4 0 387s [4,] 1 5 0 387s [5,] 1 5 0 387s TRUE FALSE 387s [1,] 3 1 1 387s [2,] 3 1 1 387s [3,] 4 1 0 387s [4,] 4 1 0 387s [5,] 3 1 1 387s [6,] 4 1 0 387s TRUE FALSE 387s [1,] 3 1 2 387s [2,] 4 1 1 387s [3,] 4 2 0 387s [4,] 5 1 0 387s [5,] 5 1 0 387s Mode: logical...done 387s Mode: raw... 387s [,1] [,2] [,3] [,4] [,5] 387s [1,] 00 01 02 03 04 387s [2,] 01 02 03 04 00 387s [3,] 02 03 04 00 01 387s [4,] 03 04 00 01 02 387s [5,] 04 00 01 02 03 387s [6,] 00 01 02 03 04 387s 0x0 0x1 0x2 0x3 0x4 387s [1,] 1 1 1 1 1 387s [2,] 1 1 1 1 1 387s [3,] 1 1 1 1 1 387s [4,] 1 1 1 1 1 387s [5,] 1 1 1 1 1 387s [6,] 1 1 1 1 1 387s 0x0 0x1 0x2 0x3 0x4 387s [1,] 2 1 1 1 1 387s [2,] 1 2 1 1 1 387s [3,] 1 1 2 1 1 387s [4,] 1 1 1 2 1 387s [5,] 1 1 1 1 2 387s 0 1 2 387s [1,] 1 1 1 387s [2,] 1 1 1 387s [3,] 1 1 1 387s [4,] 1 1 1 387s [5,] 1 1 1 387s [6,] 1 1 1 387s 0 1 2 387s [1,] 2 1 1 387s [2,] 1 2 1 387s [3,] 1 1 2 387s [4,] 1 1 1 387s [5,] 1 1 1 387s 0x0 0x1 0x2 387s [1,] 1 1 1 387s [2,] 1 1 1 387s [3,] 1 1 1 387s [4,] 1 1 1 387s [5,] 1 1 1 387s [6,] 1 1 1 387s 0x0 0x1 0x2 387s [1,] 1 1 1 387s [2,] 1 1 1 387s [3,] 1 1 1 387s [4,] 1 1 1 387s [5,] 1 1 1 387s [6,] 1 1 1 387s Mode: raw...done 387s > 387s 387s R version 4.4.3 (2025-02-28) -- "Trophy Case" 387s Copyright (C) 2025 The R Foundation for Statistical Computing 387s Platform: aarch64-unknown-linux-gnu 387s 387s R is free software and comes with ABSOLUTELY NO WARRANTY. 387s You are welcome to redistribute it under certain conditions. 387s Type 'license()' or 'licence()' for distribution details. 387s 387s R is a collaborative project with many contributors. 387s Type 'contributors()' for more information and 387s 'citation()' on how to cite R or R packages in publications. 387s 387s Type 'demo()' for some demos, 'help()' for on-line help, or 387s 'help.start()' for an HTML browser interface to help. 387s Type 'q()' to quit R. 387s 387s > library("matrixStats") 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 + useNames <- c(TRUE, FALSE) 387s + useNames <- useNames[count %% length(useNames) + 1] 387s + 387s + validateIndicesTestMatrix(x, rows, cols, 387s + ftest = rowTabulates, fsure = rowTabulates, useNames = useNames) 387s + validateIndicesTestMatrix(x, rows, cols, 387s + ftest = rowTabulates, fsure = rowTabulates, 387s + values = 1:3, useNames = useNames) 387s + 387s + validateIndicesTestMatrix(x, rows, cols, 387s + ftest = colTabulates, fsure = colTabulates, useNames = useNames) 387s + validateIndicesTestMatrix(x, rows, cols, 387s + ftest = colTabulates, fsure = colTabulates, 387s + values = 1:3, 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: aarch64-unknown-linux-gnu 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 > fcns <- list( 388s + rowVarDiffs = list(rowVarDiffs, colVarDiffs), 388s + rowSdDiffs = list(rowSdDiffs, colSdDiffs), 388s + rowMadDiffs = list(rowMadDiffs, colMadDiffs), 388s + rowIQRDiffs = list(rowIQRDiffs, colIQRDiffs) 388s + ) 388s > 388s > for (fcn in names(fcns)) { 388s + cat(sprintf("%s()...\n", fcn)) 388s + row_fcn <- fcns[[fcn]][[1L]] 388s + col_fcn <- fcns[[fcn]][[2L]] 389s + 389s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 389s + # With and without some NAs 389s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 389s + for (mode in c("integer", "double")) { 389s + for (add_na in c(FALSE, TRUE)) { 389s + cat("add_na = ", add_na, "\n", sep = "") 389s + 389s + x <- matrix(1:50 + 0.1, nrow = 10L, ncol = 5L) 389s + if (add_na) { 389s + x[3:7, c(2, 4)] <- NA_real_ 389s + } 389s + cat("mode: ", mode, "\n", sep = "") 389s + storage.mode(x) <- mode 389s + str(x) 389s + 389s + # To check names attribute 389s + dimnames <- list(letters[1:10], LETTERS[1:5]) 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 + # Row/column ranges 389s + for (na.rm in c(FALSE, TRUE)) { 389s + # Check names attribute 389s + for (useNames in c(TRUE, FALSE)) { 389s + cat("na.rm = ", na.rm, "\n", sep = "") 389s + r1 <- row_fcn(x, na.rm = na.rm, useNames = useNames) 389s + r2 <- col_fcn(t(x), na.rm = na.rm, useNames = useNames) 389s + stopifnot(all.equal(r1, r2)) 389s + } 389s + } 389s + } 389s + } # for (add_na ...) 389s + } 389s + 389s + 389s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 389s + # All NAs 389s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 389s + for (mode in c("integer", "double")) { 389s + x <- matrix(NA_real_, nrow = 10L, ncol = 5L) 389s + cat("mode: ", mode, "\n", sep = "") 389s + storage.mode(x) <- mode 389s + str(x) 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 + # Row/column ranges 389s + for (na.rm in c(FALSE, TRUE)) { 389s + # Check names attribute 389s + for (useNames in c(TRUE, FALSE)) { 389s + cat("na.rm = ", na.rm, "\n", sep = "") 389s + r1 <- row_fcn(x, na.rm = na.rm, useNames = useNames) 389s + r2 <- col_fcn(t(x), na.rm = na.rm, useNames = useNames) 389s + stopifnot(all.equal(r1, r2)) 389s + } 389s + } 389s + } 389s + } 389s + 389s + 389s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 389s + # A 1x1 matrix 389s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 389s + x <- matrix(0, nrow = 1L, ncol = 1L) 389s + dimnames <- list("a", "A") 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 + # Row/column ranges 389s + for (na.rm in c(FALSE, TRUE)) { 389s + # Check names attribute 389s + for (useNames in c(TRUE, FALSE)) { 389s + cat("na.rm = ", na.rm, "\n", sep = "") 389s + r1 <- row_fcn(x, na.rm = na.rm, useNames = useNames) 389s + r2 <- col_fcn(t(x), na.rm = na.rm, useNames = useNames) 389s + stopifnot(all.equal(r1, r2)) 389s + } 389s + } 389s + } 389s + 389s + cat(sprintf("%s()...DONE\n", fcn)) 389s + } # for (fcn ...) 389s rowVarDiffs()... 389s add_na = FALSE 389s mode: integer 389s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 389s na.rm = FALSE 389s na.rm = FALSE 389s na.rm = TRUE 389s na.rm = TRUE 389s na.rm = FALSE 389s na.rm = FALSE 389s na.rm = TRUE 389s na.rm = TRUE 389s add_na = TRUE 389s mode: integer 389s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 389s na.rm = FALSE 389s na.rm = FALSE 389s na.rm = TRUE 389s na.rm = TRUE 389s na.rm = FALSE 389s na.rm = FALSE 389s na.rm = TRUE 389s na.rm = TRUE 389s add_na = FALSE 389s mode: double 389s 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 ... 389s na.rm = FALSE 389s na.rm = FALSE 389s na.rm = TRUE 389s na.rm = TRUE 389s na.rm = FALSE 389s na.rm = FALSE 389s na.rm = TRUE 389s na.rm = TRUE 389s add_na = TRUE 389s mode: double 389s 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 ... 389s na.rm = FALSE 389s na.rm = FALSE 389s na.rm = TRUE 389s na.rm = TRUE 389s na.rm = FALSE 389s na.rm = FALSE 389s na.rm = TRUE 389s na.rm = TRUE 389s mode: integer 389s int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 389s na.rm = FALSE 389s na.rm = FALSE 389s na.rm = TRUE 389s na.rm = TRUE 389s na.rm = FALSE 389s na.rm = FALSE 389s na.rm = TRUE 389s na.rm = TRUE 389s mode: double 389s num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 389s na.rm = FALSE 389s na.rm = FALSE 389s na.rm = TRUE 389s na.rm = TRUE 389s na.rm = FALSE 389s na.rm = FALSE 389s na.rm = TRUE 389s na.rm = TRUE 389s na.rm = FALSE 389s na.rm = FALSE 389s na.rm = TRUE 389s na.rm = TRUE 389s na.rm = FALSE 389s na.rm = FALSE 389s na.rm = TRUE 389s na.rm = TRUE 389s rowVarDiffs()...DONE 389s rowSdDiffs()... 389s add_na = FALSE 389s mode: integer 389s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 389s na.rm = FALSE 389s na.rm = FALSE 389s na.rm = TRUE 389s na.rm = TRUE 389s na.rm = FALSE 389s na.rm = FALSE 389s na.rm = TRUE 389s na.rm = TRUE 389s add_na = TRUE 389s mode: integer 389s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 389s na.rm = FALSE 389s na.rm = FALSE 389s na.rm = TRUE 389s na.rm = TRUE 389s na.rm = FALSE 389s na.rm = FALSE 389s na.rm = TRUE 389s na.rm = TRUE 389s add_na = FALSE 389s mode: double 389s 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 ... 389s na.rm = FALSE 389s na.rm = FALSE 389s na.rm = TRUE 389s na.rm = TRUE 389s na.rm = FALSE 389s na.rm = FALSE 389s na.rm = TRUE 389s na.rm = TRUE 389s add_na = TRUE 389s mode: double 389s 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 ... 389s na.rm = FALSE 389s na.rm = FALSE 389s na.rm = TRUE 389s na.rm = TRUE 389s na.rm = FALSE 389s na.rm = FALSE 389s na.rm = TRUE 389s na.rm = TRUE 389s mode: integer 389s int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 389s na.rm = FALSE 389s na.rm = FALSE 389s na.rm = TRUE 389s na.rm = TRUE 389s na.rm = FALSE 389s na.rm = FALSE 389s na.rm = TRUE 389s na.rm = TRUE 389s mode: double 389s num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 389s na.rm = FALSE 389s na.rm = FALSE 389s na.rm = TRUE 389s na.rm = TRUE 389s na.rm = FALSE 389s na.rm = FALSE 389s na.rm = TRUE 389s na.rm = TRUE 389s na.rm = FALSE 389s na.rm = FALSE 389s na.rm = TRUE 389s na.rm = TRUE 389s na.rm = FALSE 389s na.rm = FALSE 389s na.rm = TRUE 389s na.rm = TRUE 389s rowSdDiffs()...DONE 389s rowMadDiffs()... 389s add_na = FALSE 389s mode: integer 389s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 389s na.rm = FALSE 389s na.rm = FALSE 389s na.rm = TRUE 389s na.rm = TRUE 389s na.rm = FALSE 389s na.rm = FALSE 389s na.rm = TRUE 389s na.rm = TRUE 389s add_na = TRUE 389s mode: integer 389s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 389s na.rm = FALSE 389s na.rm = FALSE 389s na.rm = TRUE 389s na.rm = TRUE 389s na.rm = FALSE 389s na.rm = FALSE 389s na.rm = TRUE 389s na.rm = TRUE 389s add_na = FALSE 389s mode: double 389s 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 ... 389s na.rm = FALSE 389s na.rm = FALSE 389s na.rm = TRUE 389s na.rm = TRUE 389s na.rm = FALSE 389s na.rm = FALSE 389s na.rm = TRUE 389s na.rm = TRUE 389s add_na = TRUE 389s mode: double 389s 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 ... 389s na.rm = FALSE 389s na.rm = FALSE 389s na.rm = TRUE 389s na.rm = TRUE 389s na.rm = FALSE 389s na.rm = FALSE 389s na.rm = TRUE 389s na.rm = TRUE 389s mode: integer 389s int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 389s na.rm = FALSE 389s na.rm = FALSE 389s na.rm = TRUE 389s na.rm = TRUE 389s na.rm = FALSE 389s na.rm = FALSE 389s na.rm = TRUE 389s na.rm = TRUE 389s mode: double 389s num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 389s na.rm = FALSE 389s na.rm = FALSE 389s na.rm = TRUE 389s na.rm = TRUE 389s na.rm = FALSE 389s na.rm = FALSE 389s na.rm = TRUE 389s na.rm = TRUE 389s na.rm = FALSE 389s na.rm = FALSE 389s na.rm = TRUE 389s na.rm = TRUE 389s na.rm = FALSE 389s na.rm = FALSE 389s na.rm = TRUE 389s na.rm = TRUE 389s rowMadDiffs()...DONE 389s rowIQRDiffs()... 389s add_na = FALSE 389s mode: integer 389s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 389s na.rm = FALSE 389s na.rm = FALSE 389s na.rm = TRUE 389s na.rm = TRUE 389s na.rm = FALSE 389s na.rm = FALSE 389s na.rm = TRUE 389s na.rm = TRUE 389s add_na = TRUE 389s mode: integer 389s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 389s na.rm = FALSE 389s na.rm = FALSE 389s na.rm = TRUE 389s na.rm = TRUE 389s na.rm = FALSE 389s na.rm = FALSE 389s na.rm = TRUE 389s na.rm = TRUE 389s add_na = FALSE 389s mode: double 389s 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 ... 389s na.rm = FALSE 389s na.rm = FALSE 389s na.rm = TRUE 389s na.rm = TRUE 389s na.rm = FALSE 389s na.rm = FALSE 389s na.rm = TRUE 389s na.rm = TRUE 389s add_na = TRUE 389s mode: double 389s 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 ... 389s na.rm = FALSE 389s na.rm = FALSE 389s na.rm = TRUE 389s na.rm = TRUE 389s na.rm = FALSE 389s na.rm = FALSE 389s na.rm = TRUE 389s na.rm = TRUE 389s mode: integer 389s int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 389s na.rm = FALSE 389s na.rm = FALSE 389s na.rm = TRUE 389s na.rm = TRUE 389s na.rm = FALSE 389s na.rm = FALSE 389s na.rm = TRUE 389s na.rm = TRUE 389s mode: double 389s num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 389s na.rm = FALSE 389s na.rm = FALSE 389s na.rm = TRUE 389s na.rm = TRUE 389s na.rm = FALSE 389s na.rm = FALSE 389s na.rm = TRUE 389s na.rm = TRUE 389s na.rm = FALSE 389s na.rm = FALSE 389s na.rm = TRUE 389s na.rm = TRUE 389s na.rm = FALSE 389s na.rm = FALSE 389s na.rm = TRUE 389s na.rm = TRUE 389s rowIQRDiffs()...DONE 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: aarch64-unknown-linux-gnu 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 > fcns <- list( 389s + madDiff = c(rowMadDiffs, colMadDiffs), 389s + iqrDiff = c(rowIQRDiffs, colIQRDiffs) 389s + ) 389s > 389s > 389s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 389s > # Subsetted tests 389s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 389s > source("utils/validateIndicesFramework.R") 389s > # To check names attribute 389s > dimnames <- list(letters[1:6], LETTERS[1:6]) 389s > trim <- runif(1, min = 0, max = 0.5) 389s > for (fcn in names(fcns)) { 389s + cat(sprintf("subsetted tests on %s()...\n", fcn)) 389s + row_fcn <- fcns[[fcn]][[1L]] 389s + col_fcn <- fcns[[fcn]][[2L]] 389s + 389s + for (mode in c("numeric", "integer")) { 389s + x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6L, ncol = 6L) 389s + storage.mode(x) <- mode 389s + if (mode == "numeric") x[1:2, 3:4] <- Inf 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 (diff in 1:2) { 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 + validateIndicesTestMatrix(x, rows, cols, 389s + ftest = row_fcn, fsure = row_fcn, 389s + na.rm = na.rm, diff = diff, trim = trim, useNames = useNames) 389s + validateIndicesTestMatrix(x, rows, cols, 389s + fcoltest = col_fcn, fsure = row_fcn, 389s + na.rm = na.rm, diff = diff, trim = trim, useNames = useNames) 389s + } 389s + } 389s + } 389s + } 389s + } 389s + cat(sprintf("%s()...DONE\n", fcn)) 389s + } 389s subsetted tests on madDiff()... 392s madDiff()...DONE 392s subsetted tests on iqrDiff()... 394s iqrDiff()...DONE 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: aarch64-unknown-linux-gnu 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 > fcns <- list( 394s + varDiff = c(rowVarDiffs, colVarDiffs), 394s + sdDiff = c(rowSdDiffs, colSdDiffs) 394s + ) 394s > 394s > 394s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 394s > # Subsetted tests 394s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 394s > source("utils/validateIndicesFramework.R") 394s > # To check names attribute 394s > dimnames <- list(letters[1:6], LETTERS[1:6]) 394s > trim <- runif(1, min = 0, max = 0.5) 394s > for (fcn in names(fcns)) { 394s + cat(sprintf("subsetted tests on %s()...\n", fcn)) 394s + row_fcn <- fcns[[fcn]][[1L]] 394s + col_fcn <- fcns[[fcn]][[2L]] 394s + 394s + for (mode in c("numeric", "integer")) { 394s + x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6L, ncol = 6L) 394s + storage.mode(x) <- mode 394s + if (mode == "numeric") x[1:2, 3:4] <- Inf 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 + 394s + count <- 0L 394s + for (diff in 1:2) { 394s + for (rows in index_cases) { 394s + for (cols in index_cases) { 394s + count <- count + 1L 394s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 394s + useNames <- c(TRUE, FALSE) 394s + useNames <- useNames[count %% length(useNames) + 1] 394s + 394s + validateIndicesTestMatrix(x, rows, cols, 394s + ftest = row_fcn, fsure = row_fcn, 394s + na.rm = na.rm, diff = diff, trim = trim, useNames = useNames) 394s + validateIndicesTestMatrix(x, rows, cols, 394s + fcoltest = col_fcn, fsure = row_fcn, 394s + na.rm = na.rm, diff = diff, trim = trim, useNames = useNames) 394s + } 394s + } 394s + } 394s + } 394s + } 394s + cat(sprintf("%s()...DONE\n", fcn)) 394s + } 394s subsetted tests on varDiff()... 396s varDiff()...DONE 396s subsetted tests on sdDiff()... 398s sdDiff()...DONE 398s > 398s 398s R version 4.4.3 (2025-02-28) -- "Trophy Case" 398s Copyright (C) 2025 The R Foundation for Statistical Computing 398s Platform: aarch64-unknown-linux-gnu 398s 398s R is free software and comes with ABSOLUTELY NO WARRANTY. 398s You are welcome to redistribute it under certain conditions. 398s Type 'license()' or 'licence()' for distribution details. 398s 398s R is a collaborative project with many contributors. 398s Type 'contributors()' for more information and 398s 'citation()' on how to cite R or R packages in publications. 398s 398s Type 'demo()' for some demos, 'help()' for on-line help, or 398s 'help.start()' for an HTML browser interface to help. 398s Type 'q()' to quit R. 398s 398s > library("matrixStats") 398s > 398s > ## Always allow testing of the 'center' argument (as long as it's not defunct) 398s > options(matrixStats.center.onUse = "ignore") 398s > options(matrixStats.vars.formula.freq = Inf) 398s > 398s > ## Create isFALSE() if running on an old version of R 398s > if (!exists("isFALSE", mode="function")) { 398s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 398s + } 398s > 398s > rowVars_R <- function(x, na.rm = FALSE, center = NULL, ..., useNames = TRUE) { 398s + suppressWarnings({ 398s + res <- apply(x, MARGIN = 1L, FUN = var, na.rm = na.rm) 398s + }) 398s + stopifnot(!any(is.infinite(res))) 398s + 398s + # Keep naming support consistency same as rowVars() 398s + if (is.null(center) || ncol(x) <= 1L) { 398s + if (isFALSE(useNames)) names(res) <- NULL 398s + } 398s + else if (isFALSE(useNames)) names(res) <- NULL 398s + res 398s + } 398s > 398s > colVars_R <- function(x, na.rm = FALSE, center = NULL, ..., useNames = TRUE) { 398s + suppressWarnings({ 398s + res <- apply(x, MARGIN = 2L, FUN = var, na.rm = na.rm) 398s + }) 398s + stopifnot(!any(is.infinite(res))) 398s + 398s + # Keep naming support consistency same as colVars() 398s + if (is.null(center) || ncol(x) <= 1L) { 398s + if (isFALSE(useNames)) names(res) <- NULL 398s + } 398s + else if (isFALSE(useNames)) names(res) <- NULL 398s + res 398s + } 398s > 398s > 398s > rowVars_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) { 398s + center <- rowWeightedMeans(x, cols = cols, na.rm = na.rm, useNames = FALSE) 398s + res <- rowVars(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 398s + stopifnot(!any(is.infinite(res))) 398s + res 398s + } 398s > 398s > colVars_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) { 398s + center <- colWeightedMeans(x, rows = rows, na.rm = na.rm, useNames = FALSE) 398s + res <- colVars(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 398s + stopifnot(!any(is.infinite(res))) 398s + res 398s + } 398s > 398s > rowVars_center_naive <- function(x, rows = NULL, cols = NULL, center = NULL, na.rm = FALSE, ..., useNames = TRUE) { 398s + x <- sweep(x, MARGIN = 1, STATS = as.array(center), FUN = "-") 398s + x[is.infinite(center), ] <- NaN 398s + res <- rowVars(x, rows = rows, cols = cols, center = rep(0, times = nrow(x)), na.rm = na.rm, useNames = useNames) 398s + stopifnot(!any(is.infinite(res))) 398s + res 398s + } 398s > 398s > colVars_center_naive <- function(x, rows = NULL, cols = NULL, center = NULL, na.rm = FALSE, ..., useNames = TRUE) { 398s + x <- sweep(x, MARGIN = 2, STATS = as.array(center), FUN = "-") 398s + x[, is.infinite(center)] <- NaN 398s + res <- colVars(x, rows = rows, cols = cols, center = rep(0, times = ncol(x)), na.rm = na.rm, useNames = useNames) 398s + stopifnot(!any(is.infinite(res))) 398s + res 398s + } 398s > 398s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 398s > # With and without some NAs or Infs 398s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 398s > for (mode in c("integer", "double")) { 398s + if (mode == "integer") { 398s + specials <- c(0L, NA_integer_) 398s + delta <- 0L 398s + } else { 398s + specials <- c(0, NA_real_, Inf) 398s + delta <- 0.1 398s + } 398s + 398s + for (special in specials) { 398s + cat("special = ", special, "\n", sep = "") 398s + x <- matrix(1:50 + delta, nrow = 10L, ncol = 5L) 398s + x[3:7, c(2, 4)] <- special 398s + cat("mode: ", mode, "\n", sep = "") 398s + str(x) 398s + stopifnot(storage.mode(x) == mode) 398s + 398s + # To check names attribute 398s + dimnames <- list(letters[1:10], LETTERS[1:5]) 398s + 398s + # Test with and without dimnames on x 398s + for (setDimnames in c(TRUE, FALSE)) { 398s + if (setDimnames) dimnames(x) <- dimnames 398s + else dimnames(x) <- NULL 398s + # Row/column variance 398s + for (na.rm in c(FALSE, TRUE)) { 398s + # Check names attribute 398s + for (useNames in c(TRUE, FALSE)) { 398s + cat("na.rm = ", na.rm, "\n", sep = "") 398s + center <- rowMeans(x, na.rm = na.rm) 398s + 398s + r0 <- rowVars_R(x, na.rm = na.rm, useNames = useNames) 398s + r1 <- rowVars(x, na.rm = na.rm, useNames = useNames) 398s + r1b <- rowVars_center(x, na.rm = na.rm, useNames = useNames) 398s + r1c <- rowVars(x, center = center, na.rm = na.rm, useNames = useNames) 398s + 398s + tx <- t(x) 398s + r2 <- colVars(tx, na.rm = na.rm, useNames = useNames) 398s + r2b <- colVars_center(tx, na.rm = na.rm, useNames = useNames) 398s + r2c <- colVars(tx, center = center, na.rm = na.rm, useNames = useNames) 398s + tx <- NULL 398s + 398s + stopifnot(all.equal(r1, r2)) 398s + stopifnot(all.equal(r1, r0)) 398s + stopifnot(all.equal(r1b, r1c)) 398s + stopifnot(all.equal(r2, r0)) 398s + stopifnot(all.equal(r2b, r2c)) 398s + 398s + center <- colMeans(x, na.rm = na.rm) 398s + 398s + r3 <- colVars(x, center = center, na.rm = na.rm, useNames = useNames) 398s + r3b <- colVars_center_naive(x, center = center, na.rm = na.rm, useNames = useNames) 398s + r3c <- rowVars(t(x), center = center, na.rm = na.rm, useNames = useNames) 398s + r3d <- rowVars_center_naive(t(x), center = center, na.rm = na.rm, useNames = useNames) 398s + stopifnot(all.equal(r3b, r3)) 398s + stopifnot(all.equal(r3c, r3)) 398s + stopifnot(all.equal(r3d, r3)) 398s + 398s + stopifnot( 398s + !any(is.infinite(r0)), 398s + !any(is.infinite(r1)), 398s + !any(is.infinite(r2)), 398s + !any(is.infinite(r3)), 398s + !any(is.infinite(r1b)), 398s + !any(is.infinite(r1c)), 398s + !any(is.infinite(r2b)), 398s + !any(is.infinite(r2c)), 398s + !any(is.infinite(r3b)), 398s + !any(is.infinite(r3c)), 398s + !any(is.infinite(r3d)) 398s + ) 398s + } 398s + } 398s + } 398s + } # for (special ...) 398s + } 398s special = 0 398s mode: integer 398s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 398s na.rm = FALSE 398s na.rm = FALSE 398s na.rm = TRUE 398s na.rm = TRUE 398s na.rm = FALSE 398s na.rm = FALSE 398s na.rm = TRUE 398s na.rm = TRUE 398s special = NA 398s mode: integer 398s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 398s na.rm = FALSE 398s na.rm = FALSE 398s na.rm = TRUE 398s na.rm = TRUE 398s na.rm = FALSE 398s na.rm = FALSE 398s na.rm = TRUE 398s na.rm = TRUE 398s special = 0 398s mode: double 398s 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 ... 398s na.rm = FALSE 398s na.rm = FALSE 398s na.rm = TRUE 398s na.rm = TRUE 398s na.rm = FALSE 398s na.rm = FALSE 398s na.rm = TRUE 398s na.rm = TRUE 398s special = NA 398s mode: double 398s 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 ... 398s na.rm = FALSE 398s na.rm = FALSE 398s na.rm = TRUE 398s na.rm = TRUE 398s na.rm = FALSE 398s na.rm = FALSE 398s na.rm = TRUE 398s na.rm = TRUE 398s special = Inf 398s mode: double 398s 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 ... 398s na.rm = FALSE 398s na.rm = FALSE 398s na.rm = TRUE 398s na.rm = TRUE 398s na.rm = FALSE 398s na.rm = FALSE 398s na.rm = TRUE 398s na.rm = TRUE 398s > 398s > 398s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 398s > # All NAs 398s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 398s > for (mode in c("integer", "double")) { 398s + x <- matrix(NA_real_, nrow = 10L, ncol = 5L) 398s + cat("mode: ", mode, "\n", sep = "") 398s + storage.mode(x) <- mode 398s + str(x) 398s + 398s + # Test with and without dimnames on x 398s + for (setDimnames in c(TRUE, FALSE)) { 398s + if (setDimnames) dimnames(x) <- dimnames 398s + else dimnames(x) <- NULL 398s + # Row/column variance 398s + for (na.rm in c(FALSE, TRUE)) { 398s + # Check names attribute 398s + for (useNames in c(TRUE, FALSE)) { 398s + cat("na.rm = ", na.rm, "\n", sep = "") 398s + 398s + r0 <- rowVars_R(x, na.rm = na.rm, useNames = useNames) 398s + r1 <- rowVars(x, na.rm = na.rm, useNames = useNames) 398s + r1b <- rowVars_center(x, na.rm = na.rm, useNames = useNames) 398s + r2 <- colVars(t(x), na.rm = na.rm, useNames = useNames) 398s + r2b <- colVars_center(t(x), na.rm = na.rm, useNames = useNames) 398s + stopifnot(all.equal(r1, r2)) 398s + stopifnot(all.equal(r1, r0)) 398s + stopifnot(all.equal(r2, r0)) 398s + stopifnot(all.equal(r1b, r2b)) 398s + stopifnot( 398s + !any(is.infinite(r0)), 398s + !any(is.infinite(r1)), 398s + !any(is.infinite(r2)), 398s + !any(is.infinite(r1b)), 398s + !any(is.infinite(r2b)) 398s + ) 398s + } 398s + } 398s + } 398s + } 398s mode: integer 398s int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 398s na.rm = FALSE 398s na.rm = FALSE 398s na.rm = TRUE 398s na.rm = TRUE 398s na.rm = FALSE 398s na.rm = FALSE 398s na.rm = TRUE 398s na.rm = TRUE 398s mode: double 398s num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 398s na.rm = FALSE 398s na.rm = FALSE 398s na.rm = TRUE 398s na.rm = TRUE 398s na.rm = FALSE 398s na.rm = FALSE 398s na.rm = TRUE 398s na.rm = TRUE 398s > 398s > 398s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 398s > # A 1x1 matrix 398s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 398s > x <- matrix(0, nrow = 1L, ncol = 1L) 398s > dimnames <- list("a", "A") 398s > # Test with and without dimnames on x 398s > for (setDimnames in c(TRUE, FALSE)) { 398s + if (setDimnames) dimnames(x) <- dimnames 398s + else dimnames(x) <- NULL 398s + # Row/column variance 398s + for (na.rm in c(FALSE, TRUE)) { 398s + # Check names attribute 398s + for (useNames in c(TRUE, FALSE)) { 398s + cat("na.rm = ", na.rm, "\n", sep = "") 398s + 398s + r0 <- rowVars_R(x, na.rm = na.rm, useNames = useNames) 398s + r1 <- rowVars(x, na.rm = na.rm, useNames = useNames) 398s + r1b <- rowVars_center(x, na.rm = na.rm, useNames = useNames) 398s + r2 <- colVars(t(x), na.rm = na.rm, useNames = useNames) 398s + r2b <- colVars_center(t(x), na.rm = na.rm, useNames = useNames) 398s + stopifnot(all.equal(r1, r2)) 398s + stopifnot(all.equal(r1, r0)) 398s + stopifnot(all.equal(r2, r0)) 398s + stopifnot(all.equal(r1b, r2b)) 398s + stopifnot( 398s + !any(is.infinite(r0)), 398s + !any(is.infinite(r1)), 398s + !any(is.infinite(r2)), 398s + !any(is.infinite(r1b)), 398s + !any(is.infinite(r2b)) 398s + ) 398s + } 398s + } 398s + } 398s na.rm = FALSE 398s na.rm = FALSE 398s na.rm = TRUE 398s na.rm = TRUE 398s na.rm = FALSE 398s na.rm = FALSE 398s na.rm = TRUE 398s na.rm = TRUE 398s > 398s > 398s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 398s > # center and .dim 398s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 398s > m <- matrix(1:12, nrow = 3L, ncol = 4L) 398s > a <- array(m, dim = c(3, 2, 2)) 398s > stopifnot(prod(dim(a)) == prod(dim(m))) 398s > 398s > y0 <- rowVars(m, dim. = dim(m)) 398s > print(y0) 398s [1] 15 15 15 398s > y1 <- rowVars(a, dim. = dim(m)) 398s > print(y1) 398s [1] 15 15 15 398s > stopifnot(identical(y1, y0)) 398s > stopifnot( 398s + !any(is.infinite(y0)), 398s + !any(is.infinite(y1)) 398s + ) 398s > 398s > mu <- rowMeans(m) 398s > y0 <- rowVars(m, center = mu, dim. = dim(m)) 398s > print(y0) 398s [1] 15 15 15 398s > y1 <- rowVars(a, center = mu, dim. = dim(m)) 398s > print(y1) 398s [1] 15 15 15 398s > stopifnot(identical(y1, y0)) 398s > stopifnot( 398s + !any(is.infinite(y0)), 398s + !any(is.infinite(y1)) 398s + ) 398s > 398s > 398s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 398s > # Corner cases 398s > # https://github.com/HenrikBengtsson/matrixStats/issues/195 398s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 398s > x <- matrix(c(1,2,3,4), nrow = 2L, ncol = 2L) 398s > x[1,1] <- NA_real_ 398s > x[1,2] <- Inf 398s > 398s > center <- colMeans2(x, na.rm = TRUE) 398s > y <- colVars(x, center = center, na.rm = TRUE) 398s > stopifnot(!any(is.infinite(y))) 398s > 398s > x <- t(x) 398s > center <- rowMeans2(x, na.rm = TRUE) 398s > y <- rowVars(x, center = center, na.rm = TRUE) 398s > stopifnot(!any(is.infinite(y))) 398s > 398s 398s R version 4.4.3 (2025-02-28) -- "Trophy Case" 398s Copyright (C) 2025 The R Foundation for Statistical Computing 398s Platform: aarch64-unknown-linux-gnu 398s 398s R is free software and comes with ABSOLUTELY NO WARRANTY. 398s You are welcome to redistribute it under certain conditions. 398s Type 'license()' or 'licence()' for distribution details. 398s 398s R is a collaborative project with many contributors. 398s Type 'contributors()' for more information and 398s 'citation()' on how to cite R or R packages in publications. 398s 398s Type 'demo()' for some demos, 'help()' for on-line help, or 398s 'help.start()' for an HTML browser interface to help. 398s Type 'q()' to quit R. 398s 398s > library("matrixStats") 398s > 398s > ## Always allow testing of the 'center' argument (as long as it's not defunct) 398s > options(matrixStats.center.onUse = "ignore") 398s > 398s > ## Create isFALSE() if running on an old version of R 398s > if (!exists("isFALSE", mode="function")) { 398s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 398s + } 398s > 398s > rowVars_R <- function(x, na.rm = FALSE, center = NULL, ..., useNames = TRUE) { 398s + suppressWarnings({ 398s + res <- apply(x, MARGIN = 1L, FUN = var, na.rm = na.rm) 398s + }) 398s + stopifnot(!any(is.infinite(res))) 398s + 398s + # Keep naming support consistency same as rowVars() 398s + if (is.null(center) || ncol(x) <= 1L) { 398s + if (isFALSE(useNames)) names(res) <- NULL 398s + } 398s + else if (isFALSE(useNames)) names(res) <- NULL 398s + res 398s + } 398s > 398s > colVars_R <- function(x, na.rm = FALSE, center = NULL, ..., useNames = TRUE) { 398s + suppressWarnings({ 398s + res <- apply(x, MARGIN = 2L, FUN = var, na.rm = na.rm) 398s + }) 398s + stopifnot(!any(is.infinite(res))) 398s + 398s + # Keep naming support consistency same as colVars() 398s + if (is.null(center) || nrow(x) <= 1L) { 398s + if (isFALSE(useNames)) names(res) <- NULL 398s + } 398s + else if (isFALSE(useNames)) names(res) <- NULL 398s + res 398s + } 398s > 398s > 398s > rowVars_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) { 398s + center <- rowWeightedMeans(x, cols = cols, na.rm = na.rm, useNames = FALSE) 398s + res <- rowVars(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 398s + stopifnot(!any(is.infinite(res))) 398s + res 398s + } 398s > 398s > colVars_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = TRUE) { 398s + center <- colWeightedMeans(x, rows = rows, na.rm = na.rm, useNames = FALSE) 398s + res <- colVars(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 398s + stopifnot(!any(is.infinite(res))) 398s + res 398s + } 398s > 398s > 398s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 398s > # Subsetted tests 398s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 398s > source("utils/validateIndicesFramework.R") 398s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 398s > storage.mode(x) <- "integer" 398s > 398s > # To check names attribute 398s > dimnames <- list(letters[1:6], LETTERS[1:6]) 398s > 398s > # Test with and without dimnames on x 398s > for (setDimnames in c(TRUE, FALSE)) { 398s + if (setDimnames) dimnames(x) <- dimnames 398s + else dimnames(x) <- NULL 398s + 398s + count <- 0L 398s + for (rows in index_cases) { 398s + for (cols in index_cases) { 398s + count <- count + 1L 398s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 398s + useNames <- c(TRUE, FALSE) 398s + useNames <- useNames[count %% length(useNames) + 1] 398s + 398s + validateIndicesTestMatrix(x, rows, cols, 398s + ftest = rowVars, fsure = rowVars_R, 398s + na.rm = na.rm, useNames = useNames) 398s + validateIndicesTestMatrix(x, rows, cols, 398s + ftest = rowVars_center, fsure = rowVars_R, 398s + na.rm = na.rm, center = TRUE, useNames = useNames) 398s + 398s + validateIndicesTestMatrix(x, rows, cols, 398s + fcoltest = colVars, fsure = rowVars_R, 398s + na.rm = na.rm, useNames = useNames) 398s + validateIndicesTestMatrix(x, rows, cols, 398s + fcoltest = colVars_center, fsure = rowVars_R, 398s + na.rm = na.rm, center = TRUE, useNames = useNames) 398s + } 398s + } 398s + } 399s > 399s 399s R version 4.4.3 (2025-02-28) -- "Trophy Case" 399s Copyright (C) 2025 The R Foundation for Statistical Computing 399s Platform: aarch64-unknown-linux-gnu 399s 399s R is free software and comes with ABSOLUTELY NO WARRANTY. 399s You are welcome to redistribute it under certain conditions. 399s Type 'license()' or 'licence()' for distribution details. 399s 399s R is a collaborative project with many contributors. 399s Type 'contributors()' for more information and 399s 'citation()' on how to cite R or R packages in publications. 399s 399s Type 'demo()' for some demos, 'help()' for on-line help, or 399s 'help.start()' for an HTML browser interface to help. 399s Type 'q()' to quit R. 399s 399s > library("matrixStats") 399s > 399s > ## Create isFALSE() if running on an old version of R 399s > if (!exists("isFALSE", mode="function")) { 399s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 399s + } 399s > 399s > rowWeightedMeans_R <- function(x, w, na.rm = FALSE, ..., useNames = TRUE) { 399s + res <- apply(x, MARGIN = 1L, FUN = weighted.mean, w = w, na.rm = na.rm, ...) 399s + 399s + # Keep naming support consistency same as rowWeightedMeans() 399s + idxs <- which(is.na(w) | w != 0) 399s + nw <- length(idxs) 399s + if (na.rm) na.rm <- anyMissing(x) 399s + if ((!is.null(w) && nw == 0L) || isFALSE(na.rm)) { 399s + if (!useNames) names(res) <- NULL 399s + } 399s + else if (isFALSE(useNames)) names(res) <- NULL 399s + 399s + res 399s + } 399s > 399s > colWeightedMeans_R <- function(x, w, na.rm = FALSE, ..., useNames = TRUE) { 399s + res <- apply(x, MARGIN = 2L, FUN = weighted.mean, w = w, na.rm = na.rm, ...) 399s + 399s + # Keep naming support consistency same as colWeightedMeans() 399s + idxs <- which(is.na(w) | w != 0) 399s + nw <- length(idxs) 399s + if (!is.null(w) && nw == 0L) { 399s + if (!useNames) names(res) <- NULL 399s + } 399s + else if (isFALSE(useNames)) names(res) <- NULL 399s + 399s + res 399s + } 399s > 399s > set.seed(1) 399s > 399s > x <- matrix(rnorm(20), nrow = 5, ncol = 4) 399s > print(x) 399s [,1] [,2] [,3] [,4] 399s [1,] -0.6264538 -0.8204684 1.5117812 -0.04493361 399s [2,] 0.1836433 0.4874291 0.3898432 -0.01619026 399s [3,] -0.8356286 0.7383247 -0.6212406 0.94383621 399s [4,] 1.5952808 0.5757814 -2.2146999 0.82122120 399s [5,] 0.3295078 -0.3053884 1.1249309 0.59390132 399s > 399s > # To check names attribute 399s > dimnames <- list(letters[1:5], LETTERS[1:4]) 399s > 399s > # Non-weighted row averages 399s > x_est0 <- rowMeans(x) 399s > x_est1 <- rowWeightedMeans(x) 399s > print(x_est1) 399s [1] 0.004981341 0.261181337 0.056322931 0.194395865 0.435737906 399s > stopifnot(all.equal(x_est1, x_est0)) 399s > x_est2 <- colWeightedMeans(t(x)) 399s > stopifnot(all.equal(x_est2, x_est0)) 399s > # Check names attribute 399s > dimnames(x) <- dimnames 399s > x_est1 <- rowWeightedMeans(x, useNames = FALSE) 399s > x_est2 <- colWeightedMeans(t(x), useNames = FALSE) 399s > stopifnot(all.equal(x_est1, x_est0)) 399s > stopifnot(all.equal(x_est2, x_est0)) 399s > x_est0 <- rowMeans(x) 399s > x_est1 <- rowWeightedMeans(x, useNames = TRUE) 399s > x_est2 <- colWeightedMeans(t(x), useNames = TRUE) 399s > stopifnot(all.equal(x_est1, x_est0)) 399s > stopifnot(all.equal(x_est2, x_est0)) 399s > dimnames(x) <- NULL 399s > 399s > 399s > # Weighted row averages (uniform weights) 399s > w <- rep(2.5, times = ncol(x)) 399s > x_est0 <- rowMeans(x) 399s > x_est1 <- rowWeightedMeans(x, w = w) 399s > print(x_est1) 399s [1] 0.004981341 0.261181337 0.056322931 0.194395865 0.435737906 399s > stopifnot(all.equal(x_est1, x_est0)) 399s > x_est2 <- colWeightedMeans(t(x), w = w) 399s > stopifnot(all.equal(x_est2, x_est0)) 399s > # Test with and without dimnames on x 399s > for (setDimnames in c(TRUE, FALSE)) { 399s + if (setDimnames) dimnames(x) <- dimnames 399s + else dimnames(x) <- NULL 399s + # Check names attribute 399s + for (useNames in c(TRUE, FALSE)) { 399s + x_est0 <- rowWeightedMeans_R(x, w = w, useNames = useNames) 399s + x_est1 <- rowWeightedMeans(x, w = w, useNames = useNames) 399s + stopifnot(all.equal(x_est1, x_est0)) 399s + x_est0 <- colWeightedMeans_R(t(x), w = w, useNames = useNames) 399s + x_est1 <- colWeightedMeans(t(x), w = w, useNames = useNames) 399s + stopifnot(all.equal(x_est1, x_est0)) 399s + } 399s + } 399s > 399s > 399s > # Weighted row averages (excluding some columns) 399s > w <- c(1, 1, 0, 1) 399s > x_est0 <- rowMeans(x[, (w == 1), drop = FALSE]) 399s > x_est1 <- rowWeightedMeans(x, w = w) 399s > print(x_est1) 399s [1] -0.4972853 0.2182940 0.2821774 0.9974278 0.2060069 399s > stopifnot(all.equal(x_est1, x_est0)) 399s > x_est2 <- colWeightedMeans(t(x), w = w) 399s > stopifnot(all.equal(x_est2, x_est0)) 399s > # Test with and without dimnames on x 399s > for (setDimnames in c(TRUE, FALSE)) { 399s + if (setDimnames) dimnames(x) <- dimnames 399s + else dimnames(x) <- NULL 399s + # Check names attribute 399s + for (useNames in c(TRUE, FALSE)) { 399s + x_est0 <- rowWeightedMeans_R(x, w = w, useNames = useNames) 399s + x_est1 <- rowWeightedMeans(x, w = w, useNames = useNames) 399s + stopifnot(all.equal(x_est1, x_est0)) 399s + x_est0 <- colWeightedMeans_R(t(x), w = w, useNames = useNames) 399s + x_est1 <- colWeightedMeans(t(x), w = w, useNames = useNames) 399s + stopifnot(all.equal(x_est1, x_est0)) 399s + } 399s + } 399s > 399s > 399s > # Weighted row averages (excluding some columns) 399s > w <- c(0, 1, 0, 0) 399s > x_est0 <- rowMeans(x[, (w == 1), drop = FALSE]) 399s > x_est1 <- rowWeightedMeans(x, w = w) 399s > stopifnot(all.equal(x_est1, x_est0)) 399s > x_est2 <- colWeightedMeans(t(x), w = w) 399s > stopifnot(all.equal(x_est2, x_est0)) 399s > # Test with and without dimnames on x 399s > for (setDimnames in c(TRUE, FALSE)) { 399s + if (setDimnames) dimnames(x) <- dimnames 399s + else dimnames(x) <- NULL 399s + # Check names attribute 399s + for (useNames in c(TRUE, FALSE)) { 399s + x_est0 <- rowWeightedMeans_R(x, w = w, useNames = useNames) 399s + x_est1 <- rowWeightedMeans(x, w = w, useNames = useNames) 399s + stopifnot(all.equal(x_est1, x_est0)) 399s + x_est0 <- colWeightedMeans_R(t(x), w = w, useNames = useNames) 399s + x_est1 <- colWeightedMeans(t(x), w = w, useNames = useNames) 399s + stopifnot(all.equal(x_est1, x_est0)) 399s + } 399s + } 399s > 399s > 399s > # Weighted row averages (all zero weights) 399s > w <- c(0, 0, 0, 0) 399s > x_est0 <- rowMeans(x[, (w == 1), drop = FALSE]) 399s > x_est1 <- rowWeightedMeans(x, w = w) 399s > stopifnot(all.equal(x_est1, x_est0)) 399s > x_est2 <- colWeightedMeans(t(x), w = w) 399s > stopifnot(all.equal(x_est2, x_est0)) 399s > # Test with and without dimnames on x 399s > for (setDimnames in c(TRUE, FALSE)) { 399s + if (setDimnames) dimnames(x) <- dimnames 399s + else dimnames(x) <- NULL 399s + # Check names attribute 399s + for (useNames in c(TRUE, FALSE)) { 399s + x_est0 <- rowWeightedMeans_R(x, w = w, useNames = useNames) 399s + x_est1 <- rowWeightedMeans(x, w = w, useNames = useNames) 399s + stopifnot(all.equal(x_est1, x_est0)) 399s + x_est0 <- colWeightedMeans_R(t(x), w = w, useNames = useNames) 399s + x_est1 <- colWeightedMeans(t(x), w = w, useNames = useNames) 399s + stopifnot(all.equal(x_est1, x_est0)) 399s + } 399s + } 400s > 400s > 400s > # Weighted averages by rows and columns 400s > w <- 1:4 400s > x_est1 <- rowWeightedMeans(x, w = w) 400s > print(x_est1) 400s [1] 0.20882185 0.22632701 0.25526439 -0.06123714 0.54691290 400s > x_est2 <- colWeightedMeans(t(x), w = w) 400s > stopifnot(all.equal(x_est2, x_est1)) 400s > # Test with and without dimnames on x 400s > for (setDimnames in c(TRUE, FALSE)) { 400s + if (setDimnames) dimnames(x) <- dimnames 400s + else dimnames(x) <- NULL 400s + # Check names attribute 400s + for (useNames in c(TRUE, FALSE)) { 400s + x_est0 <- rowWeightedMeans_R(x, w = w, useNames = useNames) 400s + x_est1 <- rowWeightedMeans(x, w = w, useNames = useNames) 400s + stopifnot(all.equal(x_est1, x_est0)) 400s + x_est0 <- colWeightedMeans_R(t(x), w = w, useNames = useNames) 400s + x_est1 <- colWeightedMeans(t(x), w = w, useNames = useNames) 400s + stopifnot(all.equal(x_est1, x_est0)) 400s + } 400s + } 400s > 400s > 400s > x[sample(length(x), size = 0.3 * length(x))] <- NA 400s > print(x) 400s [,1] [,2] [,3] [,4] 400s [1,] -0.6264538 NA 1.5117812 -0.04493361 400s [2,] 0.1836433 NA NA -0.01619026 400s [3,] -0.8356286 0.7383247 -0.6212406 0.94383621 400s [4,] 1.5952808 NA -2.2146999 0.82122120 400s [5,] 0.3295078 NA NA 0.59390132 400s > 400s > # Non-weighted row averages with missing values 400s > x_est0 <- rowMeans(x, na.rm = TRUE) 400s > x_est1 <- rowWeightedMeans(x, na.rm = TRUE) 400s > print(x_est1) 400s [1] 0.28013125 0.08372653 0.05632293 0.06726737 0.46170455 400s > stopifnot(all.equal(x_est1, x_est0)) 400s > x_est2 <- colWeightedMeans(t(x), na.rm = TRUE) 400s > stopifnot(all.equal(x_est2, x_est0)) 400s > # Check names attribute 400s > dimnames(x) <- dimnames 400s > x_est1 <- rowWeightedMeans(x, na.rm = TRUE, useNames = FALSE) 400s > x_est2 <- colWeightedMeans(t(x), na.rm = TRUE, useNames = FALSE) 400s > stopifnot(all.equal(x_est1, x_est0)) 400s > stopifnot(all.equal(x_est2, x_est0)) 400s > x_est0 <- rowMeans(x, na.rm = TRUE) 400s > x_est1 <- rowWeightedMeans(x, na.rm = TRUE, useNames = TRUE) 400s > x_est2 <- colWeightedMeans(t(x), na.rm = TRUE, useNames = TRUE) 400s > stopifnot(all.equal(x_est1, x_est0)) 400s > stopifnot(all.equal(x_est2, x_est0)) 400s > dimnames(x) <- NULL 400s > 400s > 400s > # Weighted row averages with missing values 400s > x_est0 <- apply(x, MARGIN = 1L, FUN = weighted.mean, w = w, na.rm = TRUE) 400s > print(x_est0) 400s [1] 0.46614441 0.02377645 0.25526439 -0.22049176 0.54102261 400s > x_est1 <- rowWeightedMeans(x, w = w, na.rm = TRUE) 400s > print(x_est1) 400s [1] 0.46614441 0.02377645 0.25526439 -0.22049176 0.54102261 400s > stopifnot(all.equal(x_est1, x_est0)) 400s > x_est2 <- colWeightedMeans(t(x), w = w, na.rm = TRUE) 400s > stopifnot(all.equal(x_est2, x_est0)) 400s > # Test with and without dimnames on x 400s > for (setDimnames in c(TRUE, FALSE)) { 400s + if (setDimnames) dimnames(x) <- dimnames 400s + else dimnames(x) <- NULL 400s + # Check names attribute 400s + for (useNames in c(TRUE, FALSE)) { 400s + x_est0 <- rowWeightedMeans_R(x, w = w, na.rm = TRUE, useNames = useNames) 400s + x_est1 <- rowWeightedMeans(x, w = w, na.rm = TRUE, useNames = useNames) 400s + stopifnot(all.equal(x_est1, x_est0)) 400s + x_est0 <- colWeightedMeans_R(t(x), w = w, na.rm = TRUE, useNames = useNames) 400s + x_est1 <- colWeightedMeans(t(x), w = w, na.rm = TRUE, useNames = useNames) 400s + stopifnot(all.equal(x_est1, x_est0)) 400s + } 400s + } 400s > 400s > 400s > # Weighted averages by rows and columns 400s > w <- 1:4 400s > x_est1 <- rowWeightedMeans(x, w = w, na.rm = TRUE) 400s > x_est2 <- colWeightedMeans(t(x), w = w, na.rm = TRUE) 400s > stopifnot(all.equal(x_est2, x_est1)) 400s > # Test with and without dimnames on x 400s > for (setDimnames in c(TRUE, FALSE)) { 400s + if (setDimnames) dimnames(x) <- dimnames 400s + else dimnames(x) <- NULL 400s + # Check names attribute 400s + for (useNames in c(TRUE, FALSE)) { 400s + x_est0 <- rowWeightedMeans_R(x, w = w, na.rm = TRUE, useNames = useNames) 400s + x_est1 <- rowWeightedMeans(x, w = w, na.rm = TRUE, useNames = useNames) 400s + stopifnot(all.equal(x_est1, x_est0)) 400s + x_est0 <- colWeightedMeans_R(t(x), w = w, na.rm = TRUE, useNames = useNames) 400s + x_est1 <- colWeightedMeans(t(x), w = w, na.rm = TRUE, useNames = useNames) 400s + stopifnot(all.equal(x_est1, x_est0)) 400s + } 400s + } 400s > 400s > 400s > # w contains missing value 400s > w[1] <- NA_integer_ 400s > x_est1 <- rowWeightedMeans(x, w = w, na.rm = TRUE) 400s > x_est2 <- colWeightedMeans(t(x), w = w, na.rm = TRUE) 400s > stopifnot(all.equal(x_est2, x_est1)) 400s > # Test with and without dimnames on x 400s > for (setDimnames in c(TRUE, FALSE)) { 400s + if (setDimnames) dimnames(x) <- dimnames 400s + else dimnames(x) <- NULL 400s + # Check names attribute 400s + for (useNames in c(TRUE, FALSE)) { 400s + x_est0 <- rowWeightedMeans_R(x, w = w, na.rm = TRUE, useNames = useNames) 400s + x_est1 <- rowWeightedMeans(x, w = w, na.rm = TRUE, useNames = useNames) 400s + stopifnot(all.equal(x_est1, x_est0)) 400s + x_est0 <- colWeightedMeans_R(t(x), w = w, na.rm = TRUE, useNames = useNames) 400s + x_est1 <- colWeightedMeans(t(x), w = w, na.rm = TRUE, useNames = useNames) 400s + stopifnot(all.equal(x_est1, x_est0)) 400s + } 400s + } 400s > 400s > x_est1 <- rowWeightedMeans(x, w = w, na.rm = FALSE) 400s > x_est2 <- colWeightedMeans(t(x), w = w, na.rm = FALSE) 400s > stopifnot(all.equal(x_est2, x_est1)) 400s > # Test with and without dimnames on x 400s > for (setDimnames in c(TRUE, FALSE)) { 400s + if (setDimnames) dimnames(x) <- dimnames 400s + else dimnames(x) <- NULL 400s + # Check names attribute 400s + for (useNames in c(TRUE, FALSE)) { 400s + x_est0 <- rowWeightedMeans_R(x, w = w, na.rm = FALSE, useNames = useNames) 400s + x_est1 <- rowWeightedMeans(x, w = w, na.rm = FALSE, useNames = useNames) 400s + stopifnot(all.equal(x_est1, x_est0)) 400s + x_est0 <- colWeightedMeans_R(t(x), w = w, na.rm = FALSE, useNames = useNames) 400s + x_est1 <- colWeightedMeans(t(x), w = w, na.rm = FALSE, useNames = useNames) 400s + stopifnot(all.equal(x_est1, x_est0)) 400s + } 400s + } 400s > 400s 400s R version 4.4.3 (2025-02-28) -- "Trophy Case" 400s Copyright (C) 2025 The R Foundation for Statistical Computing 400s Platform: aarch64-unknown-linux-gnu 400s 400s R is free software and comes with ABSOLUTELY NO WARRANTY. 400s You are welcome to redistribute it under certain conditions. 400s Type 'license()' or 'licence()' for distribution details. 400s 400s R is a collaborative project with many contributors. 400s Type 'contributors()' for more information and 400s 'citation()' on how to cite R or R packages in publications. 400s 400s Type 'demo()' for some demos, 'help()' for on-line help, or 400s 'help.start()' for an HTML browser interface to help. 400s Type 'q()' to quit R. 400s 400s > library("matrixStats") 400s > 400s > ## Create isFALSE() if running on an old version of R 400s > if (!exists("isFALSE", mode="function")) { 400s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 400s + } 400s > 400s > rowWeightedMeans_R <- function(x, w, na.rm = FALSE, ..., useNames = TRUE) { 400s + res <- apply(x, MARGIN = 1L, FUN = weighted.mean, w = w, na.rm = na.rm, ...) 400s + 400s + # Keep naming support consistency same as rowWeightedMeans() 400s + idxs <- which(is.na(w) | w != 0) 400s + nw <- length(idxs) 400s + if (na.rm) na.rm <- anyMissing(x) 400s + if ((!is.null(w) && nw == 0L) || isFALSE(na.rm)) { 400s + if (!useNames) names(res) <- NULL 400s + } 400s + else if (isFALSE(useNames)) names(res) <- NULL 400s + 400s + res 400s + } 400s > 400s > colWeightedMeans_R <- function(x, w, na.rm = FALSE, ..., useNames = TRUE) { 400s + res <- apply(x, MARGIN = 1L, FUN = weighted.mean, w = w, na.rm = na.rm, ...) 400s + 400s + # Keep naming support consistency same as colWeightedMeans() 400s + idxs <- which(is.na(w) | w != 0) 400s + nw <- length(idxs) 400s + if (!is.null(w) && nw == 0L) { 400s + if (!useNames) names(res) <- NULL 400s + } 400s + else if (isFALSE(useNames)) names(res) <- NULL 400s + 400s + res 400s + } 400s > 400s > 400s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 400s > # Subsetted tests 400s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 400s > source("utils/validateIndicesFramework.R") 400s > # To check names attribute 400s > dimnames <- list(letters[1:6], LETTERS[1:6]) 400s > for (mode in c("numeric", "integer", "logical")) { 400s + x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 400s + w <- runif(6, min = 0, max = 6) 400s + storage.mode(x) <- mode 400s + storage.mode(w) <- if (mode == "logical") "integer" else mode 400s + if (mode == "numeric") w[1] <- Inf 400s + 400s + # Test with and without dimnames on x 400s + for (setDimnames in c(TRUE, FALSE)) { 400s + if (setDimnames) dimnames(x) <- dimnames 400s + else dimnames(x) <- NULL 400s + 400s + count <- 0L 400s + for (rows in index_cases) { 400s + for (cols in index_cases) { 400s + count <- count + 1L 400s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 400s + useNames <- c(TRUE, FALSE) 400s + useNames <- useNames[count %% length(useNames) + 1] 400s + 400s + validateIndicesTestMatrix_w(x, w, rows, cols, 400s + ftest = rowWeightedMeans, fsure = rowWeightedMeans_R, 400s + na.rm = na.rm, useNames = useNames) 400s + validateIndicesTestMatrix_w(x, w, rows, cols, 400s + fcoltest = colWeightedMeans, fsure = colWeightedMeans_R, 400s + na.rm = na.rm, useNames = useNames) 400s + } 400s + } 400s + } 400s + } 401s > 401s 401s R version 4.4.3 (2025-02-28) -- "Trophy Case" 401s Copyright (C) 2025 The R Foundation for Statistical Computing 401s Platform: aarch64-unknown-linux-gnu 401s 401s R is free software and comes with ABSOLUTELY NO WARRANTY. 401s You are welcome to redistribute it under certain conditions. 401s Type 'license()' or 'licence()' for distribution details. 401s 401s R is a collaborative project with many contributors. 401s Type 'contributors()' for more information and 401s 'citation()' on how to cite R or R packages in publications. 401s 401s Type 'demo()' for some demos, 'help()' for on-line help, or 401s 'help.start()' for an HTML browser interface to help. 401s Type 'q()' to quit R. 401s 401s > library("matrixStats") 401s > 401s > ## Create isFALSE() if running on an old version of R 401s > if (!exists("isFALSE", mode="function")) { 401s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 401s + } 401s > 401s > rowWeightedMedians_R <- function(x, w, na.rm = FALSE, ..., useNames = TRUE) { 401s + res <- apply(x, MARGIN = 1L, FUN = weightedMedian, w = w, na.rm = na.rm, ...) 401s + 401s + # Keep naming support consistency same as rowWeightedMedians() 401s + if (!is.null(w)) { 401s + if (isFALSE(useNames)) names(res) <- NULL 401s + } 401s + else if (!useNames) names(res) <- NULL 401s + 401s + res 401s + } 401s > 401s > colWeightedMedians_R <- function(x, w, na.rm = FALSE, ..., useNames = TRUE) { 401s + res <- apply(x, MARGIN = 2L, FUN = weightedMedian, w = w, na.rm = na.rm, ...) 401s + 401s + # Keep naming support consistency same as colWeightedMedians() 401s + if (!is.null(w)) { 401s + if (isFALSE(useNames)) names(res) <- NULL 401s + } 401s + else if (!useNames) names(res) <- NULL 401s + 401s + res 401s + } 401s > 401s > set.seed(1) 401s > 401s > x <- matrix(rnorm(20), nrow = 5, ncol = 4) 401s > print(x) 401s [,1] [,2] [,3] [,4] 401s [1,] -0.6264538 -0.8204684 1.5117812 -0.04493361 401s [2,] 0.1836433 0.4874291 0.3898432 -0.01619026 401s [3,] -0.8356286 0.7383247 -0.6212406 0.94383621 401s [4,] 1.5952808 0.5757814 -2.2146999 0.82122120 401s [5,] 0.3295078 -0.3053884 1.1249309 0.59390132 401s > 401s > # To check names attribute 401s > dimnames <- list(letters[1:5], LETTERS[1:4]) 401s > 401s > # Non-weighted row medians 401s > x_est0 <- rowMedians(x) 401s > x_est1 <- rowWeightedMedians(x) 401s > stopifnot(all.equal(x_est1, x_est0)) 401s > x_est2 <- colWeightedMedians(t(x)) 401s > stopifnot(all.equal(x_est2, x_est0)) 401s > # Test with and without dimnames on x 401s > for (setDimnames in c(TRUE, FALSE)) { 401s + if (setDimnames) dimnames(x) <- dimnames 401s + else dimnames(x) <- NULL 401s + # Check names attribute 401s + for (useNames in c(TRUE, FALSE)) { 401s + x_est0 <- rowMedians(x, useNames = useNames) 401s + x_est1 <- rowWeightedMedians(x, useNames = useNames) 401s + x_est2 <- colWeightedMedians(t(x), useNames = useNames) 401s + stopifnot(all.equal(x_est1, x_est0)) 401s + stopifnot(all.equal(x_est2, x_est0)) 401s + } 401s + } 401s > 401s > 401s > # Weighted row medians (uniform weights) 401s > w <- rep(2.5, times = ncol(x)) 401s > x_est0 <- rowMedians(x) 401s > x_est1 <- rowWeightedMedians(x, w = w) 401s > stopifnot(all.equal(x_est1, x_est0)) 401s > x_est2 <- colWeightedMedians(t(x), w = w) 401s > stopifnot(all.equal(x_est2, x_est0)) 401s > # Test with and without dimnames on x 401s > for (setDimnames in c(TRUE, FALSE)) { 401s + if (setDimnames) dimnames(x) <- dimnames 401s + else dimnames(x) <- NULL 401s + # Check names attribute 401s + for (useNames in c(TRUE, FALSE)) { 401s + x_est0 <- rowWeightedMedians_R(x, w = w, useNames = useNames) 401s + x_est1 <- rowWeightedMedians(x, w = w, useNames = useNames) 401s + stopifnot(all.equal(x_est1, x_est0)) 401s + x_est0 <- colWeightedMedians_R(t(x), w = w, useNames = useNames) 401s + x_est1 <- colWeightedMedians(t(x), w = w, useNames = useNames) 401s + stopifnot(all.equal(x_est1, x_est0)) 401s + } 401s + } 401s > 401s > 401s > # Weighted row medians (excluding some columns) 401s > w <- c(1, 1, 0, 1) 401s > x_est0 <- rowMedians(x[, (w == 1), drop = FALSE]) 401s > x_est1 <- rowWeightedMedians(x, w = w) 401s > stopifnot(all.equal(x_est1, x_est0)) 401s > x_est2 <- colWeightedMedians(t(x), w = w) 401s > stopifnot(all.equal(x_est2, x_est0)) 401s > # Test with and without dimnames on x 401s > for (setDimnames in c(TRUE, FALSE)) { 401s + if (setDimnames) dimnames(x) <- dimnames 401s + else dimnames(x) <- NULL 401s + # Check names attribute 401s + for (useNames in c(TRUE, FALSE)) { 401s + x_est0 <- rowWeightedMedians_R(x, w = w, useNames = useNames) 401s + x_est1 <- rowWeightedMedians(x, w = w, useNames = useNames) 401s + stopifnot(all.equal(x_est1, x_est0)) 401s + x_est0 <- colWeightedMedians_R(t(x), w = w, useNames = useNames) 401s + x_est1 <- colWeightedMedians(t(x), w = w, useNames = useNames) 401s + stopifnot(all.equal(x_est1, x_est0)) 401s + } 401s + } 401s > 401s > # Weighted row medians (excluding some columns) 401s > w <- c(0, 1, 0, 0) 401s > x_est0 <- rowMedians(x[, (w == 1), drop = FALSE]) 401s > x_est1 <- rowWeightedMedians(x, w = w) 401s > stopifnot(all.equal(x_est1, x_est0)) 401s > x_est2 <- colWeightedMedians(t(x), w = w) 401s > stopifnot(all.equal(x_est2, x_est0)) 401s > # Test with and without dimnames on x 401s > for (setDimnames in c(TRUE, FALSE)) { 401s + if (setDimnames) dimnames(x) <- dimnames 401s + else dimnames(x) <- NULL 401s + # Check names attribute 401s + for (useNames in c(TRUE, FALSE)) { 401s + x_est0 <- rowWeightedMedians_R(x, w = w, useNames = useNames) 401s + x_est1 <- rowWeightedMedians(x, w = w, useNames = useNames) 401s + stopifnot(all.equal(x_est1, x_est0)) 401s + x_est0 <- colWeightedMedians_R(t(x), w = w, useNames = useNames) 401s + x_est1 <- colWeightedMedians(t(x), w = w, useNames = useNames) 401s + stopifnot(all.equal(x_est1, x_est0)) 401s + } 401s + } 401s > 401s > # Weighted row medians (all zero weights) 401s > w <- c(0, 0, 0, 0) 401s > x_est0 <- rowMedians(x[, (w == 1), drop = FALSE]) 401s > x_est1 <- rowWeightedMedians(x, w = w) 401s > stopifnot(all.equal(x_est1, x_est0)) 401s > x_est2 <- colWeightedMedians(t(x), w = w) 401s > stopifnot(all.equal(x_est2, x_est0)) 401s > # Test with and without dimnames on x 401s > for (setDimnames in c(TRUE, FALSE)) { 401s + if (setDimnames) dimnames(x) <- dimnames 401s + else dimnames(x) <- NULL 401s + # Check names attribute 401s + for (useNames in c(TRUE, FALSE)) { 401s + x_est0 <- rowWeightedMedians_R(x, w = w, useNames = useNames) 401s + x_est1 <- rowWeightedMedians(x, w = w, useNames = useNames) 401s + stopifnot(all.equal(x_est1, x_est0)) 401s + x_est0 <- colWeightedMedians_R(t(x), w = w, useNames = useNames) 401s + x_est1 <- colWeightedMedians(t(x), w = w, useNames = useNames) 401s + stopifnot(all.equal(x_est1, x_est0)) 401s + } 401s + } 401s > 401s > # Weighted medians by rows and columns 401s > w <- 1:4 401s > x_est1 <- rowWeightedMedians(x, w = w) 401s > x_est2 <- colWeightedMedians(t(x), w = w) 401s > stopifnot(all.equal(x_est2, x_est1)) 401s > # Test with and without dimnames on x 401s > for (setDimnames in c(TRUE, FALSE)) { 401s + if (setDimnames) dimnames(x) <- dimnames 401s + else dimnames(x) <- NULL 401s + # Check names attribute 401s + for (useNames in c(TRUE, FALSE)) { 401s + x_est0 <- rowWeightedMedians_R(x, w = w, useNames = useNames) 401s + x_est1 <- rowWeightedMedians(x, w = w, useNames = useNames) 401s + stopifnot(all.equal(x_est1, x_est0)) 401s + x_est0 <- colWeightedMedians_R(t(x), w = w, useNames = useNames) 401s + x_est1 <- colWeightedMedians(t(x), w = w, useNames = useNames) 401s + stopifnot(all.equal(x_est1, x_est0)) 401s + } 401s + } 401s > 401s > 401s > # Weighted row medians with missing values 401s > x_est0 <- apply(x, MARGIN = 1L, FUN = weightedMedian, w = w, na.rm = TRUE) 401s > print(x_est0) 401s [1] -0.04493361 0.23519330 0.73832471 0.65759463 0.59390132 401s > x_est1 <- rowWeightedMedians(x, w = w, na.rm = TRUE) 401s > print(x_est1) 401s [1] -0.04493361 0.23519330 0.73832471 0.65759463 0.59390132 401s > stopifnot(all.equal(x_est1, x_est0)) 401s > x_est2 <- colWeightedMedians(t(x), w = w) 401s > stopifnot(all.equal(x_est2, x_est0)) 401s > # Test with and without dimnames on x 401s > for (setDimnames in c(TRUE, FALSE)) { 401s + if (setDimnames) dimnames(x) <- dimnames 401s + else dimnames(x) <- NULL 401s + # Check names attribute 401s + for (useNames in c(TRUE, FALSE)) { 401s + x_est0 <- rowWeightedMedians_R(x, w = w, na.rm = TRUE, useNames = useNames) 401s + x_est1 <- rowWeightedMedians(x, w = w, na.rm = TRUE, useNames = useNames) 401s + stopifnot(all.equal(x_est1, x_est0)) 401s + x_est0 <- colWeightedMedians_R(t(x), w = w, na.rm = TRUE, useNames = useNames) 401s + x_est1 <- colWeightedMedians(t(x), w = w, na.rm = TRUE, useNames = useNames) 401s + stopifnot(all.equal(x_est1, x_est0)) 401s + } 401s + } 401s > 401s > # Weighted medians by rows and columns 401s > w <- 1:4 401s > x_est1 <- rowWeightedMedians(x, w = w, na.rm = TRUE) 401s > x_est2 <- colWeightedMedians(t(x), w = w, na.rm = TRUE) 401s > stopifnot(all.equal(x_est2, x_est1)) 401s > # Test with and without dimnames on x 401s > for (setDimnames in c(TRUE, FALSE)) { 401s + if (setDimnames) dimnames(x) <- dimnames 401s + else dimnames(x) <- NULL 401s + # Check names attribute 401s + for (useNames in c(TRUE, FALSE)) { 401s + x_est0 <- rowWeightedMedians_R(x, w = w, na.rm = TRUE, useNames = useNames) 401s + x_est1 <- rowWeightedMedians(x, w = w, na.rm = TRUE, useNames = useNames) 401s + stopifnot(all.equal(x_est1, x_est0)) 401s + x_est0 <- colWeightedMedians_R(t(x), w = w, na.rm = TRUE, useNames = useNames) 401s + x_est1 <- colWeightedMedians(t(x), w = w, na.rm = TRUE, useNames = useNames) 401s + stopifnot(all.equal(x_est1, x_est0)) 401s + } 401s + } 401s > 401s > 401s > # Inf weight 401s > x <- matrix(1:2, nrow = 1, ncol = 2) 401s > w <- c(7, Inf) 401s > x_est1 <- rowWeightedMedians(x, w = w) 401s > x_est2 <- colWeightedMedians(t(x), w = w) 401s > stopifnot(identical(2, x_est1)) 401s > stopifnot(identical(2, x_est2)) 401s > # Test with and without dimnames on x 401s > dimnames <- list("a", LETTERS[1:2]) 401s > for (setDimnames in c(TRUE, FALSE)) { 401s + if (setDimnames) dimnames(x) <- dimnames 401s + else dimnames(x) <- NULL 401s + # Check names attribute 401s + for (useNames in c(TRUE, FALSE)) { 401s + x_est0 <- rowWeightedMedians_R(x, w = w, useNames = useNames) 401s + x_est1 <- rowWeightedMedians(x, w = w, useNames = useNames) 401s + stopifnot(all.equal(x_est1, x_est0)) 401s + x_est0 <- colWeightedMedians_R(t(x), w = w, useNames = useNames) 401s + x_est1 <- colWeightedMedians(t(x), w = w, useNames = useNames) 401s + stopifnot(all.equal(x_est1, x_est0)) 401s + } 401s + } 401s > 401s 401s R version 4.4.3 (2025-02-28) -- "Trophy Case" 401s Copyright (C) 2025 The R Foundation for Statistical Computing 401s Platform: aarch64-unknown-linux-gnu 401s 401s R is free software and comes with ABSOLUTELY NO WARRANTY. 401s You are welcome to redistribute it under certain conditions. 401s Type 'license()' or 'licence()' for distribution details. 401s 401s R is a collaborative project with many contributors. 401s Type 'contributors()' for more information and 401s 'citation()' on how to cite R or R packages in publications. 401s 401s Type 'demo()' for some demos, 'help()' for on-line help, or 401s 'help.start()' for an HTML browser interface to help. 401s Type 'q()' to quit R. 401s 401s > library("matrixStats") 401s > 401s > ## Create isFALSE() if running on an old version of R 401s > if (!exists("isFALSE", mode="function")) { 401s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 401s + } 401s > 401s > rowWeightedMedians_R <- function(x, w, na.rm = FALSE, ..., useNames = TRUE) { 401s + res <- apply(x, MARGIN = 1L, FUN = weightedMedian, w = w, na.rm = na.rm, ...) 401s + 401s + # Keep naming support consistency same as rowWeightedMedians() 401s + if (!is.null(w)) { 401s + if (isFALSE(useNames)) names(res) <- NULL 401s + } 401s + else if (!useNames) names(res) <- NULL 401s + 401s + res 401s + } 401s > 401s > 401s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 401s > # Subsetted tests 401s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 401s > source("utils/validateIndicesFramework.R") 401s > # To check names attribute 401s > dimnames <- list(letters[1:6], LETTERS[1:6]) 401s > for (mode in c("numeric", "integer", "logical")) { 401s + x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 401s + w <- runif(6, min = 0, max = 6) 401s + storage.mode(x) <- mode 401s + storage.mode(w) <- if (mode == "logical") "integer" else mode 401s + if (mode == "numeric") w[1] <- Inf 401s + 401s + # Test with and without dimnames on x 401s + for (setDimnames in c(TRUE, FALSE)) { 401s + if (setDimnames) dimnames(x) <- dimnames 401s + else dimnames(x) <- NULL 401s + 401s + count <- 0L 401s + for (rows in index_cases) { 401s + for (cols in index_cases) { 401s + count <- count + 1L 401s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 401s + useNames <- c(TRUE, FALSE) 401s + useNames <- useNames[count %% length(useNames) + 1] 401s + 401s + validateIndicesTestMatrix_w(x, w, rows, cols, 401s + ftest = rowWeightedMedians, 401s + fsure = rowWeightedMedians_R, 401s + na.rm = na.rm, useNames = useNames) 401s + validateIndicesTestMatrix_w(x, w, rows, cols, 401s + fcoltest = colWeightedMedians, 401s + fsure = rowWeightedMedians_R, 401s + na.rm = na.rm, useNames = useNames) 401s + } 401s + } 401s + } 401s + } 402s > 402s 402s R version 4.4.3 (2025-02-28) -- "Trophy Case" 402s Copyright (C) 2025 The R Foundation for Statistical Computing 402s Platform: aarch64-unknown-linux-gnu 402s 402s R is free software and comes with ABSOLUTELY NO WARRANTY. 402s You are welcome to redistribute it under certain conditions. 402s Type 'license()' or 'licence()' for distribution details. 402s 402s R is a collaborative project with many contributors. 402s Type 'contributors()' for more information and 402s 'citation()' on how to cite R or R packages in publications. 402s 402s Type 'demo()' for some demos, 'help()' for on-line help, or 402s 'help.start()' for an HTML browser interface to help. 402s Type 'q()' to quit R. 402s 403s > library("matrixStats") 403s > 403s > set.seed(1) 403s > 403s > x <- matrix(rnorm(20), nrow = 5L, ncol = 4L) 403s > print(x) 403s [,1] [,2] [,3] [,4] 403s [1,] -0.6264538 -0.8204684 1.5117812 -0.04493361 403s [2,] 0.1836433 0.4874291 0.3898432 -0.01619026 403s [3,] -0.8356286 0.7383247 -0.6212406 0.94383621 403s [4,] 1.5952808 0.5757814 -2.2146999 0.82122120 403s [5,] 0.3295078 -0.3053884 1.1249309 0.59390132 403s > 403s > # To check names attribute 403s > dimnames <- list(letters[1:5], LETTERS[1:4]) 403s > 403s > # Weighted row variances (uniform weights - all w = 1) 403s > # Non-weighted row variances 403s > x_est0 <- rowVars(x) 403s > w <- rep(1, times = ncol(x)) 403s > x_est1 <- rowWeightedVars(x, w = w) 403s > print(x_est1) 403s [1] 1.11767161 0.05022969 0.83582537 2.76819528 0.35351857 403s > stopifnot(all.equal(x_est1, x_est0)) 403s > x_est2 <- colWeightedVars(t(x), w = w) 403s > stopifnot(all.equal(x_est2, x_est0)) 403s > # Check names attribute 403s > dimnames(x) <- dimnames 403s > x_est1 <- rowWeightedVars(x, w = w, useNames = FALSE) 403s > x_est2 <- colWeightedVars(t(x), w = w, useNames = FALSE) 403s > stopifnot(all.equal(x_est1, x_est0)) 403s > stopifnot(all.equal(x_est2, x_est0)) 403s > x_est0 <- rowVars(x, useNames = TRUE) 403s > x_est1 <- rowWeightedVars(x, w = w, useNames = TRUE) 403s > x_est2 <- colWeightedVars(t(x), w = w, useNames = TRUE) 403s > stopifnot(all.equal(x_est1, x_est0)) 403s > stopifnot(all.equal(x_est2, x_est0)) 403s > dimnames(x) <- NULL 403s > 403s > 403s > # Weighted row variances (uniform weights - all w = 3) 403s > x3 <- cbind(x, x, x) 403s > x_est0 <- rowVars(x3) 403s > w <- rep(3, times = ncol(x)) 403s > x_est1 <- rowWeightedVars(x, w = w) 403s > print(x_est1) 403s [1] 0.91445859 0.04109702 0.68385712 2.26488705 0.28924246 403s > stopifnot(all.equal(x_est1, x_est0)) 403s > x_est2 <- colWeightedVars(t(x), w = w) 403s > stopifnot(all.equal(x_est2, x_est0)) 403s > # Check names attribute 403s > dimnames(x) <- dimnames 403s > x_est1 <- rowWeightedVars(x, w = w, useNames = FALSE) 403s > x_est2 <- colWeightedVars(t(x), w = w, useNames = FALSE) 403s > stopifnot(all.equal(x_est1, x_est0)) 403s > stopifnot(all.equal(x_est2, x_est0)) 403s > x3 <- cbind(x, x, x) 403s > x_est0 <- rowVars(x3, useNames = TRUE) 403s > x_est1 <- rowWeightedVars(x, w = w, useNames = TRUE) 403s > x_est2 <- colWeightedVars(t(x), w = w, useNames = TRUE) 403s > stopifnot(all.equal(x_est1, x_est0)) 403s > stopifnot(all.equal(x_est2, x_est0)) 403s > dimnames(x) <- NULL 403s > 403s > 403s > # Weighted row variances (excluding some columns) 403s > w <- c(1, 1, 0, 1) 403s > x_est0 <- rowVars(x[, (w == 1), drop = FALSE]) 403s > x_est1 <- rowWeightedVars(x, w = w) 403s > print(x_est1) 403s [1] 0.16287693 0.06430861 0.94767651 0.28313135 0.21361984 403s > stopifnot(all.equal(x_est1, x_est0)) 403s > x_est2 <- colWeightedVars(t(x), w = w) 403s > stopifnot(all.equal(x_est2, x_est0)) 403s > # Check names attribute 403s > dimnames(x) <- dimnames 403s > x_est1 <- rowWeightedVars(x, w = w, useNames = FALSE) 403s > x_est2 <- colWeightedVars(t(x), w = w, useNames = FALSE) 403s > stopifnot(all.equal(x_est1, x_est0)) 403s > stopifnot(all.equal(x_est2, x_est0)) 403s > x_est0 <- rowVars(x[, (w == 1), drop = FALSE], useNames = TRUE) 403s > x_est1 <- rowWeightedVars(x, w = w, useNames = TRUE) 403s > x_est2 <- colWeightedVars(t(x), w = w, useNames = TRUE) 403s > stopifnot(all.equal(x_est1, x_est0)) 403s > stopifnot(all.equal(x_est2, x_est0)) 403s > dimnames(x) <- NULL 403s > 403s > 403s > # Weighted row variances (excluding some columns) 403s > w <- c(0, 1, 0, 0) 403s > x_est0 <- rowVars(x[, (w == 1), drop = FALSE]) 403s > x_est1 <- rowWeightedVars(x, w = w) 403s > #stopifnot(all.equal(x_est1, x_est0)) 403s > x_est2 <- colWeightedVars(t(x), w = w) 403s > stopifnot(all.equal(x_est2, x_est1)) 403s > # Check names attribute 403s > dimnames(x) <- dimnames 403s > x_est1 <- rowWeightedVars(x, w = w, useNames = FALSE) 403s > x_est2 <- colWeightedVars(t(x), w = w, useNames = FALSE) 403s > stopifnot(all.equal(x_est1, x_est0)) 403s > stopifnot(all.equal(x_est2, x_est0)) 403s > x_est0 <- rowVars(x[, (w == 1), drop = FALSE], useNames = TRUE) 403s > x_est1 <- rowWeightedVars(x, w = w, useNames = TRUE) 403s > x_est2 <- colWeightedVars(t(x), w = w, useNames = TRUE) 403s > stopifnot(all.equal(x_est1, x_est0)) 403s > stopifnot(all.equal(x_est2, x_est0)) 403s > dimnames(x) <- NULL 403s > 403s > 403s > # Weighted row variances (all zero weights) 403s > w <- c(0, 0, 0, 0) 403s > x_est0 <- rowVars(x[, (w == 1), drop = FALSE]) 403s > x_est1 <- rowWeightedVars(x, w = w) 403s > stopifnot(all.equal(x_est1, x_est0)) 403s > x_est2 <- colWeightedVars(t(x), w = w) 403s > stopifnot(all.equal(x_est2, x_est0)) 403s > # Check names attribute 403s > dimnames(x) <- dimnames 403s > x_est1 <- rowWeightedVars(x, w = w, useNames = FALSE) 403s > x_est2 <- colWeightedVars(t(x), w = w, useNames = FALSE) 403s > stopifnot(all.equal(x_est1, x_est0)) 403s > stopifnot(all.equal(x_est2, x_est0)) 403s > x_est0 <- rowVars(x[, (w == 1), drop = FALSE], useNames = TRUE) 403s > x_est1 <- rowWeightedVars(x, w = w, useNames = TRUE) 403s > x_est2 <- colWeightedVars(t(x), w = w, useNames = TRUE) 403s > stopifnot(all.equal(x_est1, x_est0)) 403s > stopifnot(all.equal(x_est2, x_est0)) 403s > dimnames(x) <- NULL 403s > 403s > # Weighted variances by rows and columns 403s > w <- 1:4 403s > # Test with and without dimnames on x 403s > for (setDimnames in c(TRUE, FALSE)) { 403s + if (setDimnames) dimnames(x) <- dimnames 403s + else dimnames(x) <- NULL 403s + # Check names attribute 403s + for (useNames in c(TRUE, FALSE)) { 403s + x_est1 <- rowWeightedVars(x, w = w, useNames = useNames) 403s + print(x_est1) 403s + x_est2 <- colWeightedVars(t(x), w = w, useNames = useNames) 403s + stopifnot(all.equal(x_est2, x_est1)) 403s + } 403s + } 403s a b c d e 403s 0.90747094 0.05040463 0.65089440 2.28697479 0.27902734 403s [1] 0.90747094 0.05040463 0.65089440 2.28697479 0.27902734 403s [1] 0.90747094 0.05040463 0.65089440 2.28697479 0.27902734 403s [1] 0.90747094 0.05040463 0.65089440 2.28697479 0.27902734 403s > 403s > 403s > x[sample(length(x), size = 0.3 * length(x))] <- NA 403s > print(x) 403s [,1] [,2] [,3] [,4] 403s [1,] -0.6264538 NA 1.5117812 -0.04493361 403s [2,] 0.1836433 NA NA -0.01619026 403s [3,] -0.8356286 0.7383247 -0.6212406 0.94383621 403s [4,] 1.5952808 NA -2.2146999 0.82122120 403s [5,] 0.3295078 NA NA 0.59390132 403s > 403s > # Non-weighted row variances with missing values 403s > x_est0 <- rowVars(x, na.rm = TRUE) 403s > x_est1 <- rowWeightedVars(x, w = rep(1, times = ncol(x)), na.rm = TRUE) 403s > print(x_est1) 403s [1] 1.22226258 0.01996673 0.83582537 4.05532299 0.03495197 403s > stopifnot(all.equal(x_est1, x_est0)) 403s > x_est2 <- colWeightedVars(t(x), w = rep(1, times = ncol(x)), na.rm = TRUE) 403s > stopifnot(all.equal(x_est2, x_est0)) 403s > # Check names attribute 403s > dimnames(x) <- dimnames 403s > x_est1 <- rowWeightedVars(x, w = rep(1, times = ncol(x)), na.rm = TRUE, useNames = FALSE) 403s > x_est2 <- colWeightedVars(t(x), w = rep(1, times = ncol(x)), na.rm = TRUE, useNames = FALSE) 403s > stopifnot(all.equal(x_est1, x_est0)) 403s > stopifnot(all.equal(x_est2, x_est0)) 403s > x_est0 <- rowVars(x, na.rm = TRUE, useNames = TRUE) 403s > x_est1 <- rowWeightedVars(x, w = rep(1, times = ncol(x)), na.rm = TRUE, useNames = TRUE) 403s > x_est2 <- colWeightedVars(t(x), w = rep(1, times = ncol(x)), na.rm = TRUE, useNames = TRUE) 403s > stopifnot(all.equal(x_est1, x_est0)) 403s > stopifnot(all.equal(x_est2, x_est0)) 403s > dimnames(x) <- NULL 403s > 403s > 403s > # Weighted row variances with missing values 403s > # Test with and without dimnames on x 403s > for (setDimnames in c(TRUE, FALSE)) { 403s + if (setDimnames) dimnames(x) <- dimnames 403s + else dimnames(x) <- NULL 403s + # Check names attribute 403s + for (useNames in c(TRUE, FALSE)) { 403s + x_est1 <- rowWeightedVars(x, w = w, na.rm = TRUE, useNames = useNames) 403s + print(x_est1) 403s + x_est2 <- colWeightedVars(t(x), w = w, na.rm = TRUE, useNames = useNames) 403s + stopifnot(all.equal(x_est2, x_est1)) 403s + } 403s + } 403s a b c d e 403s 0.788377504 0.007986693 0.650894398 2.795470241 0.013980790 403s [1] 0.788377504 0.007986693 0.650894398 2.795470241 0.013980790 403s [1] 0.788377504 0.007986693 0.650894398 2.795470241 0.013980790 403s [1] 0.788377504 0.007986693 0.650894398 2.795470241 0.013980790 403s > 403s > 403s > # Weighted variances by rows and columns 403s > w <- 1:4 403s > # Test with and without dimnames on x 403s > for (setDimnames in c(TRUE, FALSE)) { 403s + if (setDimnames) dimnames(x) <- dimnames 403s + else dimnames(x) <- NULL 403s + # Check names attribute 403s + for (useNames in c(TRUE, FALSE)) { 403s + x_est1 <- rowWeightedVars(x, w = w, na.rm = TRUE, useNames = useNames) 403s + print(x_est1) 403s + x_est2 <- colWeightedVars(t(x), w = w, na.rm = TRUE, useNames = useNames) 403s + stopifnot(all.equal(x_est2, x_est1)) 403s + } 403s + } 403s a b c d e 403s 0.788377504 0.007986693 0.650894398 2.795470241 0.013980790 403s [1] 0.788377504 0.007986693 0.650894398 2.795470241 0.013980790 403s [1] 0.788377504 0.007986693 0.650894398 2.795470241 0.013980790 403s [1] 0.788377504 0.007986693 0.650894398 2.795470241 0.013980790 403s > 403s > 403s > # Weighted row standard deviation (excluding some columns) 403s > w <- c(1, 1, 0, 1) 403s > ## FIXME: rowVars()/rowSds() needs na.rm = FALSE (wrong default) 403s > x_est0 <- rowSds(x[, (w == 1), drop = FALSE], na.rm = FALSE) 403s > x_est1 <- rowWeightedSds(x, w = w) 403s > print(x_est1) 403s [1] NA NA 0.9734868 NA NA 403s > stopifnot(all.equal(x_est1, x_est0)) 403s > x_est2 <- colWeightedSds(t(x), w = w, na.rm = FALSE) 403s > stopifnot(all.equal(x_est2, x_est0)) 403s > # Check names attribute 403s > dimnames(x) <- dimnames 403s > x_est1 <- rowWeightedSds(x, w = w, na.rm = FALSE, useNames = FALSE) 403s > x_est2 <- colWeightedSds(t(x), w = w, na.rm = FALSE, useNames = FALSE) 403s > stopifnot(all.equal(x_est1, x_est0)) 403s > stopifnot(all.equal(x_est2, x_est0)) 403s > x_est0 <- rowSds(x[, (w == 1), drop = FALSE], na.rm = FALSE, useNames = TRUE) 403s > x_est1 <- rowWeightedSds(x, w = w, na.rm = FALSE, useNames = TRUE) 403s > x_est2 <- colWeightedSds(t(x), w = w, na.rm = FALSE, useNames = TRUE) 403s > stopifnot(all.equal(x_est1, x_est0)) 403s > stopifnot(all.equal(x_est2, x_est0)) 403s > dimnames(x) <- NULL 403s > 403s > 403s > # Weighted row MADs (excluding some columns) 403s > w <- c(1, 1, 0, 1) 403s > x_est0 <- rowMads(x[, (w == 1), drop = FALSE]) 403s > x_est1 <- rowWeightedMads(x, w = w) 403s > print(x_est1) 403s [1] NA NA 0.3046914 NA NA 403s > stopifnot(all.equal(x_est1, x_est0)) 403s > x_est2 <- colWeightedMads(t(x), w = w) 403s > stopifnot(all.equal(x_est2, x_est0)) 403s > # Check names attribute 403s > dimnames(x) <- dimnames 403s > x_est1 <- rowWeightedMads(x, w = w, useNames = FALSE) 403s > x_est2 <- colWeightedMads(t(x), w = w, useNames = FALSE) 403s > stopifnot(all.equal(x_est1, x_est0)) 403s > stopifnot(all.equal(x_est2, x_est0)) 403s > x_est0 <- rowMads(x[, (w == 1), drop = FALSE], useNames = TRUE) 403s > x_est1 <- rowWeightedMads(x, w = w, useNames = TRUE) 403s > x_est2 <- colWeightedMads(t(x), w = w, useNames = TRUE) 403s > stopifnot(all.equal(x_est1, x_est0)) 403s > stopifnot(all.equal(x_est2, x_est0)) 403s > dimnames(x) <- NULL 403s > 403s 403s R version 4.4.3 (2025-02-28) -- "Trophy Case" 403s Copyright (C) 2025 The R Foundation for Statistical Computing 403s Platform: aarch64-unknown-linux-gnu 403s 403s R is free software and comes with ABSOLUTELY NO WARRANTY. 403s You are welcome to redistribute it under certain conditions. 403s Type 'license()' or 'licence()' for distribution details. 403s 403s R is a collaborative project with many contributors. 403s Type 'contributors()' for more information and 403s 'citation()' on how to cite R or R packages in publications. 403s 403s Type 'demo()' for some demos, 'help()' for on-line help, or 403s 'help.start()' for an HTML browser interface to help. 403s Type 'q()' to quit R. 403s 403s > library("matrixStats") 403s > 403s > fcns <- list( 403s + weightedVar = c(rowWeightedVars, colWeightedVars), 403s + weightedSd = c(rowWeightedSds, colWeightedSds), 403s + weightedMad = c(rowWeightedMads, colWeightedMads) 403s + ) 403s > 403s > 403s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 403s > # Subsetted tests 403s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 403s > source("utils/validateIndicesFramework.R") 403s > # To check names attribute 403s > dimnames <- list(letters[1:6], LETTERS[1:6]) 403s > for (fcn in names(fcns)) { 403s + cat(sprintf("subsetted tests on matrix %s()...\n", fcn)) 403s + row_fcn <- fcns[[fcn]][[1]] 403s + col_fcn <- fcns[[fcn]][[2]] 403s + 403s + for (mode in c("numeric", "integer")) { 403s + x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 403s + w <- runif(6, min = 0, max = 6) 403s + storage.mode(x) <- mode 403s + storage.mode(w) <- mode 403s + if (mode == "numeric") w[1] <- Inf 403s + 403s + # Test with and without dimnames on x 403s + for (setDimnames in c(TRUE, FALSE)) { 403s + if (setDimnames) dimnames(x) <- dimnames 403s + else dimnames(x) <- NULL 403s + 403s + count <- 0L 403s + for (rows in index_cases) { 403s + for (cols in index_cases) { 403s + count <- count + 1L 403s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 403s + useNames <- c(TRUE, FALSE) 403s + useNames <- useNames[count %% length(useNames) + 1] 403s + 403s + validateIndicesTestMatrix_w(x, w, rows, cols, 403s + ftest = row_fcn, fsure = row_fcn, 403s + na.rm = na.rm, useNames = useNames) 403s + validateIndicesTestMatrix_w(x, w, rows, cols, 403s + fcoltest = col_fcn, fsure = row_fcn, 403s + na.rm = na.rm, useNames = useNames) 403s + } 403s + } 403s + } 403s + } 403s + cat(sprintf("%s()...DONE\n", fcn)) 403s + } 403s subsetted tests on matrix weightedVar()... 404s weightedVar()...DONE 404s subsetted tests on matrix weightedSd()... 404s weightedSd()...DONE 404s subsetted tests on matrix weightedMad()... 405s weightedMad()...DONE 405s > 405s 405s R version 4.4.3 (2025-02-28) -- "Trophy Case" 405s Copyright (C) 2025 The R Foundation for Statistical Computing 405s Platform: aarch64-unknown-linux-gnu 405s 405s R is free software and comes with ABSOLUTELY NO WARRANTY. 405s You are welcome to redistribute it under certain conditions. 405s Type 'license()' or 'licence()' for distribution details. 405s 405s R is a collaborative project with many contributors. 405s Type 'contributors()' for more information and 405s 'citation()' on how to cite R or R packages in publications. 405s 405s Type 'demo()' for some demos, 'help()' for on-line help, or 405s 'help.start()' for an HTML browser interface to help. 405s Type 'q()' to quit R. 405s 405s > library("matrixStats") 405s > 405s > signTabulate0 <- function(x, ...) { 405s + nneg <- sum(x < 0, na.rm = TRUE) 405s + nzero <- sum(x == 0, na.rm = TRUE) 405s + npos <- sum(x > 0, na.rm = TRUE) 405s + nna <- sum(is.na(x)) 405s + nneginf <- sum(is.infinite(x) & x < 0, na.rm = TRUE) 405s + nposinf <- sum(is.infinite(x) & x > 0, na.rm = TRUE) 405s + res <- c(nneg, nzero, npos, nna, nneginf, nposinf) 405s + res <- as.double(res) 405s + names(res) <- c("-1", "0", "+1", "NA", "-Inf", "+Inf") 405s + if (is.integer(x)) res <- res[1:4] 405s + res 405s + } # signTabulate0() 405s > 405s > 405s > # Simulate data 405s > set.seed(0xBEEF) 405s > n <- 100L 405s > x <- runif(n) 405s > x[sample(n, size = 0.1 * n)] <- 0 405s > x[sample(n, size = 0.1 * n)] <- NA_real_ 405s > x[sample(n, size = 0.1 * n)] <- -Inf 405s > x[sample(n, size = 0.1 * n)] <- +Inf 405s > 405s > # Doubles 405s > message("Doubles:") 405s > counts0 <- signTabulate0(x) 405s > print(counts0) 405s -1 0 +1 NA -Inf +Inf 405s 9 7 77 7 9 10 405s > counts1 <- signTabulate(x) 405s > print(counts1) 405s -1 0 +1 NA -Inf +Inf 405s 9 7 77 7 9 10 405s > stopifnot(identical(counts1, counts0)) 405s > 405s > # Integers 405s > message("Integers:") 405s > x <- suppressWarnings(as.integer(x)) 405s > counts0 <- signTabulate0(x) 405s > print(counts0) 405s -1 0 +1 NA 405s 0 74 0 26 405s > counts1 <- signTabulate(x) 405s > print(counts1) 405s -1 0 +1 NA 405s 0 74 0 26 405s > stopifnot(identical(counts1, counts0)) 405s > 405s Doubles: 405s Integers: 405s 405s R version 4.4.3 (2025-02-28) -- "Trophy Case" 405s Copyright (C) 2025 The R Foundation for Statistical Computing 405s Platform: aarch64-unknown-linux-gnu 405s 405s R is free software and comes with ABSOLUTELY NO WARRANTY. 405s You are welcome to redistribute it under certain conditions. 405s Type 'license()' or 'licence()' for distribution details. 405s 405s R is a collaborative project with many contributors. 405s Type 'contributors()' for more information and 405s 'citation()' on how to cite R or R packages in publications. 405s 405s Type 'demo()' for some demos, 'help()' for on-line help, or 405s 'help.start()' for an HTML browser interface to help. 405s Type 'q()' to quit R. 405s 405s > library("matrixStats") 405s > 405s > signTabulate0 <- function(x, ...) { 405s + nneg <- sum(x < 0, na.rm = TRUE) 405s + nzero <- sum(x == 0, na.rm = TRUE) 405s + npos <- sum(x > 0, na.rm = TRUE) 405s + nna <- sum(is.na(x)) 405s + nneginf <- sum(is.infinite(x) & x < 0, na.rm = TRUE) 405s + nposinf <- sum(is.infinite(x) & x > 0, na.rm = TRUE) 405s + res <- c(nneg, nzero, npos, nna, nneginf, nposinf) 405s + res <- as.double(res) 405s + names(res) <- c("-1", "0", "+1", "NA", "-Inf", "+Inf") 405s + if (is.integer(x)) res <- res[1:4] 405s + res 405s + } # signTabulate0() 405s > 405s > 405s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 405s > # Subsetted tests 405s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 405s > source("utils/validateIndicesFramework.R") 405s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 405s > x[2:3, 4:5] <- +Inf 405s > x[4:5, 1:2] <- -Inf 405s > for (idxs in index_cases) { 405s + validateIndicesTestVector(x, idxs, 405s + ftest = signTabulate, fsure = signTabulate0) 405s + } 406s > 406s 406s R version 4.4.3 (2025-02-28) -- "Trophy Case" 406s Copyright (C) 2025 The R Foundation for Statistical Computing 406s Platform: aarch64-unknown-linux-gnu 406s 406s R is free software and comes with ABSOLUTELY NO WARRANTY. 406s You are welcome to redistribute it under certain conditions. 406s Type 'license()' or 'licence()' for distribution details. 406s 406s R is a collaborative project with many contributors. 406s Type 'contributors()' for more information and 406s 'citation()' on how to cite R or R packages in publications. 406s 406s Type 'demo()' for some demos, 'help()' for on-line help, or 406s 'help.start()' for an HTML browser interface to help. 406s Type 'q()' to quit R. 406s 406s > library("matrixStats") 406s > options(warn = 1) 406s > 406s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 406s > # Consistency checks 406s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 406s > set.seed(1) 406s > 406s > sum2_R <- function(x, na.rm = FALSE, idxs = NULL) { 406s + if (is.null(idxs)) { 406s + sum(x, na.rm = na.rm) 406s + } else { 406s + sum(x[idxs], na.rm = na.rm) 406s + } 406s + } # sum2_R() 406s > 406s > 406s > cat("Consistency checks:\n") 406s Consistency checks: 406s > for (kk in 1:20) { 406s + cat("Random test #", kk, "\n", sep = "") 406s + 406s + # Simulate data in a matrix of any shape 406s + n <- sample(1e3, size = 1L) 406s + x <- rnorm(n, sd = 100) 406s + 406s + # Add NAs? 406s + if ((kk %% 4) %in% c(3, 0)) { 406s + cat("Adding NAs\n") 406s + nna <- sample(n, size = 1L) 406s + na_values <- c(NA_real_, NaN) 406s + t <- sample(na_values, size = nna, replace = TRUE) 406s + x[sample(length(x), size = nna)] <- t 406s + } 406s + 406s + # Integer or double? 406s + if ((kk %% 4) %in% c(2, 0)) { 406s + cat("Coercing to integers\n") 406s + storage.mode(x) <- "integer" 406s + } 406s + 406s + na.rm <- sample(c(TRUE, FALSE), size = 1L) 406s + 406s + # Sum over all 406s + y0 <- sum2_R(x, na.rm = na.rm) 406s + y1 <- sum2(x, na.rm = na.rm) 406s + stopifnot(all.equal(y1, y0)) 406s + 406s + # Sum over subset 406s + nidxs <- sample(n, size = 1L) 406s + idxs <- sample(n, size = nidxs) 406s + y0 <- sum2_R(x, na.rm = na.rm, idxs = idxs) 406s + y1 <- sum2(x, na.rm = na.rm, idxs = idxs) 406s + stopifnot(all.equal(y1, y0)) 406s + 406s + if (storage.mode(x) == "integer") { 406s + storage.mode(x) <- "logical" 406s + 406s + y0 <- sum2_R(x, na.rm = na.rm) 406s + y1 <- sum2(x, na.rm = na.rm) 406s + stopifnot(all.equal(y1, y0)) 406s + 406s + y0 <- sum2_R(x, na.rm = na.rm, idxs = idxs) 406s + y1 <- sum2(x, na.rm = na.rm, idxs = idxs) 406s + stopifnot(all.equal(y1, y0)) 406s + } 406s + } # for (kk ...) 406s Random test #1 406s Random test #2 406s Coercing to integers 406s Random test #3 406s Adding NAs 406s Random test #4 406s Adding NAs 406s Coercing to integers 406s Random test #5 406s Random test #6 406s Coercing to integers 406s Random test #7 406s Adding NAs 406s Random test #8 406s Adding NAs 406s Coercing to integers 406s Random test #9 406s Random test #10 406s Coercing to integers 406s Random test #11 406s Adding NAs 406s Random test #12 406s Adding NAs 406s Coercing to integers 406s Random test #13 406s Random test #14 406s Coercing to integers 406s Random test #15 406s Adding NAs 406s Random test #16 406s Adding NAs 406s Coercing to integers 406s Random test #17 406s Random test #18 406s Coercing to integers 406s Random test #19 406s Adding NAs 406s Random test #20 406s Adding NAs 406s Coercing to integers 406s > 406s > 406s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 406s > # All missing values 406s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 406s > for (n in 0:2) { 406s + for (na.rm in c(FALSE, TRUE)) { 406s + x <- rep(NA_real_, times = n) 406s + y0 <- sum(x, na.rm = na.rm) 406s + y <- sum2(x, na.rm = na.rm) 406s + stopifnot(all.equal(y, y0)) 406s + 406s + x <- rep(NA_integer_, times = n) 406s + y0 <- sum(x, na.rm = na.rm) 406s + y <- sum2(x, na.rm = na.rm) 406s + stopifnot(all.equal(y, y0)) 406s + 406s + x <- rep(NA, times = n) 406s + y0 <- sum(x, na.rm = na.rm) 406s + y <- sum2(x, na.rm = na.rm) 406s + stopifnot(all.equal(y, y0)) 406s + } 406s + } 406s > 406s > 406s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 406s > # Special cases 406s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 406s > for (na.rm in c(FALSE, TRUE)) { 406s + # Summing over zero elements (integers) 406s + x <- integer(0) 406s + s1 <- sum(x, na.rm = na.rm) 406s + s2 <- sum2(x, na.rm = na.rm) 406s + stopifnot(identical(s1, s2)) 406s + 406s + x <- 1:10 406s + idxs <- integer(0) 406s + s1 <- sum(x[idxs], na.rm = na.rm) 406s + s2 <- sum2(x, idxs = idxs, na.rm = na.rm) 406s + stopifnot(identical(s1, s2)) 406s + 406s + # Summing over NA_integer_:s 406s + x <- rep(NA_integer_, times = 10L) 406s + s1 <- sum(x, na.rm = na.rm) 406s + s2 <- sum2(x, na.rm = na.rm) 406s + stopifnot(identical(s1, s2)) 406s + 406s + x <- rep(NA_integer_, times = 10L) 406s + idxs <- 1:5 406s + s1 <- sum(x[idxs], na.rm = na.rm) 406s + s2 <- sum2(x, idxs = idxs, na.rm = na.rm) 406s + stopifnot(identical(s1, s2)) 406s + 406s + 406s + # Summing over zero elements (doubles) 406s + x <- double(0) 406s + s1 <- sum(x) 406s + s2 <- sum2(x) 406s + stopifnot( 406s + identical(s1, 0), 406s + identical(s1, s2) 406s + ) 406s + 406s + x <- as.double(1:10) 406s + idxs <- integer(0) 406s + s1 <- sum(x[idxs]) 406s + s2 <- sum2(x, idxs = idxs) 406s + stopifnot( 406s + identical(s1, 0), 406s + identical(s1, s2) 406s + ) 406s + 406s + # Summing over NA_real_:s 406s + x <- rep(NA_real_, times = 10L) 406s + s1 <- sum(x, na.rm = na.rm) 406s + s2 <- sum2(x, na.rm = na.rm) 406s + stopifnot( 406s + !na.rm || s1 == 0, 406s + identical(s1, s2) 406s + ) 406s + 406s + x <- rep(NA_real_, times = 10L) 406s + idxs <- 1:5 406s + s1 <- sum(x[idxs], na.rm = na.rm) 406s + s2 <- sum2(x, idxs = idxs, na.rm = na.rm) 406s + stopifnot( 406s + !na.rm || s1 == 0, 406s + identical(s1, s2) 406s + ) 406s + 406s + # Summing over -Inf:s 406s + x <- rep(-Inf, times = 3L) 406s + s1 <- sum(x, na.rm = na.rm) 406s + s2 <- sum2(x, na.rm = na.rm) 406s + stopifnot( 406s + is.infinite(s1) && s1 < 0, 406s + identical(s1, s2) 406s + ) 406s + 406s + # Summing over +Inf:s 406s + x <- rep(+Inf, times = 3L) 406s + s1 <- sum(x, na.rm = na.rm) 406s + s2 <- sum2(x, na.rm = na.rm) 406s + stopifnot(identical(s1, s2)) 406s + stopifnot( 406s + is.infinite(s1) && s1 > 0, 406s + identical(s1, s2) 406s + ) 406s + 406s + # Summing over mix of -Inf:s and +Inf:s 406s + x <- rep(c(-Inf, +Inf), times = 3L) 406s + s1 <- sum(x, na.rm = na.rm) 406s + s2 <- sum2(x, na.rm = na.rm) 406s + stopifnot( 406s + is.nan(s1), 406s + identical(s1, s2) 406s + ) 406s + 406s + # Summing over mix of -Inf:s and +Inf:s and numerics 406s + x <- rep(c(-Inf, +Inf, 3.14), times = 2L) 406s + s1 <- sum(x, na.rm = na.rm) 406s + s2 <- sum2(x, na.rm = na.rm) 406s + stopifnot( 406s + is.nan(s1), 406s + identical(s1, s2) 406s + ) 406s + 406s + # Summing over mix of NaN, NA, +Inf, and numerics 406s + x <- c(NaN, NA, +Inf, 3.14) 406s + s1 <- sum(x, na.rm = na.rm) 406s + s2 <- sum2(x, na.rm = na.rm) 406s + if (na.rm) { 406s + stopifnot( 406s + is.infinite(s1) && s1 > 0, 406s + identical(s2, s1) 406s + ) 406s + } else { 406s + stopifnot(is.na(s1), is.na(s2)) 406s + ## NOTE, due to compiler optimization, it is not guaranteed that NA is 406s + ## returned here (as one would expect). NaN might very well be returned, 406s + ## when both NA and NaN are involved. This is an accepted feature in R, 406s + ## which is documented in help("is.nan"). See also 406s + ## https://stat.ethz.ch/pipermail/r-devel/2017-April/074009.html. 406s + ## Thus, we cannot guarantee that s1 is identical to s0. 406s + } 406s + 406s + # Summing over mix of NaN, NA, +Inf, and numerics 406s + x <- c(NA, NaN, +Inf, 3.14) 406s + s1 <- sum(x, na.rm = na.rm) 406s + s2 <- sum2(x, na.rm = na.rm) 406s + if (na.rm) { 406s + stopifnot( 406s + is.infinite(s1) && s1 > 0, 406s + identical(s2, s1) 406s + ) 406s + } else { 406s + stopifnot(is.na(s1), is.na(s2)) 406s + ## NOTE, due to compiler optimization, it is not guaranteed that NA is 406s + ## returned here (as one would expect). NaN might very well be returned, 406s + ## when both NA and NaN are involved. This is an accepted feature in R, 406s + ## which is documented in help("is.nan"). See also 406s + ## https://stat.ethz.ch/pipermail/r-devel/2017-April/074009.html. 406s + ## Thus, we cannot guarantee that s1 is identical to s0. 406s + } 406s + } 406s > 406s > 406s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 406s > # Summing of large integers 406s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 406s > x <- c(.Machine$integer.max, 1L, -.Machine$integer.max) 406s > 406s > # Total gives integer overflow 406s > s1 <- sum(x[1:2]) # NA_integer_ w/ warning 406s > s2 <- sum2(x[1:2]) # NA_integer_ w/ warning 406s Warning in sum2(x[1:2]) :> stopifnot( 406s + identical(s2, NA_integer_) 406s + ) 406s > 406s > ## Assert above warning 406s > res <- tryCatch({ 406s + s2 <- sum2(x[1:2]) 406s + }, warning = identity) 406s > stopifnot(inherits(res, "warning")) 406s 406s Integer overflow. Use sum2(..., mode = "double") to avoid this. 406s Warning in sum2(x, mode = "integer") : 406s sum2(x, mode = "integer") called with typeof(x) == "double"; did you mean to use as.integer(sum2(x))? 406s > 406s > 406s > # Total gives integer overflow (coerce to numeric) 406s > s1 <- sum(as.numeric(x[1:2])) # 2147483648 406s > s2 <- sum2(as.numeric(x[1:2])) # 2147483648 406s > s3 <- sum2(x[1:2], mode = "double") # 2147483648 406s > stopifnot( 406s + identical(s1, 2147483648), 406s + identical(s1, s2), 406s + identical(s1, s3) 406s + ) 406s > 406s > # Cumulative sum would give integer overflow but not the total 406s > s1 <- sum(x) # 1L 406s > s2 <- sum2(x) # 1L 406s > stopifnot( 406s + identical(s1, 1L), 406s + identical(s1, s2) 406s + ) 406s > 406s > # Input is double but coercing result to integer 406s > x <- c(1, 2, 3.1) 406s > s1 <- sum2(x) 406s > s2 <- sum2(x, mode = "integer") 406s > stopifnot( 406s + identical(as.integer(s1), s2) 406s + ) 406s > 406s > ## Assert above warning 406s > res <- tryCatch({ 406s + s2 <- sum2(x, mode = "integer") 406s + }, warning = identity) 406s > stopifnot(inherits(res, "warning")) 406s > 406s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 406s > # Summing of large doubles 406s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 406s > ## Double overflow 406s > x <- rep(.Machine$double.xmax, times = 2L) 406s > y0 <- sum(x) 406s > print(y0) 406s [1] Inf 406s > y <- sum2(x) 406s > print(y) 406s [1] Inf 406s > stopifnot( 406s + is.infinite(y) && y > 0, 406s + identical(y, y0) 406s + ) 406s > 406s > x <- rep(-.Machine$double.xmax, times = 2L) 406s > y0 <- sum(x) 406s > print(y0) 406s [1] -Inf 406s > y <- sum2(x) 406s > print(y) 406s [1] -Inf 406s > stopifnot( 406s + is.infinite(y) && y < 0, 406s + identical(y, y0) 406s + ) 406s > 406s > 406s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 406s > # Argument 'idxs' 406s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 406s > x <- 1:10 406s > idxs_list <- list( 406s + integer = 1:5, 406s + double = as.double(1:5), 406s + logical = (x <= 5) 406s + ) 406s > 406s > for (idxs in idxs_list) { 406s + cat("idxs:\n") 406s + str(idxs) 406s + s1 <- sum(x[idxs], na.rm = TRUE) 406s + s2 <- sum2(x, idxs = idxs, na.rm = TRUE) 406s + stopifnot(identical(s1, s2)) 406s + } 406s idxs: 406s int [1:5] 1 2 3 4 5 406s idxs: 406s num [1:5] 1 2 3 4 5 406s idxs: 406s logi [1:10] TRUE TRUE TRUE TRUE TRUE FALSE ... 406s > 406s 406s R version 4.4.3 (2025-02-28) -- "Trophy Case" 406s Copyright (C) 2025 The R Foundation for Statistical Computing 406s Platform: aarch64-unknown-linux-gnu 406s 406s R is free software and comes with ABSOLUTELY NO WARRANTY. 406s You are welcome to redistribute it under certain conditions. 406s Type 'license()' or 'licence()' for distribution details. 406s 406s R is a collaborative project with many contributors. 406s Type 'contributors()' for more information and 406s 'citation()' on how to cite R or R packages in publications. 406s 406s Type 'demo()' for some demos, 'help()' for on-line help, or 406s 'help.start()' for an HTML browser interface to help. 406s Type 'q()' to quit R. 406s 406s > library("matrixStats") 406s > 406s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 406s > # Subsetted tests 406s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 406s > source("utils/validateIndicesFramework.R") 406s > x <- runif(6, min = -6, max = 6) 406s > storage.mode(x) <- "integer" 406s > for (idxs in index_cases) { 406s + validateIndicesTestVector(x, idxs, 406s + ftest = sum2, fsure = sum, 406s + na.rm = FALSE) 406s + validateIndicesTestVector(x, idxs, 406s + ftest = sum2, fsure = sum, 406s + na.rm = TRUE) 406s + } 406s > 406s 406s R version 4.4.3 (2025-02-28) -- "Trophy Case" 406s Copyright (C) 2025 The R Foundation for Statistical Computing 406s Platform: aarch64-unknown-linux-gnu 406s 406s R is free software and comes with ABSOLUTELY NO WARRANTY. 406s You are welcome to redistribute it under certain conditions. 406s Type 'license()' or 'licence()' for distribution details. 406s 406s R is a collaborative project with many contributors. 406s Type 'contributors()' for more information and 406s 'citation()' on how to cite R or R packages in publications. 406s 406s Type 'demo()' for some demos, 'help()' for on-line help, or 406s 'help.start()' for an HTML browser interface to help. 406s Type 'q()' to quit R. 406s 406s > library("matrixStats") 406s > 406s > set.seed(1) 406s > x <- rnorm(1e4) 406s > 406s > 406s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 406s > # Variance estimators 406s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 406s > sigma2_a <- var(x) 406s > cat(sprintf("var(x) = %g\n", sigma2_a)) 406s var(x) = 1.02487 406s > 406s > sigma2_b <- varDiff(x) 406s > cat(sprintf("varDiff(x) = %g\n", sigma2_b)) 406s varDiff(x) = 1.01224 406s > 406s > d <- abs(sigma2_b - sigma2_a) 406s > cat(sprintf("Absolute difference = %g\n", d)) 406s Absolute difference = 0.0126268 406s > stopifnot(d < 0.02) 406s > 406s > 406s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 406s > # Standard deviation estimators 406s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 406s > sigma_a <- sd(x) 406s > cat(sprintf("sd(x) = %g\n", sigma_a)) 406s sd(x) = 1.01236 406s > 406s > sigma_b <- sdDiff(x) 406s > cat(sprintf("sdDiff(x) = %g\n", sigma_b)) 406s sdDiff(x) = 1.0061 406s > 406s > d <- abs(sigma_b - sigma_a) 406s > cat(sprintf("Absolute difference = %g\n", d)) 406s Absolute difference = 0.00625567 406s > stopifnot(d < 0.01) 406s > 406s > # Sanity checks 406s > stopifnot(abs(sigma2_a - sigma_a ^ 2) < 1e-9) 406s > stopifnot(abs(sigma2_b - sigma_b ^ 2) < 1e-9) 406s > 406s > 406s > sigma_a2 <- mad(x) 406s > cat(sprintf("mad(x) = %g\n", sigma_a2)) 406s mad(x) = 0.998376 406s > 406s > sigma_b2 <- madDiff(x) 406s > cat(sprintf("madDiff(x) = %g\n", sigma_b2)) 406s madDiff(x) = 1.02513 406s > 406s > d <- abs(sigma_b2 - sigma_a2) 406s > cat(sprintf("Absolute difference = %g\n", d)) 406s Absolute difference = 0.0267497 406s > stopifnot(d < 0.05) 406s > 406s > 406s > sigma_a3 <- IQR(x) 406s > cat(sprintf("IQR(x) = %g\n", sigma_a3)) 406s IQR(x) = 1.35105 406s > 406s > sigma_b3 <- iqrDiff(x) 406s > cat(sprintf("iqrDiff(x) = %g\n", sigma_b3)) 406s iqrDiff(x) = 1.37797 406s > 406s > d <- abs(sigma_b3 - sigma_a3) 406s > cat(sprintf("Absolute difference = %g\n", d)) 406s Absolute difference = 0.0269152 406s > stopifnot(d < 0.05) 406s > 406s > 406s > 406s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 406s > # Trimmed estimators 406s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 406s > y <- x 406s > outliers <- sample(length(x), size = 0.1 * length(x)) 406s > y[outliers] <- 100 * y[outliers] 406s > 406s > sigma_ao <- sd(y[-outliers]) 406s > cat(sprintf("sd(y) = %g\n", sigma_ao)) 406s sd(y) = 1.01166 406s > 406s > sigma_bo <- sdDiff(y[-outliers]) 406s > cat(sprintf("sdDiff(y) = %g\n", sigma_bo)) 406s sdDiff(y) = 1.00743 406s > 406s > d <- abs(sigma_b - sigma_a) 406s > cat(sprintf("Absolute difference = %g\n", d)) 406s Absolute difference = 0.00625567 406s > stopifnot(d < 0.01) 406s > 406s > sigma_bot <- sdDiff(y, trim = 0.05) 406s > cat(sprintf("sdDiff(y, trim = 0.05) = %g\n", sigma_bot)) 406s sdDiff(y, trim = 0.05) = 7.74327 406s > 406s > d <- abs(sigma_bot - sigma_a) 406s > cat(sprintf("Absolute difference = %g\n", d)) 406s Absolute difference = 6.73091 406s > #stopifnot(d < 1e-3) 406s > 406s > sigma_cot <- madDiff(y, trim = 0.05) 406s > cat(sprintf("madDiff(y, trim = 0.05) = %g\n", sigma_cot)) 406s madDiff(y, trim = 0.05) = 1.15278 406s > 406s > sigma_dot <- iqrDiff(y, trim = 0.05) 406s > cat(sprintf("iqrDiff(y, trim = 0.05) = %g\n", sigma_dot)) 406s iqrDiff(y, trim = 0.05) = 1.55762 406s > 406s > 406s > fcns <- list( 406s + varDiff = varDiff, 406s + sdDiff = sdDiff, 406s + madDiff = madDiff, 406s + iqrDiff = iqrDiff 406s + ) 406s > 406s > for (name in names(fcns)) { 406s + cat(sprintf("%s()...\n", name)) 406s + fcn <- fcns[[name]] 406s + 406s + for (mode in c("integer", "double")) { 406s + cat("mode: ", mode, "", sep = "") 406s + for (n in 0:3) { 406s + x <- runif(n, min = -5, max = 5) 406s + storage.mode(x) <- mode 406s + str(x) 406s + 406s + y <- fcn(x) 406s + yt <- fcn(x, trim = 0.1) 406s + str(list("non-trimmed" = y, trimmed = yt)) 406s + } # for (mode ...) 406s + } 406s + 406s + cat(sprintf("%s()...DONE\n", name)) 406s + } # for (name ...) 406s varDiff()... 406s mode: integer int(0) 406s List of 2 406s $ non-trimmed: num NA 406s $ trimmed : num NA 406s int -4 406s List of 2 406s $ non-trimmed: num NA 406s $ trimmed : num NA 406s int [1:2] 3 2 406s List of 2 406s $ non-trimmed: num NA 406s $ trimmed : num NA 406s int [1:3] 1 4 -1 406s List of 2 406s $ non-trimmed: num 16 406s $ trimmed : num 16 406s mode: double num(0) 406s List of 2 406s $ non-trimmed: num NA 406s $ trimmed : num NA 406s num -0.794 406s List of 2 406s $ non-trimmed: num NA 406s $ trimmed : num NA 406s num [1:2] 0.897 -3.728 406s List of 2 406s $ non-trimmed: num NA 406s $ trimmed : num NA 406s num [1:3] 2.07 -1.13 1.94 406s List of 2 406s $ non-trimmed: num 9.83 406s $ trimmed : num 9.83 406s varDiff()...DONE 406s sdDiff()... 406s mode: integer int(0) 406s List of 2 406s $ non-trimmed: num NA 406s $ trimmed : num NA 406s int 2 406s List of 2 406s $ non-trimmed: num NA 406s $ trimmed : num NA 406s int [1:2] -4 1 406s List of 2 406s $ non-trimmed: num NA 406s $ trimmed : num NA 406s int [1:3] -2 1 -1 406s List of 2 406s $ non-trimmed: num 2.5 406s $ trimmed : num 2.5 406s mode: double num(0) 406s List of 2 406s $ non-trimmed: num NA 406s $ trimmed : num NA 406s num -3.78 406s List of 2 406s $ non-trimmed: num NA 406s $ trimmed : num NA 406s num [1:2] -2.04 2.38 406s List of 2 406s $ non-trimmed: num NA 406s $ trimmed : num NA 406s num [1:3] 1.42 -2.14 1.14 406s List of 2 406s $ non-trimmed: num 3.42 406s $ trimmed : num 3.42 406s sdDiff()...DONE 406s madDiff()... 406s mode: integer int(0) 406s List of 2 406s $ non-trimmed: num NA 406s $ trimmed : num NA 406s int -1 406s List of 2 406s $ non-trimmed: num NA 406s $ trimmed : num NA 406s int [1:2] -1 4 406s List of 2 406s $ non-trimmed: num NA 406s $ trimmed : num NA 406s int [1:3] -1 0 -3 406s List of 2 406s $ non-trimmed: num 2.1 406s $ trimmed : num 2.1 406s mode: double num(0) 406s List of 2 406s $ non-trimmed: num NA 406s $ trimmed : num NA 406s num -1.13 406s List of 2 406s $ non-trimmed: num NA 406s $ trimmed : num NA 406s num [1:2] -1.7 -1.21 406s List of 2 406s $ non-trimmed: num NA 406s $ trimmed : num NA 406s num [1:3] -2.39 -0.464 3.086 406s List of 2 406s $ non-trimmed: num 0.851 406s $ trimmed : num 0.851 406s madDiff()...DONE 406s iqrDiff()... 406s mode: integer int(0) 406s List of 2 406s $ non-trimmed: num NA 406s $ trimmed : num NA 406s int 3 406s List of 2 406s $ non-trimmed: num 0 406s $ trimmed : num 0 406s int [1:2] -3 4 406s List of 2 406s $ non-trimmed: num 0 406s $ trimmed : num 0 406s int [1:3] 0 -2 -2 406s List of 2 406s $ non-trimmed: num 0.707 406s $ trimmed : num 0.707 406s mode: double num(0) 406s List of 2 406s $ non-trimmed: num NA 406s $ trimmed : num NA 406s num -4.46 406s List of 2 406s $ non-trimmed: num 0 406s $ trimmed : num 0 406s num [1:2] 3.67 1.02 406s List of 2 406s $ non-trimmed: num 0 406s $ trimmed : num 0 406s num [1:3] -0.537 -2.733 2.857 406s List of 2 406s $ non-trimmed: num 2.75 406s $ trimmed : num 2.75 406s iqrDiff()...DONE 406s > 407s 407s R version 4.4.3 (2025-02-28) -- "Trophy Case" 407s Copyright (C) 2025 The R Foundation for Statistical Computing 407s Platform: aarch64-unknown-linux-gnu 407s 407s R is free software and comes with ABSOLUTELY NO WARRANTY. 407s You are welcome to redistribute it under certain conditions. 407s Type 'license()' or 'licence()' for distribution details. 407s 407s R is a collaborative project with many contributors. 407s Type 'contributors()' for more information and 407s 'citation()' on how to cite R or R packages in publications. 407s 407s Type 'demo()' for some demos, 'help()' for on-line help, or 407s 'help.start()' for an HTML browser interface to help. 407s Type 'q()' to quit R. 407s 407s > library("matrixStats") 407s > 407s > fcns <- list( 407s + varDiff = varDiff, 407s + sdDiff = sdDiff, 407s + madDiff = madDiff, 407s + iqrDiff = iqrDiff 407s + ) 407s > 407s > 407s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 407s > # Subsetted tests 407s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 407s > source("utils/validateIndicesFramework.R") 407s > for (name in names(fcns)) { 407s + cat(sprintf("subsetted tests on %s()...\n", name)) 407s + fcn <- fcns[[name]] 407s + 407s + for (mode in c("numeric", "integer")) { 407s + x <- runif(6, min = -6, max = 6) 407s + storage.mode(x) <- mode 407s + trim <- runif(1, min = 0, max = 0.5) 407s + if (mode == "numeric") x[1] <- Inf 407s + 407s + for (diff in 1:2) { 407s + for (idxs in index_cases) { 407s + validateIndicesTestVector(x, idxs, 407s + ftest = fcn, fsure = fcn, 407s + na.rm = TRUE, diff = diff, trim = trim) 407s + validateIndicesTestVector(x, idxs, 407s + ftest = fcn, fsure = fcn, 407s + na.rm = FALSE, diff = diff, trim = trim) 407s + } 407s + } 407s + } 407s + cat(sprintf("%s()...DONE\n", name)) 407s + } 407s subsetted tests on varDiff()... 407s varDiff()...DONE 407s subsetted tests on sdDiff()... 407s sdDiff()...DONE 407s subsetted tests on madDiff()... 407s madDiff()...DONE 407s subsetted tests on iqrDiff()... 407s iqrDiff()...DONE 407s > 407s 407s R version 4.4.3 (2025-02-28) -- "Trophy Case" 407s Copyright (C) 2025 The R Foundation for Statistical Computing 407s Platform: aarch64-unknown-linux-gnu 407s 407s R is free software and comes with ABSOLUTELY NO WARRANTY. 407s You are welcome to redistribute it under certain conditions. 407s Type 'license()' or 'licence()' for distribution details. 407s 407s R is a collaborative project with many contributors. 407s Type 'contributors()' for more information and 407s 'citation()' on how to cite R or R packages in publications. 407s 407s Type 'demo()' for some demos, 'help()' for on-line help, or 407s 'help.start()' for an HTML browser interface to help. 407s Type 'q()' to quit R. 407s 407s > library("matrixStats") 407s > 407s > for (mode in c("logical", "integer", "double")) { 407s + cat("mode: ", mode, "", sep = "") 407s + n <- 2L 407s + x <- runif(n, min = -5, max = 5) 407s + if (mode == "logical") { 407s + x <- x > 0 407s + } 407s + storage.mode(x) <- mode 407s + str(x) 407s + 407s + cat("All weights are 1\n") 407s + w <- rep(1, times = n) 407s + m0 <- weighted.mean(x, w) 407s + m1 <- weightedMean(x, w) 407s + str(list(m0 = m0, m1 = m1)) 407s + stopifnot(identical(m1, m0)) 407s + 407s + cat("First weight is 5\n") 407s + # Pull the mean towards zero 407s + w[1] <- 5 407s + str(w) 407s + m0 <- weighted.mean(x, w) 407s + m1 <- weightedMean(x, w) 407s + str(list(m0 = m0, m1 = m1)) 407s + stopifnot(identical(m1, m0)) 407s + 407s + cat("All weights are 0\n") 407s + # All weights set to zero 407s + w <- rep(0, times = n) 407s + m0 <- weighted.mean(x, w) 407s + m1 <- weightedMean(x, w) 407s + str(list(m0 = m0, m1 = m1)) 407s + stopifnot(identical(m1, m0)) 407s + 407s + cat("First weight is 8.5\n") 407s + # Put even more weight on the zero 407s + w[1] <- 8.5 407s + m0 <- weighted.mean(x, w) 407s + m1 <- weightedMean(x, w) 407s + str(list(m0 = m0, m1 = m1)) 407s + stopifnot(identical(m1, m0)) 407s + 407s + cat("First weight is Inf\n") 407s + # All weight on the first value 407s + w[1] <- Inf 407s + m0 <- weighted.mean(x, w) 407s + m1 <- weightedMean(x, w) 407s + str(list(m0 = m0, m1 = m1)) 407s + stopifnot(identical(m1, m0)) 407s + 407s + cat("Last weight is Inf\n") 407s + # All weight on the last value 407s + w[1] <- 1 407s + w[n] <- Inf 407s + m0 <- weighted.mean(x, w) 407s + m1 <- weightedMean(x, w) 407s + str(list(m0 = m0, m1 = m1)) 407s + stopifnot(identical(m1, m0)) 407s + } # for (mode ...) 407s mode: logical logi [1:2] TRUE FALSE 407s All weights are 1 407s List of 2 407s $ m0: num 0.5 407s $ m1: num 0.5 407s First weight is 5 407s num [1:2] 5 1 407s List of 2 407s $ m0: num 0.833 407s $ m1: num 0.833 407s All weights are 0 407s List of 2 407s $ m0: num NaN 407s $ m1: num NaN 407s First weight is 8.5 407s List of 2 407s $ m0: num 1 407s $ m1: num 1 407s First weight is Inf 407s List of 2 407s $ m0: num NaN 407s $ m1: num NaN 407s Last weight is Inf 407s List of 2 407s $ m0: num NaN 407s $ m1: num NaN 407s mode: integer int [1:2] -4 3 407s All weights are 1 407s List of 2 407s $ m0: num -0.5 407s $ m1: num -0.5 407s First weight is 5 407s num [1:2] 5 1 407s List of 2 407s $ m0: num -2.83 407s $ m1: num -2.83 407s All weights are 0 407s List of 2 407s $ m0: num NaN 407s $ m1: num NaN 407s First weight is 8.5 407s List of 2 407s $ m0: num -4 407s $ m1: num -4 407s First weight is Inf 407s List of 2 407s $ m0: num NaN 407s $ m1: num NaN 407s Last weight is Inf 407s List of 2 407s $ m0: num NaN 407s $ m1: num NaN 407s mode: double num [1:2] 0.057 -2.22 407s All weights are 1 407s List of 2 407s $ m0: num -1.08 407s $ m1: num -1.08 407s First weight is 5 407s num [1:2] 5 1 407s List of 2 407s $ m0: num -0.323 407s $ m1: num -0.323 407s All weights are 0 407s List of 2 407s $ m0: num NaN 407s $ m1: num NaN 407s First weight is 8.5 407s List of 2 407s $ m0: num 0.057 407s $ m1: num 0.057 407s First weight is Inf 407s List of 2 407s $ m0: num NaN 407s $ m1: num NaN 407s Last weight is Inf 407s List of 2 407s $ m0: num NaN 407s $ m1: num NaN 407s > 407s > 407s > message("*** Testing for missing values") 407s *** Testing for missing values 407s > # NA tests 407s > xs <- list(A = c(1, 2, 3), B = c(NA, 2, 3), C = c(NA, 2, 3)) 407s > ws <- list(A = c(1, 1, 1), B = c(NA, 1, 1), C = c(1, NA, 1)) 407s > ## NOTE: The (B, B) case with na.rm = TRUE is interesting because 407s > ## even if NAs in 'w' are not dropped by na.rm = TRUE, this one 407s > ## is because 'x' is dropped and therefore that first element 407s > ## is skipped in the computation. It basically does 407s > ## keep <- !is.na(x); x <- x[keep]; w <- w[keep] 407s > ## without looking at 'w'. 407s > for (x in xs) { 407s + for (mode in c("logical", "integer", "double")) { 407s + storage.mode(x) <- mode 407s + for (w in ws) { 407s + for (na.rm in c(FALSE, TRUE)) { 407s + cat(sprintf("mode: %s, na.rm = %s\n", mode, na.rm)) 407s + str(list(x = x, w = w)) 407s + m0 <- weighted.mean(x, w, na.rm = na.rm) 407s + m1 <- weightedMean(x, w, na.rm = na.rm) 407s + str(list(m0 = m0, m1 = m1)) 407s + stopifnot(all.equal(m1, m0)) 407s + } 407s + } 407s + } 407s + } 407s mode: logical, na.rm = FALSE 407s List of 2 407s $ x: logi [1:3] TRUE TRUE TRUE 407s $ w: num [1:3] 1 1 1 407s List of 2 407s $ m0: num 1 407s $ m1: num 1 407s mode: logical, na.rm = TRUE 407s List of 2 407s $ x: logi [1:3] TRUE TRUE TRUE 407s $ w: num [1:3] 1 1 1 407s List of 2 407s $ m0: num 1 407s $ m1: num 1 407s mode: logical, na.rm = FALSE 407s List of 2 407s $ x: logi [1:3] TRUE TRUE TRUE 407s $ w: num [1:3] NA 1 1 407s List of 2 407s $ m0: num NA 407s $ m1: num NA 407s mode: logical, na.rm = TRUE 407s List of 2 407s $ x: logi [1:3] TRUE TRUE TRUE 407s $ w: num [1:3] NA 1 1 407s List of 2 407s $ m0: num NA 407s $ m1: num NA 407s mode: logical, na.rm = FALSE 407s List of 2 407s $ x: logi [1:3] TRUE TRUE TRUE 407s $ w: num [1:3] 1 NA 1 407s List of 2 407s $ m0: num NA 407s $ m1: num NA 407s mode: logical, na.rm = TRUE 407s List of 2 407s $ x: logi [1:3] TRUE TRUE TRUE 407s $ w: num [1:3] 1 NA 1 407s List of 2 407s $ m0: num NA 407s $ m1: num NA 407s mode: integer, na.rm = FALSE 407s List of 2 407s $ x: int [1:3] 1 1 1 407s $ w: num [1:3] 1 1 1 407s List of 2 407s $ m0: num 1 407s $ m1: num 1 407s mode: integer, na.rm = TRUE 407s List of 2 407s $ x: int [1:3] 1 1 1 407s $ w: num [1:3] 1 1 1 407s List of 2 407s $ m0: num 1 407s $ m1: num 1 407s mode: integer, na.rm = FALSE 407s List of 2 407s $ x: int [1:3] 1 1 1 407s $ w: num [1:3] NA 1 1 407s List of 2 407s $ m0: num NA 407s $ m1: num NA 407s mode: integer, na.rm = TRUE 407s List of 2 407s $ x: int [1:3] 1 1 1 407s $ w: num [1:3] NA 1 1 407s List of 2 407s $ m0: num NA 407s $ m1: num NA 407s mode: integer, na.rm = FALSE 407s List of 2 407s $ x: int [1:3] 1 1 1 407s $ w: num [1:3] 1 NA 1 407s List of 2 407s $ m0: num NA 407s $ m1: num NA 407s mode: integer, na.rm = TRUE 407s List of 2 407s $ x: int [1:3] 1 1 1 407s $ w: num [1:3] 1 NA 1 407s List of 2 407s $ m0: num NA 407s $ m1: num NA 407s mode: double, na.rm = FALSE 407s List of 2 407s $ x: num [1:3] 1 1 1 407s $ w: num [1:3] 1 1 1 407s List of 2 407s $ m0: num 1 407s $ m1: num 1 407s mode: double, na.rm = TRUE 407s List of 2 407s $ x: num [1:3] 1 1 1 407s $ w: num [1:3] 1 1 1 407s List of 2 407s $ m0: num 1 407s $ m1: num 1 407s mode: double, na.rm = FALSE 407s List of 2 407s $ x: num [1:3] 1 1 1 407s $ w: num [1:3] NA 1 1 407s List of 2 407s $ m0: num NA 407s $ m1: num NA 407s mode: double, na.rm = TRUE 407s List of 2 407s $ x: num [1:3] 1 1 1 407s $ w: num [1:3] NA 1 1 407s List of 2 407s $ m0: num NA 407s $ m1: num NA 407s mode: double, na.rm = FALSE 407s List of 2 407s $ x: num [1:3] 1 1 1 407s $ w: num [1:3] 1 NA 1 407s List of 2 407s $ m0: num NA 407s $ m1: num NA 407s mode: double, na.rm = TRUE 407s List of 2 407s $ x: num [1:3] 1 1 1 407s $ w: num [1:3] 1 NA 1 407s List of 2 407s $ m0: num NA 407s $ m1: num NA 407s mode: logical, na.rm = FALSE 407s List of 2 407s $ x: logi [1:3] NA TRUE TRUE 407s $ w: num [1:3] 1 1 1 407s List of 2 407s $ m0: num NA 407s $ m1: num NA 407s mode: logical, na.rm = TRUE 407s List of 2 407s $ x: logi [1:3] NA TRUE TRUE 407s $ w: num [1:3] 1 1 1 407s List of 2 407s $ m0: num 1 407s $ m1: num 1 407s mode: logical, na.rm = FALSE 407s List of 2 407s $ x: logi [1:3] NA TRUE TRUE 407s $ w: num [1:3] NA 1 1 407s List of 2 407s $ m0: num NA 407s $ m1: num NA 407s mode: logical, na.rm = TRUE 407s List of 2 407s $ x: logi [1:3] NA TRUE TRUE 407s $ w: num [1:3] NA 1 1 407s List of 2 407s $ m0: num 1 407s $ m1: num 1 407s mode: logical, na.rm = FALSE 407s List of 2 407s $ x: logi [1:3] NA TRUE TRUE 407s $ w: num [1:3] 1 NA 1 407s List of 2 407s $ m0: num NA 407s $ m1: num NA 407s mode: logical, na.rm = TRUE 407s List of 2 407s $ x: logi [1:3] NA TRUE TRUE 407s $ w: num [1:3] 1 NA 1 407s List of 2 407s $ m0: num NA 407s $ m1: num NA 407s mode: integer, na.rm = FALSE 407s List of 2 407s $ x: int [1:3] NA 1 1 407s $ w: num [1:3] 1 1 1 407s List of 2 407s $ m0: num NA 407s $ m1: num NA 407s mode: integer, na.rm = TRUE 407s List of 2 407s $ x: int [1:3] NA 1 1 407s $ w: num [1:3] 1 1 1 407s List of 2 407s $ m0: num 1 407s $ m1: num 1 407s mode: integer, na.rm = FALSE 407s List of 2 407s $ x: int [1:3] NA 1 1 407s $ w: num [1:3] NA 1 1 407s List of 2 407s $ m0: num NA 407s $ m1: num NA 407s mode: integer, na.rm = TRUE 407s List of 2 407s $ x: int [1:3] NA 1 1 407s $ w: num [1:3] NA 1 1 407s List of 2 407s $ m0: num 1 407s $ m1: num 1 407s mode: integer, na.rm = FALSE 407s List of 2 407s $ x: int [1:3] NA 1 1 407s $ w: num [1:3] 1 NA 1 407s List of 2 407s $ m0: num NA 407s $ m1: num NA 407s mode: integer, na.rm = TRUE 407s List of 2 407s $ x: int [1:3] NA 1 1 407s $ w: num [1:3] 1 NA 1 407s List of 2 407s $ m0: num NA 407s $ m1: num NA 407s mode: double, na.rm = FALSE 407s List of 2 407s $ x: num [1:3] NA 1 1 407s $ w: num [1:3] 1 1 1 407s List of 2 407s $ m0: num NA 407s $ m1: num NA 407s mode: double, na.rm = TRUE 407s List of 2 407s $ x: num [1:3] NA 1 1 407s $ w: num [1:3] 1 1 1 407s List of 2 407s $ m0: num 1 407s $ m1: num 1 407s mode: double, na.rm = FALSE 407s List of 2 407s $ x: num [1:3] NA 1 1 407s $ w: num [1:3] NA 1 1 407s List of 2 407s $ m0: num NA 407s $ m1: num NA 407s mode: double, na.rm = TRUE 407s List of 2 407s $ x: num [1:3] NA 1 1 407s $ w: num [1:3] NA 1 1 407s List of 2 407s $ m0: num 1 407s $ m1: num 1 407s mode: double, na.rm = FALSE 407s List of 2 407s $ x: num [1:3] NA 1 1 407s $ w: num [1:3] 1 NA 1 407s List of 2 407s $ m0: num NA 407s $ m1: num NA 407s mode: double, na.rm = TRUE 407s List of 2 407s $ x: num [1:3] NA 1 1 407s $ w: num [1:3] 1 NA 1 407s List of 2 407s $ m0: num NA 407s $ m1: num NA 407s mode: logical, na.rm = FALSE 407s List of 2 407s $ x: logi [1:3] NA TRUE TRUE 407s $ w: num [1:3] 1 1 1 407s List of 2 407s $ m0: num NA 407s $ m1: num NA 407s mode: logical, na.rm = TRUE 407s List of 2 407s $ x: logi [1:3] NA TRUE TRUE 407s $ w: num [1:3] 1 1 1 407s List of 2 407s $ m0: num 1 407s $ m1: num 1 407s mode: logical, na.rm = FALSE 407s List of 2 407s $ x: logi [1:3] NA TRUE TRUE 407s $ w: num [1:3] NA 1 1 407s List of 2 407s $ m0: num NA 407s $ m1: num NA 407s mode: logical, na.rm = TRUE 407s List of 2 407s $ x: logi [1:3] NA TRUE TRUE 407s $ w: num [1:3] NA 1 1 407s List of 2 407s $ m0: num 1 407s $ m1: num 1 407s mode: logical, na.rm = FALSE 407s List of 2 407s $ x: logi [1:3] NA TRUE TRUE 407s $ w: num [1:3] 1 NA 1 407s List of 2 407s $ m0: num NA 407s $ m1: num NA 407s mode: logical, na.rm = TRUE 407s List of 2 407s $ x: logi [1:3] NA TRUE TRUE 407s $ w: num [1:3] 1 NA 1 407s List of 2 407s $ m0: num NA 407s $ m1: num NA 407s mode: integer, na.rm = FALSE 407s List of 2 407s $ x: int [1:3] NA 1 1 407s $ w: num [1:3] 1 1 1 407s List of 2 407s $ m0: num NA 407s $ m1: num NA 407s mode: integer, na.rm = TRUE 407s List of 2 407s $ x: int [1:3] NA 1 1 407s $ w: num [1:3] 1 1 1 407s List of 2 407s $ m0: num 1 407s $ m1: num 1 407s mode: integer, na.rm = FALSE 407s List of 2 407s $ x: int [1:3] NA 1 1 407s $ w: num [1:3] NA 1 1 407s List of 2 407s $ m0: num NA 407s $ m1: num NA 407s mode: integer, na.rm = TRUE 407s List of 2 407s $ x: int [1:3] NA 1 1 407s $ w: num [1:3] NA 1 1 407s List of 2 407s $ m0: num 1 407s $ m1: num 1 407s mode: integer, na.rm = FALSE 407s List of 2 407s $ x: int [1:3] NA 1 1 407s $ w: num [1:3] 1 NA 1 407s List of 2 407s $ m0: num NA 407s $ m1: num NA 407s mode: integer, na.rm = TRUE 407s List of 2 407s $ x: int [1:3] NA 1 1 407s $ w: num [1:3] 1 NA 1 407s List of 2 407s $ m0: num NA 407s $ m1: num NA 407s mode: double, na.rm = FALSE 407s List of 2 407s $ x: num [1:3] NA 1 1 407s $ w: num [1:3] 1 1 1 407s List of 2 407s $ m0: num NA 407s $ m1: num NA 407s mode: double, na.rm = TRUE 407s List of 2 407s $ x: num [1:3] NA 1 1 407s $ w: num [1:3] 1 1 1 407s List of 2 407s $ m0: num 1 407s $ m1: num 1 407s mode: double, na.rm = FALSE 407s List of 2 407s $ x: num [1:3] NA 1 1 407s $ w: num [1:3] NA 1 1 407s List of 2 407s $ m0: num NA 407s $ m1: num NA 407s mode: double, na.rm = TRUE 407s List of 2 407s $ x: num [1:3] NA 1 1 407s $ w: num [1:3] NA 1 1 407s List of 2 407s $ m0: num 1 407s $ m1: num 1 407s mode: double, na.rm = FALSE 407s List of 2 407s $ x: num [1:3] NA 1 1 407s $ w: num [1:3] 1 NA 1 407s List of 2 407s $ m0: num NA 407s $ m1: num NA 407s mode: double, na.rm = TRUE 407s List of 2 407s $ x: num [1:3] NA 1 1 407s $ w: num [1:3] 1 NA 1 407s List of 2 407s $ m0: num NA 408s $ m1: num NA 408s > 408s *** weightedVar() ... 408s - Zero elements 408s 408s R version 4.4.3 (2025-02-28) -- "Trophy Case" 408s Copyright (C) 2025 The R Foundation for Statistical Computing 408s Platform: aarch64-unknown-linux-gnu 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 408s > library("matrixStats") 408s > 408s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 408s > # Subsetted tests 408s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 408s > source("utils/validateIndicesFramework.R") 408s > for (mode in c("numeric", "integer")) { 408s + x <- runif(6, min = -6, max = 6) 408s + w <- runif(6, min = 0, max = 6) 408s + storage.mode(x) <- mode 408s + storage.mode(w) <- mode 408s + if (mode == "numeric") w[1] <- Inf 408s + 408s + for (idxs in index_cases) { 408s + validateIndicesTestVector_w(x, w, idxs, 408s + ftest = weightedMean, fsure = weighted.mean, 408s + na.rm = TRUE, refine = TRUE) 408s + validateIndicesTestVector_w(x, w, idxs, 408s + ftest = weightedMean, fsure = weighted.mean, 408s + na.rm = FALSE, refine = TRUE) 408s + } 408s + } 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: aarch64-unknown-linux-gnu 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 408s > library("matrixStats") 408s > 408s > x <- 1:5 408s > y <- weightedMedian(x) 408s > y <- weightedMedian(x, w = c(NA, Inf, NA, Inf, NA), na.rm = TRUE) 408s > print(y) 408s [1] 3 408s > 408s > y <- weightedMedian(x, w = c(NA, Inf, NA, Inf, NA), na.rm = FALSE) 408s > print(y) 408s [1] NA 408s > stopifnot(is.na(y)) 408s > 408s > x <- 1:10 408s > n <- length(x) 408s > 408s > y1 <- median(x) # 5.5 408s > y2 <- weightedMedian(x) # 5.5 408s > stopifnot(all.equal(y1, y2)) 408s > 408s > 408s > w <- rep(1, times = n) 408s > y1 <- weightedMedian(x, w) # 5.5 (default) 408s > y2a <- weightedMedian(x, ties = "weighted") # 5.5 (default) 408s > y2b <- weightedMedian(x, ties = "min") # 5 408s > y2c <- weightedMedian(x, ties = "max") # 6 408s > stopifnot(all.equal(y2a, y1)) 408s > 408s > y3 <- weightedMedian(x, w) # 5.5 (default) 408s > 408s > 408s > # Pull the median towards zero 408s > w[1] <- 5 408s > y1 <- weightedMedian(x, w) # 3.5 408s > y <- c(rep(0, times = w[1]), x[-1]) # Only possible for integer weights 408s > y2 <- median(y) # 3.5 408s > stopifnot(all.equal(y1, y2)) 408s > 408s > # Put even more weight on the zero 408s > w[1] <- 8.5 408s > y <- weightedMedian(x, w) # 2 408s > 408s > # All weight on the first value 408s > w[1] <- Inf 408s > y <- weightedMedian(x, w) # 1 408s > 408s > # All weight on the last value 408s > w[1] <- 1 408s > w[n] <- Inf 408s > y <- weightedMedian(x, w) # 10 408s > 408s > # All weights set to zero 408s > w <- rep(0, times = n) 408s > y <- weightedMedian(x, w) # NA 408s > 408s > x <- 1:4 408s > w <- rep(1, times = 4) 408s > for (mode in c("integer", "double")) { 408s + storage.mode(x) <- mode 408s + for (ties in c("weighted", "mean", "min", "max")) { 408s + cat(sprintf("ties = %s\n", ties)) 408s + y <- weightedMedian(x, w, ties = ties) 408s + } 408s + } 408s ties = weighted 408s ties = mean 408s ties = min 408s ties = max 408s ties = weighted 408s ties = mean 408s ties = min 408s ties = max 408s > 408s > set.seed(0x42) 408s > 408s > y <- weightedMedian(x = double(0L)) 408s > print(y) 408s [1] NA 408s > stopifnot(length(y) == 1L) 408s > stopifnot(is.na(y)) 408s > 408s > y <- weightedMedian(x = x[1]) 408s > print(y) 408s [1] 1 408s > stopifnot(length(y) == 1L) 408s > stopifnot(all.equal(y, x[1])) 408s > 408s > 408s > n <- 1e3 408s > x <- runif(n) 408s > w <- runif(n, min = 0, max = 1) 408s > for (mode in c("integer", "double")) { 408s + storage.mode(x) <- mode 408s + for (ties in c("weighted", "mean", "min", "max")) { 408s + y <- weightedMedian(x, w, ties = ties) 408s + cat(sprintf("mode = %s, ties = %s, result = %g\n", mode, ties, y)) 408s + } 408s + } 408s mode = integer, ties = weighted, result = 0 408s mode = integer, ties = mean, result = 0 408s mode = integer, ties = min, result = 0 408s mode = integer, ties = max, result = 0 408s mode = double, ties = weighted, result = 0 408s mode = double, ties = mean, result = 0 408s mode = double, ties = min, result = 0 408s mode = double, ties = max, result = 0 408s > 408s > 408s > # A large vector 408s > n <- 1e5 408s > x <- runif(n) 408s > w <- runif(n, min = 0, max = 1) 408s > y <- weightedMedian(x, w) 408s > 408s > y <- weightedMedian(x, w, ties = "min") 408s > 408s > 408s > # Single Number 408s > xs <- c(1, NA_integer_) 408s > ws <- c(1, NA_integer_) 408s > for (x in xs) { 408s + for (w in ws) { 408s + y <- weightedMedian(x = x, w = w) 408s + if (is.na(w)) z <- NA_real_ 408s + else z <- x[1] 408s + stopifnot(all.equal(y, z)) 408s + } 408s + } 408s > 408s > ## Logical 408s > x1 <- c(TRUE, FALSE, TRUE) 408s > w0 <- c(0, 0, 0) 408s > stopifnot(!is.finite(weightedMedian(x1, w0)), 408s + !is.infinite(weightedMedian(x1, w0))) 408s > 408s > w1 <- c(1, 1, 1) 408s > stopifnot(weightedMedian(x1, w1) == 1) 408s > 408s > w2 <- c(1, 2, 3) 408s > stopifnot(weightedMedian(x1, w2) == 1) 408s > 408s > ### NA 408s > stopifnot(is.na(weightedMedian(c(TRUE, FALSE, NA), 408s + c(1, 2, 3))), 408s + all.equal(weightedMedian(c(TRUE, FALSE, NA), 408s + c(1, 2, 3), 408s + na.rm = TRUE), 408s + weightedMedian(c(TRUE, FALSE), 408s + c(1, 2)))) 408s > ### Identical to as.integer() 408s > x <- rcauchy(100) 408s > w <- abs(rcauchy(100)) 408s > stopifnot(all.equal(weightedMedian(x > 0, w), 408s + weightedMedian(as.integer(x > 0), w))) 408s > 408s > 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: aarch64-unknown-linux-gnu 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 408s > library("matrixStats") 408s > 408s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 408s > # Subsetted tests 408s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 408s > source("utils/validateIndicesFramework.R") 408s > for (mode in c("numeric", "integer")) { 408s + x <- runif(6, min = -6, max = 6) 408s + w <- runif(6, min = 0, max = 6) 408s + storage.mode(x) <- mode 408s + storage.mode(w) <- mode 408s + if (mode == "numeric") w[1] <- Inf 408s + 408s + for (idxs in index_cases) { 408s + validateIndicesTestVector_w(x, w, idxs, 408s + ftest = weightedMedian, 408s + fsure = weightedMedian, 408s + na.rm = TRUE) 408s + validateIndicesTestVector_w(x, w, idxs, 408s + ftest = weightedMedian, 408s + fsure = weightedMedian, 408s + na.rm = FALSE) 408s + 408s + for (ties in c("weighted", "mean", "min", "max")) { 408s + validateIndicesTestVector_w(x, w, idxs, 408s + ftest = weightedMedian, 408s + fsure = weightedMedian, 408s + na.rm = TRUE, ties = ties) 408s + validateIndicesTestVector_w(x, w, idxs, 408s + ftest = weightedMedian, 408s + fsure = weightedMedian, 408s + na.rm = FALSE, ties = ties) 408s + } 408s + } 408s + } 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: aarch64-unknown-linux-gnu 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 408s > library("matrixStats") 408s > 408s > weightedVar_R <- function(x, w) { 408s + mu <- weighted.mean(x, w = w) 408s + sum(w * (x - mu) ^ 2) / (sum(w) - 1) 408s + } 408s > 408s > 408s > n <- 10 408s > x <- as.double(1:n) 408s > 408s > message("*** weightedVar() ...") 408s > 408s > message("- Zero elements") 408s > m0 <- var(integer(0)) 408s > m1 <- weightedVar(integer(0), w = integer(0)) 408s > str(list(m0 = m0, m1 = m1)) 408s List of 2 408s $ m0: num NA 408s $ m1: int NA 408s > stopifnot(all.equal(m1, m0)) 408s > 408s > 408s > message("- One elements") 408s > m0 <- var(1) 408s > m1 <- weightedVar(1) 408s > str(list(m0 = m0, m1 = m1)) 408s List of 2 408s $ m0: num NA 408s $ m1: num NA 408s > stopifnot(all.equal(m1, m0)) 408s > 408s > 408s > message("- Uniform weights (all w = 1)") 408s > m0 <- var(x) 408s > w <- rep(1, times = n) 408s > m1 <- weightedVar(x, w = w) 408s > str(list(m0 = m0, m1 = m1)) 408s List of 2 408s $ m0: num 9.17 408s $ m1: num 9.17 408s > stopifnot(all.equal(m1, m0)) 408s > 408s > 408s > message("- Uniform weights (all w = 3)") 408s > m0 <- var(rep(x, each = 3)) 408s > w <- rep(3, times = n) 408s > m1 <- weightedVar(x, w = w) 408s > str(list(m0 = m0, m1 = m1)) 408s List of 2 408s $ m0: num 8.53 408s $ m1: num 8.53 408s > stopifnot(all.equal(m1, m0)) 408s > 408s > 408s > message("- Uniform weights on the first five elements") 408s > idxs <- 1:5 408s > m0 <- var(x[1:5]) 408s > w <- rep(0, times = n) 408s > w[idxs] <- 1 408s > m1 <- weightedVar(x, w = w) 408s > str(list(m0 = m0, m1 = m1)) 408s List of 2 408s $ m0: num 2.5 408s $ m1: num 2.5 408s > stopifnot(all.equal(m1, m0)) 408s > 408s > 408s > message("- Uniform weights on every second elements") 408s > idxs <- seq(from = 1, to = n, by = 2) 408s > m0 <- var(x[idxs]) 408s > w <- rep(0, times = n) 408s > w[idxs] <- 1 408s > m1 <- weightedVar(x, w = w) 408s > str(list(m0 = m0, m1 = m1)) 408s List of 2 408s $ m0: num 10 408s $ m1: num 10 408s > stopifnot(all.equal(m1, m0)) 408s > 408s > 408s > message("- All weights are zero") 408s > idxs <- integer(0L) 408s > m0 <- var(x[idxs]) 408s > w <- rep(0, times = n) 408s > w[idxs] <- 1 408s > m1 <- weightedVar(x, w = w) 408s > str(list(m0 = m0, m1 = m1)) 408s List of 2 408s $ m0: num NA 408s $ m1: num NA 408s > stopifnot(all.equal(m1, m0)) 408s > 408s > message("- Infinite weight on first element") 408s > idxs <- 1L 408s > m0 <- var(x[idxs]) 408s > w <- rep(0, times = n) 408s > w[idxs] <- Inf 408s > m1 <- weightedVar(x, w = w) 408s > str(list(m0 = m0, m1 = m1)) 408s List of 2 408s $ m0: num NA 408s $ m1: num NA 408s > stopifnot(all.equal(m1, m0)) 408s > 408s > message("- Missing-value weight on first element") 408s > idxs <- 1L 408s > w <- rep(1, times = n) 408s > w[idxs] <- NA_real_ 408s > m1 <- weightedVar(x, w = w) 408s > str(list(m1 = m1)) 408s List of 1 408s $ m1: num NA 408s > stopifnot(identical(m1, NA_real_)) 408s > 408s > 408s > message("- Frequency weights") 408s > 408s > ## From https://en.wikipedia.org/wiki/Weighted_arithmetic_mean 408s > y <- c(2, 2, 4, 5, 5, 5) 408s > x <- unique(y) 408s > w <- table(y) 408s > stopifnot(names(w) == x) 408s > 408s > m0 <- weightedVar(x, w = w) 408s > m1 <- var(y) 408s > stopifnot(all.equal(m1, m0)) 408s > m2 <- weightedVar(x, w = w) 408s > str(list(m0 = m0, m1 = m1, m2 = m2)) 408s List of 3 408s $ m0: num 2.17 408s $ m1: num 2.17 408s $ m2: num 2.17 408s > stopifnot(all.equal(m2, m0)) 408s > 408s > ## From https://github.com/HenrikBengtsson/matrixStats/issues/72 408s > large <- c(21, 8, 26, 1, 15, 33, 12, 25, 0, 84) 408s > years <- c(41706, 9301, 33678, 3082, 27040, 44188, 10049, 30591, 2275, 109831) 408s > 408s > m0 <- weightedVar(large, w = years) 408s > m1 <- weightedVar(large, w = years) 408s > str(list(m0 = m0, m1 = m1)) 408s List of 2 408s $ m0: num 899 408s $ m1: num 899 408s > stopifnot(all.equal(m1, m0)) 408s > 408s > message("*** weightedVar() ... DONE") 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: aarch64-unknown-linux-gnu 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 408s - One elements 408s - Uniform weights (all w = 1) 408s - Uniform weights (all w = 3) 408s - Uniform weights on the first five elements 408s - Uniform weights on every second elements 408s - All weights are zero 408s - Infinite weight on first element 408s - Missing-value weight on first element 408s - Frequency weights 408s *** weightedVar() ... DONE 409s > library("matrixStats") 409s > 409s > fcns <- list( 409s + weightedVar = weightedVar, 409s + weightedSd = weightedSd, 409s + weightedMad = weightedMad 409s + ) 409s > 409s > for (name in names(fcns)) { 409s + cat(sprintf("%s()...\n", name)) 409s + fcn <- fcns[[name]] 409s + 409s + for (mode in c("integer", "double")) { 409s + cat("mode: ", mode, "\n", sep = "") 409s + n <- 15L 409s + x <- runif(n, min = -5, max = 5) 409s + storage.mode(x) <- mode 409s + str(x) 409s + 409s + for (add_na in c(FALSE, TRUE)) { 409s + cat("add_na: ", add_na, "\n", sep = "") 409s + if (add_na) { 409s + x[c(5, 7)] <- NA 409s + } 409s + str(x) 409s + 409s + for (na.rm in c(FALSE, TRUE)) { 409s + cat("na.rm: ", na.rm, "\n", sep = "") 409s + 409s + cat("Weights are not specified (all are 1)\n") 409s + m1 <- fcn(x, na.rm = na.rm) 409s + str(list(m1 = m1)) 409s + 409s + cat("All weights are 1\n") 409s + w <- rep(1, times = n) 409s + m1 <- fcn(x, w, na.rm = na.rm) 409s + str(list(m1 = m1)) 409s + 409s + cat("First weight is 5\n") 409s + # Pull the mean towards zero 409s + w[1] <- 5 409s + str(w) 409s + m1 <- fcn(x, w, na.rm = na.rm) 409s + str(list(m1 = m1)) 409s + 409s + cat("All weights are 0\n") 409s + # All weights set to zero 409s + w <- rep(0, times = n) 409s + m1 <- fcn(x, w, na.rm = na.rm) 409s + str(list(m1 = m1)) 409s + 409s + cat("First weight is 8.5\n") 409s + # Put even more weight on the zero 409s + w[1] <- 8.5 409s + m1 <- fcn(x, w, na.rm = na.rm) 409s + str(list(m1 = m1)) 409s + 409s + cat("First weight is Inf\n") 409s + # All weight on the first value 409s + w[1] <- Inf 409s + m1 <- fcn(x, w, na.rm = na.rm) 409s + str(list(m1 = m1)) 409s + 409s + cat("Last weight is Inf\n") 409s + # All weight on the last value 409s + w[1] <- 1 409s + w[n] <- Inf 409s + m1 <- fcn(x, w, na.rm = na.rm) 409s + str(list(m1 = m1)) 409s + 409s + cat("Last weight is NA\n") 409s + # All weight on the last value 409s + w[1] <- 1 409s + w[n] <- NA_real_ 409s + m1 <- fcn(x, w, na.rm = na.rm) 409s + str(list(m1 = m1)) 409s + } # for (na.rm ...) 409s + } # for (add_na ...) 409s + } # for (mode ...) 409s + 409s + cat(sprintf("%s()...DONE\n", name)) 409s + } # for (name ...) 409s weightedVar()... 409s mode: integer 409s int [1:15] -2 1 0 2 3 0 -1 0 -3 -4 ... 409s add_na: FALSE 409s int [1:15] -2 1 0 2 3 0 -1 0 -3 -4 ... 409s na.rm: FALSE 409s Weights are not specified (all are 1) 409s List of 1 409s $ m1: num 4.12 409s All weights are 1 409s List of 1 409s $ m1: num 4.12 409s First weight is 5 409s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 409s List of 1 409s $ m1: num 3.62 409s All weights are 0 409s List of 1 409s $ m1: int NA 409s First weight is 8.5 409s List of 1 409s $ m1: int NA 409s First weight is Inf 409s List of 1 409s $ m1: int NA 409s Last weight is Inf 409s List of 1 409s $ m1: int NA 409s Last weight is NA 409s List of 1 409s $ m1: int NA 409s na.rm: TRUE 409s Weights are not specified (all are 1) 409s List of 1 409s $ m1: num 4.12 409s All weights are 1 409s List of 1 409s $ m1: num 4.12 409s First weight is 5 409s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 409s List of 1 409s $ m1: num 3.62 409s All weights are 0 409s List of 1 409s $ m1: int NA 409s First weight is 8.5 409s List of 1 409s $ m1: int NA 409s First weight is Inf 409s List of 1 409s $ m1: int NA 409s Last weight is Inf 409s List of 1 409s $ m1: int NA 409s Last weight is NA 409s List of 1 409s $ m1: int NA 409s add_na: TRUE 409s int [1:15] -2 1 0 2 NA 0 NA 0 -3 -4 ... 409s na.rm: FALSE 409s Weights are not specified (all are 1) 409s List of 1 409s $ m1: int NA 409s All weights are 1 409s List of 1 409s $ m1: int NA 409s First weight is 5 409s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 409s List of 1 409s $ m1: int NA 409s All weights are 0 409s List of 1 409s $ m1: int NA 409s First weight is 8.5 409s List of 1 409s $ m1: int NA 409s First weight is Inf 409s List of 1 409s $ m1: int NA 409s Last weight is Inf 409s List of 1 409s $ m1: int NA 409s Last weight is NA 409s List of 1 409s $ m1: int NA 409s na.rm: TRUE 409s Weights are not specified (all are 1) 409s List of 1 409s $ m1: num 3.73 409s All weights are 1 409s List of 1 409s $ m1: num 3.73 409s First weight is 5 409s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 409s List of 1 409s $ m1: num 3.12 409s All weights are 0 409s List of 1 409s $ m1: int NA 409s First weight is 8.5 409s List of 1 409s $ m1: int NA 409s First weight is Inf 409s List of 1 409s $ m1: int NA 409s Last weight is Inf 409s List of 1 409s $ m1: int NA 409s Last weight is NA 409s List of 1 409s $ m1: int NA 409s mode: double 409s num [1:15] 2.507 -0.703 -3.49 -3.536 1.657 ... 409s add_na: FALSE 409s num [1:15] 2.507 -0.703 -3.49 -3.536 1.657 ... 409s na.rm: FALSE 409s Weights are not specified (all are 1) 409s List of 1 409s $ m1: num 7.7 409s All weights are 1 409s List of 1 409s $ m1: num 7.7 409s First weight is 5 409s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 409s List of 1 409s $ m1: num 6.96 409s All weights are 0 409s List of 1 409s $ m1: num NA 409s First weight is 8.5 409s List of 1 409s $ m1: num NA 409s First weight is Inf 409s List of 1 409s $ m1: num NA 409s Last weight is Inf 409s List of 1 409s $ m1: num NA 409s Last weight is NA 409s List of 1 409s $ m1: num NA 409s na.rm: TRUE 409s Weights are not specified (all are 1) 409s List of 1 409s $ m1: num 7.7 409s All weights are 1 409s List of 1 409s $ m1: num 7.7 409s First weight is 5 409s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 409s List of 1 409s $ m1: num 6.96 409s All weights are 0 409s List of 1 409s $ m1: num NA 409s First weight is 8.5 409s List of 1 409s $ m1: num NA 409s First weight is Inf 409s List of 1 409s $ m1: num NA 409s Last weight is Inf 409s List of 1 409s $ m1: num NA 409s Last weight is NA 409s List of 1 409s $ m1: num NA 409s add_na: TRUE 409s num [1:15] 2.507 -0.703 -3.49 -3.536 NA ... 409s na.rm: FALSE 409s Weights are not specified (all are 1) 409s List of 1 409s $ m1: num NA 409s All weights are 1 409s List of 1 409s $ m1: num NA 409s First weight is 5 409s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 409s List of 1 409s $ m1: num NA 409s All weights are 0 409s List of 1 409s $ m1: num NA 409s First weight is 8.5 409s List of 1 409s $ m1: num NA 409s First weight is Inf 409s List of 1 409s $ m1: num NA 409s Last weight is Inf 409s List of 1 409s $ m1: num NA 409s Last weight is NA 409s List of 1 409s $ m1: num NA 409s na.rm: TRUE 409s Weights are not specified (all are 1) 409s List of 1 409s $ m1: num 8.36 409s All weights are 1 409s List of 1 409s $ m1: num 8.36 409s First weight is 5 409s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 409s List of 1 409s $ m1: num 7.59 409s All weights are 0 409s List of 1 409s $ m1: num NA 409s First weight is 8.5 409s List of 1 409s $ m1: num NA 409s First weight is Inf 409s List of 1 409s $ m1: num NA 409s Last weight is Inf 409s List of 1 409s $ m1: num NA 409s Last weight is NA 409s List of 1 409s $ m1: num NA 409s weightedVar()...DONE 409s weightedSd()... 409s mode: integer 409s int [1:15] 0 4 0 1 3 -4 -2 -3 0 0 ... 409s add_na: FALSE 409s int [1:15] 0 4 0 1 3 -4 -2 -3 0 0 ... 409s na.rm: FALSE 409s Weights are not specified (all are 1) 409s List of 1 409s $ m1: num 2.38 409s All weights are 1 409s List of 1 409s $ m1: num 2.38 409s First weight is 5 409s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 409s List of 1 409s $ m1: num 2.1 409s All weights are 0 409s List of 1 409s $ m1: num NA 409s First weight is 8.5 409s List of 1 409s $ m1: num NA 409s First weight is Inf 409s List of 1 409s $ m1: num NA 409s Last weight is Inf 409s List of 1 409s $ m1: num NA 409s Last weight is NA 409s List of 1 409s $ m1: num NA 409s na.rm: TRUE 409s Weights are not specified (all are 1) 409s List of 1 409s $ m1: num 2.38 409s All weights are 1 409s List of 1 409s $ m1: num 2.38 409s First weight is 5 409s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 409s List of 1 409s $ m1: num 2.1 409s All weights are 0 409s List of 1 409s $ m1: num NA 409s First weight is 8.5 409s List of 1 409s $ m1: num NA 409s First weight is Inf 409s List of 1 409s $ m1: num NA 409s Last weight is Inf 409s List of 1 409s $ m1: num NA 409s Last weight is NA 409s List of 1 409s $ m1: num NA 409s add_na: TRUE 409s int [1:15] 0 4 0 1 NA -4 NA -3 0 0 ... 409s na.rm: FALSE 409s Weights are not specified (all are 1) 409s List of 1 409s $ m1: num NA 409s All weights are 1 409s List of 1 409s $ m1: num NA 409s First weight is 5 409s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 409s List of 1 409s $ m1: num NA 409s All weights are 0 409s List of 1 409s $ m1: num NA 409s First weight is 8.5 409s List of 1 409s $ m1: num NA 409s First weight is Inf 409s List of 1 409s $ m1: num NA 409s Last weight is Inf 409s List of 1 409s $ m1: num NA 409s Last weight is NA 409s List of 1 409s $ m1: num NA 409s na.rm: TRUE 409s Weights are not specified (all are 1) 409s List of 1 409s $ m1: num 2.36 409s All weights are 1 409s List of 1 409s $ m1: num 2.36 409s First weight is 5 409s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 409s List of 1 409s $ m1: num 2.05 409s All weights are 0 409s List of 1 409s $ m1: num NA 409s First weight is 8.5 409s List of 1 409s $ m1: num NA 409s First weight is Inf 409s List of 1 409s $ m1: num NA 409s Last weight is Inf 409s List of 1 409s $ m1: num NA 409s Last weight is NA 409s List of 1 409s $ m1: num NA 409s mode: double 409s num [1:15] -3.794 0.475 0.689 -3.924 -1.995 ... 409s add_na: FALSE 409s num [1:15] -3.794 0.475 0.689 -3.924 -1.995 ... 409s na.rm: FALSE 409s Weights are not specified (all are 1) 409s List of 1 409s $ m1: num 2.94 409s All weights are 1 409s List of 1 409s $ m1: num 2.94 409s First weight is 5 409s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 409s List of 1 409s $ m1: num 3.3 409s All weights are 0 409s List of 1 409s $ m1: num NA 409s First weight is 8.5 409s List of 1 409s $ m1: num NA 409s First weight is Inf 409s List of 1 409s $ m1: num NA 409s Last weight is Inf 409s List of 1 409s $ m1: num NA 409s Last weight is NA 409s List of 1 409s $ m1: num NA 409s na.rm: TRUE 409s Weights are not specified (all are 1) 409s List of 1 409s $ m1: num 2.94 409s All weights are 1 409s List of 1 409s $ m1: num 2.94 409s First weight is 5 409s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 409s List of 1 409s $ m1: num 3.3 409s All weights are 0 409s List of 1 409s $ m1: num NA 409s First weight is 8.5 409s List of 1 409s $ m1: num NA 409s First weight is Inf 409s List of 1 409s $ m1: num NA 409s Last weight is Inf 409s List of 1 409s $ m1: num NA 409s Last weight is NA 409s List of 1 409s $ m1: num NA 409s add_na: TRUE 409s num [1:15] -3.794 0.475 0.689 -3.924 NA ... 409s na.rm: FALSE 409s Weights are not specified (all are 1) 409s List of 1 409s $ m1: num NA 409s All weights are 1 409s List of 1 409s $ m1: num NA 409s First weight is 5 409s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 409s List of 1 409s $ m1: num NA 409s All weights are 0 409s List of 1 409s $ m1: num NA 409s First weight is 8.5 409s List of 1 409s $ m1: num NA 409s First weight is Inf 409s List of 1 409s $ m1: num NA 409s Last weight is Inf 409s List of 1 409s $ m1: num NA 409s Last weight is NA 409s List of 1 409s $ m1: num NA 409s na.rm: TRUE 409s Weights are not specified (all are 1) 409s List of 1 409s $ m1: num 2.98 409s All weights are 1 409s List of 1 409s $ m1: num 2.98 409s First weight is 5 409s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 409s List of 1 409s $ m1: num 3.45 409s All weights are 0 409s List of 1 409s $ m1: num NA 409s First weight is 8.5 409s List of 1 409s $ m1: num NA 409s First weight is Inf 409s List of 1 409s $ m1: num NA 409s Last weight is Inf 409s List of 1 409s $ m1: num NA 409s Last weight is NA 409s List of 1 409s $ m1: num NA 409s weightedSd()...DONE 409s weightedMad()... 409s mode: integer 409s int [1:15] 0 0 -3 -3 -3 4 3 -3 1 -2 ... 409s add_na: FALSE 409s int [1:15] 0 0 -3 -3 -3 4 3 -3 1 -2 ... 409s na.rm: FALSE 409s Weights are not specified (all are 1) 409s List of 1 409s $ m1: num 4.45 409s All weights are 1 409s List of 1 409s $ m1: num 4.45 409s First weight is 5 409s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 409s List of 1 409s $ m1: num 1.48 409s All weights are 0 409s List of 1 409s $ m1: int NA 409s First weight is 8.5 409s List of 1 409s $ m1: int 0 409s First weight is Inf 409s List of 1 409s $ m1: int 0 409s Last weight is Inf 409s List of 1 409s $ m1: int 0 409s Last weight is NA 409s List of 1 409s $ m1: int NA 409s na.rm: TRUE 409s Weights are not specified (all are 1) 409s List of 1 409s $ m1: num 4.45 409s All weights are 1 409s List of 1 409s $ m1: num 4.45 409s First weight is 5 409s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 409s List of 1 409s $ m1: num 1.48 409s All weights are 0 409s List of 1 409s $ m1: int NA 409s First weight is 8.5 409s List of 1 409s $ m1: int 0 409s First weight is Inf 409s List of 1 409s $ m1: int 0 409s Last weight is Inf 409s List of 1 409s $ m1: int 0 409s Last weight is NA 409s List of 1 409s $ m1: int NA 409s add_na: TRUE 409s int [1:15] 0 0 -3 -3 NA 4 NA -3 1 -2 ... 409s na.rm: FALSE 409s Weights are not specified (all are 1) 409s List of 1 409s $ m1: num NA 409s All weights are 1 409s List of 1 409s $ m1: int NA 409s First weight is 5 409s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 409s List of 1 409s $ m1: int NA 409s All weights are 0 409s List of 1 409s $ m1: int NA 409s First weight is 8.5 409s List of 1 409s $ m1: int 0 409s First weight is Inf 409s List of 1 409s $ m1: int 0 409s Last weight is Inf 409s List of 1 409s $ m1: int 0 409s Last weight is NA 409s List of 1 409s $ m1: int NA 409s na.rm: TRUE 409s Weights are not specified (all are 1) 409s List of 1 409s $ m1: num 2.97 409s All weights are 1 409s List of 1 409s $ m1: num 2.97 409s First weight is 5 409s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 409s List of 1 409s $ m1: num 1.48 409s All weights are 0 409s List of 1 409s $ m1: int NA 409s First weight is 8.5 409s List of 1 409s $ m1: int 0 409s First weight is Inf 409s List of 1 409s $ m1: int 0 409s Last weight is Inf 409s List of 1 409s $ m1: int 0 409s Last weight is NA 409s List of 1 409s $ m1: int NA 409s mode: double 409s num [1:15] -0.141 -4.97 4.109 0.215 -3.278 ... 409s add_na: FALSE 409s num [1:15] -0.141 -4.97 4.109 0.215 -3.278 ... 409s na.rm: FALSE 409s Weights are not specified (all are 1) 409s List of 1 409s $ m1: num 4.65 409s All weights are 1 409s List of 1 409s $ m1: num 4.65 409s First weight is 5 409s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 409s List of 1 409s $ m1: num 2.93 409s All weights are 0 409s List of 1 409s $ m1: num NA 409s First weight is 8.5 409s List of 1 409s $ m1: num 0 409s First weight is Inf 409s List of 1 409s $ m1: num 0 409s Last weight is Inf 409s List of 1 409s $ m1: num 0 409s Last weight is NA 409s List of 1 409s $ m1: num NA 409s na.rm: TRUE 409s Weights are not specified (all are 1) 409s List of 1 409s $ m1: num 4.65 409s All weights are 1 409s List of 1 409s $ m1: num 4.65 409s First weight is 5 409s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 409s List of 1 409s $ m1: num 2.93 409s All weights are 0 409s List of 1 409s $ m1: num NA 409s First weight is 8.5 409s List of 1 409s $ m1: num 0 409s First weight is Inf 409s List of 1 409s $ m1: num 0 409s Last weight is Inf 409s List of 1 409s $ m1: num 0 409s Last weight is NA 409s List of 1 409s $ m1: num NA 409s add_na: TRUE 409s num [1:15] -0.141 -4.97 4.109 0.215 NA ... 409s na.rm: FALSE 409s Weights are not specified (all are 1) 409s List of 1 409s $ m1: num NA 409s All weights are 1 409s List of 1 409s $ m1: num NA 409s First weight is 5 409s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 409s List of 1 409s $ m1: num NA 409s All weights are 0 409s List of 1 409s $ m1: num NA 409s First weight is 8.5 409s List of 1 409s $ m1: num 0 409s First weight is Inf 409s List of 1 409s $ m1: num 0 409s Last weight is Inf 409s List of 1 409s $ m1: num 0 409s Last weight is NA 409s List of 1 409s $ m1: num NA 409s na.rm: TRUE 409s Weights are not specified (all are 1) 409s List of 1 409s $ m1: num 4.52 409s All weights are 1 409s List of 1 409s $ m1: num 4.52 409s First weight is 5 409s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 409s List of 1 409s $ m1: num 2.74 409s All weights are 0 409s List of 1 409s $ m1: num NA 409s First weight is 8.5 409s List of 1 409s $ m1: num 0 409s First weight is Inf 409s List of 1 409s $ m1: num 0 409s Last weight is Inf 409s List of 1 409s $ m1: num 0 409s Last weight is NA 409s List of 1 409s $ m1: num NA 409s weightedMad()...DONE 409s > 409s 409s R version 4.4.3 (2025-02-28) -- "Trophy Case" 409s Copyright (C) 2025 The R Foundation for Statistical Computing 409s Platform: aarch64-unknown-linux-gnu 409s 409s R is free software and comes with ABSOLUTELY NO WARRANTY. 409s You are welcome to redistribute it under certain conditions. 409s Type 'license()' or 'licence()' for distribution details. 409s 409s R is a collaborative project with many contributors. 409s Type 'contributors()' for more information and 409s 'citation()' on how to cite R or R packages in publications. 409s 409s Type 'demo()' for some demos, 'help()' for on-line help, or 409s 'help.start()' for an HTML browser interface to help. 409s Type 'q()' to quit R. 409s 409s > library("matrixStats") 409s > 409s > fcns <- list( 409s + weightedVar = weightedVar, 409s + weightedSd = weightedSd, 409s + weightedMad = weightedMad 409s + ) 409s > 409s > 409s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 409s > # Subsetted tests 409s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 409s > source("utils/validateIndicesFramework.R") 409s > for (name in names(fcns)) { 409s + cat(sprintf("subsetted tests on %s()...\n", name)) 409s + fcn <- fcns[[name]] 409s + 409s + for (mode in c("numeric", "integer")) { 409s + x <- runif(6, min = -6, max = 6) 409s + w <- runif(6, min = 0, max = 6) 409s + storage.mode(x) <- mode 409s + storage.mode(w) <- mode 409s + if (mode == "numeric") w[1] <- Inf 409s + 409s + for (idxs in index_cases) { 409s + validateIndicesTestVector_w(x, w, idxs, 409s + ftest = fcn, fsure = fcn, 409s + na.rm = TRUE) 409s + validateIndicesTestVector_w(x, w, idxs, 409s + ftest = fcn, fsure = fcn, 409s + na.rm = FALSE) 409s + } 409s + } 409s + cat(sprintf("%s()...DONE\n", name)) 409s + } 409s subsetted tests on weightedVar()... 409s weightedVar()...DONE 409s subsetted tests on weightedSd()... 409s weightedSd()...DONE 409s subsetted tests on weightedMad()... 409s weightedMad()...DONE 409s > 409s 409s R version 4.4.3 (2025-02-28) -- "Trophy Case" 409s Copyright (C) 2025 The R Foundation for Statistical Computing 409s Platform: aarch64-unknown-linux-gnu 409s 409s R is free software and comes with ABSOLUTELY NO WARRANTY. 409s You are welcome to redistribute it under certain conditions. 409s Type 'license()' or 'licence()' for distribution details. 409s 409s R is a collaborative project with many contributors. 409s Type 'contributors()' for more information and 409s 'citation()' on how to cite R or R packages in publications. 409s 409s Type 'demo()' for some demos, 'help()' for on-line help, or 409s 'help.start()' for an HTML browser interface to help. 409s Type 'q()' to quit R. 409s 409s > library("matrixStats") 409s > 409s > x_OP_y_R <- function(x, y, OP, na.rm = FALSE) { 409s + if (na.rm) { 409s + xnok <- is.na(x) 409s + ynok <- is.na(y) 409s + anok <- xnok & ynok 409s + unit <- switch(OP, 409s + "+" = 0, 409s + "-" = NA_real_, 409s + "*" = 1, 409s + "/" = NA_real_, 409s + stop("Unknown 'OP' operator: ", OP) 409s + ) 409s + x[xnok] <- unit 409s + y[ynok] <- unit 409s + } 409s + 409s + ans <- switch(OP, 409s + "+" = x + y, 409s + "-" = x - y, 409s + "*" = x * y, 409s + "/" = x / y, 409s + stop("Unknown 'OP' operator: ", OP) 409s + ) 409s + 409s + if (na.rm) { 409s + ans[anok] <- NA_real_ 409s + } 409s + 409s + ans 409s + } # x_OP_y_R() 409s > 409s > 409s > 409s > t_tx_OP_y_R <- function(x, y, OP, na.rm = FALSE) { 409s + t(x_OP_y_R(x = t(x), y = y, OP = OP, na.rm = na.rm)) 409s + } 409s > 409s > 409s > 409s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 409s > # No missing values 409s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 409s > x <- matrix(1:16, nrow = 4, ncol = 4) 409s > y <- 1:nrow(x) 409s > storage.mode(y) <- storage.mode(x) 409s > 409s > for (OP in c("+", "-", "*", "/")) { 409s + for (na.rm in c(FALSE, TRUE)) { 409s + cat(sprintf("OP = '%s', na.rm = %s\n", OP, na.rm)) 409s + 409s + a0 <- x_OP_y_R(x, y, OP, na.rm = na.rm) 409s + a1 <- x_OP_y(x, y, OP, na.rm = na.rm) 409s + str(a1) 409s + stopifnot(all.equal(a1, a0)) 409s + 409s + b0 <- t_tx_OP_y_R(x, y, OP, na.rm = na.rm) 409s + b1 <- t_tx_OP_y(x, y, OP, na.rm = na.rm) 409s + str(b1) 409s + stopifnot(all.equal(b1, b0)) 409s + } 409s + } 409s OP = '+', na.rm = FALSE 409s int [1:4, 1:4] 2 4 6 8 6 8 10 12 10 12 ... 409s int [1:4, 1:4] 2 3 4 5 7 8 9 10 12 13 ... 409s OP = '+', na.rm = TRUE 409s int [1:4, 1:4] 2 4 6 8 6 8 10 12 10 12 ... 409s int [1:4, 1:4] 2 3 4 5 7 8 9 10 12 13 ... 409s OP = '-', na.rm = FALSE 409s int [1:4, 1:4] 0 0 0 0 4 4 4 4 8 8 ... 409s int [1:4, 1:4] 0 1 2 3 3 4 5 6 6 7 ... 409s OP = '-', na.rm = TRUE 409s int [1:4, 1:4] 0 0 0 0 4 4 4 4 8 8 ... 409s int [1:4, 1:4] 0 1 2 3 3 4 5 6 6 7 ... 409s OP = '*', na.rm = FALSE 409s int [1:4, 1:4] 1 4 9 16 5 12 21 32 9 20 ... 409s int [1:4, 1:4] 1 2 3 4 10 12 14 16 27 30 ... 409s OP = '*', na.rm = TRUE 409s int [1:4, 1:4] 1 4 9 16 5 12 21 32 9 20 ... 409s int [1:4, 1:4] 1 2 3 4 10 12 14 16 27 30 ... 409s OP = '/', na.rm = FALSE 409s num [1:4, 1:4] 1 1 1 1 5 ... 409s num [1:4, 1:4] 1 2 3 4 2.5 ... 409s OP = '/', na.rm = TRUE 409s num [1:4, 1:4] 1 1 1 1 5 ... 409s num [1:4, 1:4] 1 2 3 4 2.5 ... 409s > 409s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 409s > # Missing values in x, y, or both. 409s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 409s > for (which in c("x", "y", "both")) { 409s + x <- matrix(1:16, nrow = 4, ncol = 4) 409s + y <- 1:nrow(x) 409s + storage.mode(y) <- storage.mode(x) 409s + 409s + if (which == "x") { 409s + x[3:6] <- NA_real_ 409s + } else if (which == "y") { 409s + y[c(1, 3)] <- NA_real_ 409s + } else if (which == "both") { 409s + x[3:6] <- NA_real_ 409s + y[c(1, 3)] <- NA_real_ 409s + } 409s + 409s + for (OP in c("+", "-", "*", "/")) { 409s + for (na.rm in c(FALSE, TRUE)) { 409s + cat(sprintf("OP = '%s', na.rm = %s\n", OP, na.rm)) 409s + a0 <- x_OP_y_R(x, y, OP, na.rm = na.rm) 409s + a1 <- x_OP_y(x, y, OP, na.rm = na.rm) 409s + str(a1) 409s + stopifnot(all.equal(a1, a0)) 409s + 409s + b0 <- t_tx_OP_y_R(x, y, OP, na.rm = na.rm) 409s + b1 <- t_tx_OP_y(x, y, OP, na.rm = na.rm) 409s + str(b1) 409s + stopifnot(all.equal(b1, b0)) 409s + } 409s + } 409s + } 409s OP = '+', na.rm = FALSE 409s num [1:4, 1:4] 2 4 NA NA NA NA 10 12 10 12 ... 409s num [1:4, 1:4] 2 3 NA NA NA NA 9 10 12 13 ... 409s OP = '+', na.rm = TRUE 409s num [1:4, 1:4] 2 4 3 4 1 2 10 12 10 12 ... 409s num [1:4, 1:4] 2 3 1 1 2 2 9 10 12 13 ... 409s OP = '-', na.rm = FALSE 409s num [1:4, 1:4] 0 0 NA NA NA NA 4 4 8 8 ... 409s num [1:4, 1:4] 0 1 NA NA NA NA 5 6 6 7 ... 409s OP = '-', na.rm = TRUE 409s num [1:4, 1:4] 0 0 NA NA NA NA 4 4 8 8 ... 409s num [1:4, 1:4] 0 1 NA NA NA NA 5 6 6 7 ... 409s OP = '*', na.rm = FALSE 409s num [1:4, 1:4] 1 4 NA NA NA NA 21 32 9 20 ... 409s num [1:4, 1:4] 1 2 NA NA NA NA 14 16 27 30 ... 409s OP = '*', na.rm = TRUE 409s num [1:4, 1:4] 1 4 3 4 1 2 21 32 9 20 ... 409s num [1:4, 1:4] 1 2 1 1 2 2 14 16 27 30 ... 409s OP = '/', na.rm = FALSE 409s num [1:4, 1:4] 1 1 NA NA NA ... 409s num [1:4, 1:4] 1 2 NA NA NA ... 409s OP = '/', na.rm = TRUE 409s num [1:4, 1:4] 1 1 NA NA NA ... 409s num [1:4, 1:4] 1 2 NA NA NA ... 409s OP = '+', na.rm = FALSE 409s num [1:4, 1:4] NA 4 NA 8 NA 8 NA 12 NA 12 ... 409s num [1:4, 1:4] NA NA NA NA 7 8 9 10 NA NA ... 409s OP = '+', na.rm = TRUE 409s num [1:4, 1:4] 1 4 3 8 5 8 7 12 9 12 ... 409s num [1:4, 1:4] 1 2 3 4 7 8 9 10 9 10 ... 409s OP = '-', na.rm = FALSE 409s num [1:4, 1:4] NA 0 NA 0 NA 4 NA 4 NA 8 ... 409s num [1:4, 1:4] NA NA NA NA 3 4 5 6 NA NA ... 409s OP = '-', na.rm = TRUE 409s num [1:4, 1:4] NA 0 NA 0 NA 4 NA 4 NA 8 ... 409s num [1:4, 1:4] NA NA NA NA 3 4 5 6 NA NA ... 409s OP = '*', na.rm = FALSE 409s num [1:4, 1:4] NA 4 NA 16 NA 12 NA 32 NA 20 ... 409s num [1:4, 1:4] NA NA NA NA 10 12 14 16 NA NA ... 409s OP = '*', na.rm = TRUE 409s num [1:4, 1:4] 1 4 3 16 5 12 7 32 9 20 ... 409s num [1:4, 1:4] 1 2 3 4 10 12 14 16 9 10 ... 409s OP = '/', na.rm = FALSE 409s num [1:4, 1:4] NA 1 NA 1 NA 3 NA 2 NA 5 ... 409s num [1:4, 1:4] NA NA NA NA 2.5 3 3.5 4 NA NA ... 409s OP = '/', na.rm = TRUE 409s num [1:4, 1:4] NA 1 NA 1 NA 3 NA 2 NA 5 ... 409s num [1:4, 1:4] NA NA NA NA 2.5 3 3.5 4 NA NA ... 409s OP = '+', na.rm = FALSE 409s num [1:4, 1:4] NA 4 NA NA NA NA NA 12 NA 12 ... 409s num [1:4, 1:4] NA NA NA NA NA NA 9 10 NA NA ... 409s OP = '+', na.rm = TRUE 409s num [1:4, 1:4] 1 4 NA 4 NA 2 7 12 9 12 ... 409s num [1:4, 1:4] 1 2 NA NA 2 2 9 10 9 10 ... 409s OP = '-', na.rm = FALSE 409s num [1:4, 1:4] NA 0 NA NA NA NA NA 4 NA 8 ... 409s num [1:4, 1:4] NA NA NA NA NA NA 5 6 NA NA ... 409s OP = '-', na.rm = TRUE 409s num [1:4, 1:4] NA 0 NA NA NA NA NA 4 NA 8 ... 409s num [1:4, 1:4] NA NA NA NA NA NA 5 6 NA NA ... 409s OP = '*', na.rm = FALSE 409s num [1:4, 1:4] NA 4 NA NA NA NA NA 32 NA 20 ... 409s num [1:4, 1:4] NA NA NA NA NA NA 14 16 NA NA ... 409s OP = '*', na.rm = TRUE 409s num [1:4, 1:4] 1 4 NA 4 NA 2 7 32 9 20 ... 409s num [1:4, 1:4] 1 2 NA NA 2 2 14 16 9 10 ... 409s OP = '/', na.rm = FALSE 409s num [1:4, 1:4] NA 1 NA NA NA NA NA 2 NA 5 ... 409s num [1:4, 1:4] NA NA NA NA NA NA 3.5 4 NA NA ... 409s OP = '/', na.rm = TRUE 409s num [1:4, 1:4] NA 1 NA NA NA NA NA 2 NA 5 ... 409s num [1:4, 1:4] NA NA NA NA NA NA 3.5 4 NA NA ... 409s > 409s > 409s > 409s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 409s > # Length differences 409s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 409s > x <- matrix(1:8, nrow = 2, ncol = 4) 409s > y <- 1:ncol(x) 409s > storage.mode(y) <- storage.mode(x) 409s > 409s > for (OP in c("+", "-", "*", "/")) { 409s + for (na.rm in c(FALSE, TRUE)) { 409s + cat(sprintf("OP = '%s', na.rm = %s\n", OP, na.rm)) 409s + 409s + a0 <- x_OP_y_R(x, y, OP, na.rm = na.rm) 409s + a1 <- x_OP_y(x, y, OP, na.rm = na.rm) 409s + str(a1) 409s + stopifnot(all.equal(a1, a0)) 409s + 409s + b0 <- t_tx_OP_y_R(x, y, OP, na.rm = na.rm) 409s + b1 <- t_tx_OP_y(x, y, OP, na.rm = na.rm) 409s + str(b1) 409s + stopifnot(all.equal(b1, b0)) 409s + } 409s + } 409s OP = '+', na.rm = FALSE 409s int [1:2, 1:4] 2 4 6 8 6 8 10 12 409s int [1:2, 1:4] 2 3 5 6 8 9 11 12 409s OP = '+', na.rm = TRUE 409s int [1:2, 1:4] 2 4 6 8 6 8 10 12 409s int [1:2, 1:4] 2 3 5 6 8 9 11 12 409s OP = '-', na.rm = FALSE 409s int [1:2, 1:4] 0 0 0 0 4 4 4 4 409s int [1:2, 1:4] 0 1 1 2 2 3 3 4 409s OP = '-', na.rm = TRUE 409s int [1:2, 1:4] 0 0 0 0 4 4 4 4 409s int [1:2, 1:4] 0 1 1 2 2 3 3 4 409s OP = '*', na.rm = FALSE 409s int [1:2, 1:4] 1 4 9 16 5 12 21 32 409s int [1:2, 1:4] 1 2 6 8 15 18 28 32 409s OP = '*', na.rm = TRUE 409s int [1:2, 1:4] 1 4 9 16 5 12 21 32 409s int [1:2, 1:4] 1 2 6 8 15 18 28 32 409s OP = '/', na.rm = FALSE 409s num [1:2, 1:4] 1 1 1 1 5 ... 409s num [1:2, 1:4] 1 2 1.5 2 1.67 ... 409s OP = '/', na.rm = TRUE 409s num [1:2, 1:4] 1 1 1 1 5 ... 409s num [1:2, 1:4] 1 2 1.5 2 1.67 ... 409s > 409s > 409s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 409s > # All missing values 409s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 409s > xs <- list( 409s + A = matrix(1:2, nrow = 2, ncol = 2), 409s + B = matrix(NA_integer_, nrow = 2, ncol = 2) 409s + ) 409s > ys <- list( 409s + A = 1L, 409s + B = NA_integer_ 409s + ) 409s > 409s > for (x in xs) { 409s + for (y in ys) { 409s + for (mode in c("logical", "integer", "double")) { 409s + storage.mode(x) <- mode 409s + storage.mode(y) <- mode 409s + str(list(x = x, y = y)) 409s + 409s + for (OP in c("+", "-", "*", "/")) { 409s + for (na.rm in c(FALSE, TRUE)) { 409s + cat(sprintf("mode = '%s', OP = '%s', na.rm = %s\n", mode, OP, na.rm)) 409s + suppressWarnings({ 409s + z0 <- x_OP_y_R(x, y, OP, na.rm = na.rm) 409s + z <- x_OP_y(x, y, OP, na.rm = na.rm) 409s + }) 409s + str(z) 409s + stopifnot(all.equal(z, z0)) 409s + } 409s + } 409s + } # for (mode ...) 409s + } # for (y ...) 409s + } # for (x ...) 409s List of 2 409s $ x: logi [1:2, 1:2] TRUE TRUE TRUE TRUE 409s $ y: logi TRUE 409s mode = 'logical', OP = '+', na.rm = FALSE 409s int [1:2, 1:2] 2 2 2 2 409s mode = 'logical', OP = '+', na.rm = TRUE 409s int [1:2, 1:2] 2 2 2 2 409s mode = 'logical', OP = '-', na.rm = FALSE 409s int [1:2, 1:2] 0 0 0 0 409s mode = 'logical', OP = '-', na.rm = TRUE 409s int [1:2, 1:2] 0 0 0 0 409s mode = 'logical', OP = '*', na.rm = FALSE 409s int [1:2, 1:2] 1 1 1 1 409s mode = 'logical', OP = '*', na.rm = TRUE 409s int [1:2, 1:2] 1 1 1 1 409s mode = 'logical', OP = '/', na.rm = FALSE 409s num [1:2, 1:2] 1 1 1 1 409s mode = 'logical', OP = '/', na.rm = TRUE 409s num [1:2, 1:2] 1 1 1 1 409s List of 2 409s $ x: int [1:2, 1:2] 1 1 1 1 409s $ y: int 1 409s mode = 'integer', OP = '+', na.rm = FALSE 409s int [1:2, 1:2] 2 2 2 2 409s mode = 'integer', OP = '+', na.rm = TRUE 409s int [1:2, 1:2] 2 2 2 2 409s mode = 'integer', OP = '-', na.rm = FALSE 409s int [1:2, 1:2] 0 0 0 0 409s mode = 'integer', OP = '-', na.rm = TRUE 409s int [1:2, 1:2] 0 0 0 0 409s mode = 'integer', OP = '*', na.rm = FALSE 409s int [1:2, 1:2] 1 1 1 1 409s mode = 'integer', OP = '*', na.rm = TRUE 409s int [1:2, 1:2] 1 1 1 1 409s mode = 'integer', OP = '/', na.rm = FALSE 409s num [1:2, 1:2] 1 1 1 1 409s mode = 'integer', OP = '/', na.rm = TRUE 409s num [1:2, 1:2] 1 1 1 1 409s List of 2 409s $ x: num [1:2, 1:2] 1 1 1 1 409s $ y: num 1 409s mode = 'double', OP = '+', na.rm = FALSE 409s num [1:2, 1:2] 2 2 2 2 409s mode = 'double', OP = '+', na.rm = TRUE 409s num [1:2, 1:2] 2 2 2 2 409s mode = 'double', OP = '-', na.rm = FALSE 409s num [1:2, 1:2] 0 0 0 0 409s mode = 'double', OP = '-', na.rm = TRUE 409s num [1:2, 1:2] 0 0 0 0 409s mode = 'double', OP = '*', na.rm = FALSE 409s num [1:2, 1:2] 1 1 1 1 409s mode = 'double', OP = '*', na.rm = TRUE 409s num [1:2, 1:2] 1 1 1 1 409s mode = 'double', OP = '/', na.rm = FALSE 409s num [1:2, 1:2] 1 1 1 1 409s mode = 'double', OP = '/', na.rm = TRUE 409s num [1:2, 1:2] 1 1 1 1 409s List of 2 409s $ x: logi [1:2, 1:2] TRUE TRUE TRUE TRUE 409s $ y: logi NA 409s mode = 'logical', OP = '+', na.rm = FALSE 409s int [1:2, 1:2] NA NA NA NA 409s mode = 'logical', OP = '+', na.rm = TRUE 409s int [1:2, 1:2] 1 1 1 1 409s mode = 'logical', OP = '-', na.rm = FALSE 409s int [1:2, 1:2] NA NA NA NA 409s mode = 'logical', OP = '-', na.rm = TRUE 409s int [1:2, 1:2] NA NA NA NA 409s mode = 'logical', OP = '*', na.rm = FALSE 409s int [1:2, 1:2] NA NA NA NA 409s mode = 'logical', OP = '*', na.rm = TRUE 409s int [1:2, 1:2] 1 1 1 1 409s mode = 'logical', OP = '/', na.rm = FALSE 409s num [1:2, 1:2] NA NA NA NA 409s mode = 'logical', OP = '/', na.rm = TRUE 409s num [1:2, 1:2] NA NA NA NA 409s List of 2 409s $ x: int [1:2, 1:2] 1 1 1 1 409s $ y: int NA 409s mode = 'integer', OP = '+', na.rm = FALSE 409s int [1:2, 1:2] NA NA NA NA 409s mode = 'integer', OP = '+', na.rm = TRUE 409s int [1:2, 1:2] 1 1 1 1 409s mode = 'integer', OP = '-', na.rm = FALSE 409s int [1:2, 1:2] NA NA NA NA 409s mode = 'integer', OP = '-', na.rm = TRUE 409s int [1:2, 1:2] NA NA NA NA 409s mode = 'integer', OP = '*', na.rm = FALSE 409s int [1:2, 1:2] NA NA NA NA 409s mode = 'integer', OP = '*', na.rm = TRUE 409s int [1:2, 1:2] 1 1 1 1 409s mode = 'integer', OP = '/', na.rm = FALSE 409s num [1:2, 1:2] NA NA NA NA 409s mode = 'integer', OP = '/', na.rm = TRUE 409s num [1:2, 1:2] NA NA NA NA 409s List of 2 409s $ x: num [1:2, 1:2] 1 1 1 1 409s $ y: num NA 409s mode = 'double', OP = '+', na.rm = FALSE 409s num [1:2, 1:2] NA NA NA NA 409s mode = 'double', OP = '+', na.rm = TRUE 409s num [1:2, 1:2] 1 1 1 1 409s mode = 'double', OP = '-', na.rm = FALSE 409s num [1:2, 1:2] NA NA NA NA 409s mode = 'double', OP = '-', na.rm = TRUE 409s num [1:2, 1:2] NA NA NA NA 409s mode = 'double', OP = '*', na.rm = FALSE 409s num [1:2, 1:2] NA NA NA NA 409s mode = 'double', OP = '*', na.rm = TRUE 409s num [1:2, 1:2] 1 1 1 1 409s mode = 'double', OP = '/', na.rm = FALSE 409s num [1:2, 1:2] NA NA NA NA 409s mode = 'double', OP = '/', na.rm = TRUE 409s num [1:2, 1:2] NA NA NA NA 409s List of 2 409s $ x: logi [1:2, 1:2] NA NA NA NA 409s $ y: logi TRUE 409s mode = 'logical', OP = '+', na.rm = FALSE 409s int [1:2, 1:2] NA NA NA NA 409s mode = 'logical', OP = '+', na.rm = TRUE 409s int [1:2, 1:2] 1 1 1 1 409s mode = 'logical', OP = '-', na.rm = FALSE 409s int [1:2, 1:2] NA NA NA NA 409s mode = 'logical', OP = '-', na.rm = TRUE 409s int [1:2, 1:2] NA NA NA NA 409s mode = 'logical', OP = '*', na.rm = FALSE 409s int [1:2, 1:2] NA NA NA NA 409s mode = 'logical', OP = '*', na.rm = TRUE 409s int [1:2, 1:2] 1 1 1 1 409s mode = 'logical', OP = '/', na.rm = FALSE 409s num [1:2, 1:2] NA NA NA NA 409s mode = 'logical', OP = '/', na.rm = TRUE 409s num [1:2, 1:2] NA NA NA NA 409s List of 2 409s $ x: int [1:2, 1:2] NA NA NA NA 409s $ y: int 1 409s mode = 'integer', OP = '+', na.rm = FALSE 409s int [1:2, 1:2] NA NA NA NA 409s mode = 'integer', OP = '+', na.rm = TRUE 409s int [1:2, 1:2] 1 1 1 1 409s mode = 'integer', OP = '-', na.rm = FALSE 409s int [1:2, 1:2] NA NA NA NA 409s mode = 'integer', OP = '-', na.rm = TRUE 409s int [1:2, 1:2] NA NA NA NA 409s mode = 'integer', OP = '*', na.rm = FALSE 409s int [1:2, 1:2] NA NA NA NA 409s mode = 'integer', OP = '*', na.rm = TRUE 409s int [1:2, 1:2] 1 1 1 1 409s mode = 'integer', OP = '/', na.rm = FALSE 409s num [1:2, 1:2] NA NA NA NA 409s mode = 'integer', OP = '/', na.rm = TRUE 409s num [1:2, 1:2] NA NA NA NA 409s List of 2 409s $ x: num [1:2, 1:2] NA NA NA NA 409s $ y: num 1 409s mode = 'double', OP = '+', na.rm = FALSE 409s num [1:2, 1:2] NA NA NA NA 409s mode = 'double', OP = '+', na.rm = TRUE 409s num [1:2, 1:2] 1 1 1 1 409s mode = 'double', OP = '-', na.rm = FALSE 409s num [1:2, 1:2] NA NA NA NA 409s mode = 'double', OP = '-', na.rm = TRUE 409s num [1:2, 1:2] NA NA NA NA 409s mode = 'double', OP = '*', na.rm = FALSE 409s num [1:2, 1:2] NA NA NA NA 409s mode = 'double', OP = '*', na.rm = TRUE 409s num [1:2, 1:2] 1 1 1 1 409s mode = 'double', OP = '/', na.rm = FALSE 409s num [1:2, 1:2] NA NA NA NA 409s mode = 'double', OP = '/', na.rm = TRUE 409s num [1:2, 1:2] NA NA NA NA 409s List of 2 409s $ x: logi [1:2, 1:2] NA NA NA NA 409s $ y: logi NA 409s mode = 'logical', OP = '+', na.rm = FALSE 409s int [1:2, 1:2] NA NA NA NA 409s mode = 'logical', OP = '+', na.rm = TRUE 409s int [1:2, 1:2] NA NA NA NA 409s mode = 'logical', OP = '-', na.rm = FALSE 409s int [1:2, 1:2] NA NA NA NA 409s mode = 'logical', OP = '-', na.rm = TRUE 409s int [1:2, 1:2] NA NA NA NA 409s mode = 'logical', OP = '*', na.rm = FALSE 409s int [1:2, 1:2] NA NA NA NA 409s mode = 'logical', OP = '*', na.rm = TRUE 409s int [1:2, 1:2] NA NA NA NA 409s mode = 'logical', OP = '/', na.rm = FALSE 409s num [1:2, 1:2] NA NA NA NA 409s mode = 'logical', OP = '/', na.rm = TRUE 409s num [1:2, 1:2] NA NA NA NA 409s List of 2 409s $ x: int [1:2, 1:2] NA NA NA NA 409s $ y: int NA 409s mode = 'integer', OP = '+', na.rm = FALSE 409s int [1:2, 1:2] NA NA NA NA 409s mode = 'integer', OP = '+', na.rm = TRUE 409s int [1:2, 1:2] NA NA NA NA 409s mode = 'integer', OP = '-', na.rm = FALSE 409s int [1:2, 1:2] NA NA NA NA 409s mode = 'integer', OP = '-', na.rm = TRUE 409s int [1:2, 1:2] NA NA NA NA 409s mode = 'integer', OP = '*', na.rm = FALSE 409s int [1:2, 1:2] NA NA NA NA 409s mode = 'integer', OP = '*', na.rm = TRUE 409s int [1:2, 1:2] NA NA NA NA 409s mode = 'integer', OP = '/', na.rm = FALSE 409s num [1:2, 1:2] NA NA NA NA 409s mode = 'integer', OP = '/', na.rm = TRUE 409s num [1:2, 1:2] NA NA NA NA 409s List of 2 409s $ x: num [1:2, 1:2] NA NA NA NA 409s $ y: num NA 409s mode = 'double', OP = '+', na.rm = FALSE 409s num [1:2, 1:2] NA NA NA NA 409s mode = 'double', OP = '+', na.rm = TRUE 409s num [1:2, 1:2] NA NA NA NA 409s mode = 'double', OP = '-', na.rm = FALSE 409s num [1:2, 1:2] NA NA NA NA 409s mode = 'double', OP = '-', na.rm = TRUE 409s num [1:2, 1:2] NA NA NA NA 409s mode = 'double', OP = '*', na.rm = FALSE 409s num [1:2, 1:2] NA NA NA NA 409s mode = 'double', OP = '*', na.rm = TRUE 409s num [1:2, 1:2] NA NA NA NA 409s mode = 'double', OP = '/', na.rm = FALSE 409s num [1:2, 1:2] NA NA NA NA 409s mode = 'double', OP = '/', na.rm = TRUE 409s num [1:2, 1:2] NA NA NA NA 409s > 410s 410s R version 4.4.3 (2025-02-28) -- "Trophy Case" 410s Copyright (C) 2025 The R Foundation for Statistical Computing 410s Platform: aarch64-unknown-linux-gnu 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 410s > library("matrixStats") 410s > 410s > x_OP_y_R <- function(x, y, OP, na.rm = FALSE) { 410s + if (na.rm) { 410s + xnok <- is.na(x) 410s + ynok <- is.na(y) 410s + anok <- xnok & ynok 410s + unit <- switch(OP, 410s + "+" = 0, 410s + "-" = NA_real_, 410s + "*" = 1, 410s + "/" = NA_real_, 410s + stop("Unknown 'OP' operator: ", OP) 410s + ) 410s + x[xnok] <- unit 410s + y[ynok] <- unit 410s + } 410s + 410s + ans <- switch(OP, 410s + "+" = x + y, 410s + "-" = x - y, 410s + "*" = x * y, 410s + "/" = x / y, 410s + stop("Unknown 'OP' operator: ", OP) 410s + ) 410s + 410s + if (na.rm) { 410s + ans[anok] <- NA_real_ 410s + } 410s + 410s + ans 410s + } # x_OP_y_R() 410s > 410s > 410s > t_tx_OP_y_R <- function(x, y, OP, na.rm = FALSE) { 410s + t(x_OP_y_R(x = t(x), y = y, OP = OP, na.rm = na.rm)) 410s + } 410s > 410s > 410s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 410s > # Subsetted tests 410s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 410s > source("utils/validateIndicesFramework.R") 410s > for (OP in c("+", "-", "*", "/")) { 410s + for (mode in c("numeric", "integer", "logical")) { 410s + x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6L, ncol = 6L) 410s + y <- runif(6, min = 0, max = 6) 410s + storage.mode(x) <- mode 410s + storage.mode(y) <- mode 410s + if (mode == "numeric") y[1] <- Inf 410s + 410s + for (xrows in index_cases) { 410s + for (xcols in index_cases) { 410s + if (is.null(xrows)) xrows <- seq_len(nrow(x)) 410s + if (is.null(xcols)) xcols <- seq_len(ncol(x)) 410s + 410s + for (yidxs in list(xrows, xcols)) { 410s + for (na.rm in c(TRUE, FALSE)) { 410s + 410s + suppressWarnings({ 410s + actual <- tryCatch( 410s + x_OP_y(x, y, OP, xrows = xrows, xcols = xcols, yidxs = yidxs, 410s + na.rm = na.rm), 410s + error = function(c) "error" 410s + ) 410s + 410s + expect <- tryCatch( 410s + x_OP_y_R(x[xrows, xcols, drop = FALSE], y[yidxs], OP, 410s + na.rm = na.rm), 410s + error = function(c) "error" 410s + ) 410s + }) 410s + stopifnot(all.equal(as.vector(actual), as.vector(expect))) 410s + 410s + suppressWarnings({ 410s + actual <- tryCatch( 410s + t_tx_OP_y(x, y, OP, xrows = xrows, xcols = xcols, yidxs = yidxs, 410s + na.rm = na.rm), 410s + error = function(c) "error" 410s + ) 410s + 410s + expect <- tryCatch( 410s + t_tx_OP_y_R(x[xrows, xcols, drop = FALSE], y[yidxs], OP, 410s + na.rm = na.rm), 410s + error = function(c) "error" 410s + ) 410s + }) 410s + stopifnot(all.equal(as.vector(actual), as.vector(expect))) 410s + } 410s + } 410s + } 410s + } 410s + } 410s + } 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: aarch64-unknown-linux-gnu 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 > ## These tests need to be last of all tests, otherwise 414s > ## covr::package_coverage() gives an error. 414s > cat("1. Loading package\n") 414s 1. Loading package 414s > loadNamespace("matrixStats") 414s 414s > stopifnot("matrixStats" %in% loadedNamespaces()) 414s > 414s > cat("2. Unloading package\n") 414s 2. Unloading package 414s > unloadNamespace("matrixStats") 414s > stopifnot(!"matrixStats" %in% loadedNamespaces()) 414s > 414s > if (FALSE) { 414s + ## 'covr' gives "Error in library("matrixStats") : 414s + ## there is no package called 'matrixStats'" here, cf. 414s + ## https://travis-ci.org/HenrikBengtsson/matrixStats/builds/48015577 414s + 414s + cat("3. Attaching package\n") 414s + library("matrixStats") 414s + stopifnot("package:matrixStats" %in% search()) 414s + 414s + cat("4. Detaching package\n") 414s + detach("package:matrixStats") 414s + stopifnot(!"package:matrixStats" %in% search()) 414s + stopifnot("matrixStats" %in% loadedNamespaces()) 414s + 414s + cat("5. Unloading package\n") 414s + unloadNamespace("matrixStats") 414s + stopifnot(!"matrixStats" %in% loadedNamespaces()) 414s + 414s + cat("6. Attaching package (again)\n") 414s + library("matrixStats") 414s + stopifnot("package:matrixStats" %in% search()) 414s + 414s + cat("7. Detaching package (again)\n") 414s + detach("package:matrixStats") 414s + stopifnot(!"package:matrixStats" %in% search()) 414s + stopifnot("matrixStats" %in% loadedNamespaces()) 414s + } 414s > 414s > cat("7. DONE\n") 414s 7. DONE 414s > 414s autopkgtest [15:46:43]: test run-unit-test: -----------------------] 415s autopkgtest [15:46:44]: test run-unit-test: - - - - - - - - - - results - - - - - - - - - - 415s run-unit-test PASS 415s autopkgtest [15:46:44]: test pkg-r-autopkgtest: preparing testbed 612s autopkgtest [15:50:01]: testbed dpkg architecture: arm64 612s autopkgtest [15:50:01]: testbed apt version: 2.9.33 613s autopkgtest [15:50:02]: @@@@@@@@@@@@@@@@@@@@ test bed setup 613s autopkgtest [15:50:02]: testbed release detected to be: plucky 614s autopkgtest [15:50:03]: updating testbed package index (apt update) 614s Get:1 http://ftpmaster.internal/ubuntu plucky-proposed InRelease [126 kB] 615s Hit:2 http://ftpmaster.internal/ubuntu plucky InRelease 615s Hit:3 http://ftpmaster.internal/ubuntu plucky-updates InRelease 615s Hit:4 http://ftpmaster.internal/ubuntu plucky-security InRelease 615s Get:5 http://ftpmaster.internal/ubuntu plucky-proposed/multiverse Sources [15.8 kB] 615s Get:6 http://ftpmaster.internal/ubuntu plucky-proposed/main Sources [99.7 kB] 615s Get:7 http://ftpmaster.internal/ubuntu plucky-proposed/universe Sources [379 kB] 616s Get:8 http://ftpmaster.internal/ubuntu plucky-proposed/main arm64 Packages [111 kB] 616s Get:9 http://ftpmaster.internal/ubuntu plucky-proposed/main arm64 c-n-f Metadata [1856 B] 616s Get:10 http://ftpmaster.internal/ubuntu plucky-proposed/restricted arm64 c-n-f Metadata [116 B] 616s Get:11 http://ftpmaster.internal/ubuntu plucky-proposed/universe arm64 Packages [324 kB] 616s Get:12 http://ftpmaster.internal/ubuntu plucky-proposed/universe arm64 c-n-f Metadata [14.7 kB] 616s Get:13 http://ftpmaster.internal/ubuntu plucky-proposed/multiverse arm64 Packages [4948 B] 616s Get:14 http://ftpmaster.internal/ubuntu plucky-proposed/multiverse arm64 c-n-f Metadata [268 B] 616s Fetched 1078 kB in 2s (564 kB/s) 618s Reading package lists... 618s Reading package lists... 619s Building dependency tree... 619s Reading state information... 619s Calculating upgrade... 619s Calculating upgrade... 620s The following packages will be upgraded: 620s pinentry-curses python3-jinja2 strace 620s 3 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 620s Need to get 647 kB of archives. 620s After this operation, 11.3 kB of additional disk space will be used. 620s Get:1 http://ftpmaster.internal/ubuntu plucky/main arm64 strace arm64 6.13+ds-1ubuntu1 [499 kB] 621s Get:2 http://ftpmaster.internal/ubuntu plucky/main arm64 pinentry-curses arm64 1.3.1-2ubuntu3 [39.2 kB] 621s Get:3 http://ftpmaster.internal/ubuntu plucky/main arm64 python3-jinja2 all 3.1.5-2ubuntu1 [109 kB] 622s Fetched 647 kB in 1s (538 kB/s) 622s (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 ... 117701 files and directories currently installed.) 622s Preparing to unpack .../strace_6.13+ds-1ubuntu1_arm64.deb ... 622s Unpacking strace (6.13+ds-1ubuntu1) over (6.11-0ubuntu1) ... 622s Preparing to unpack .../pinentry-curses_1.3.1-2ubuntu3_arm64.deb ... 622s Unpacking pinentry-curses (1.3.1-2ubuntu3) over (1.3.1-2ubuntu2) ... 622s Preparing to unpack .../python3-jinja2_3.1.5-2ubuntu1_all.deb ... 622s Unpacking python3-jinja2 (3.1.5-2ubuntu1) over (3.1.5-2) ... 622s Setting up pinentry-curses (1.3.1-2ubuntu3) ... 622s Setting up python3-jinja2 (3.1.5-2ubuntu1) ... 623s Setting up strace (6.13+ds-1ubuntu1) ... 623s Processing triggers for man-db (2.13.0-1) ... 623s Reading package lists... 624s Building dependency tree... 624s Reading state information... 624s Solving dependencies... 625s The following packages will be REMOVED: 625s libnsl2* libpython3.12-minimal* libpython3.12-stdlib* libpython3.12t64* 625s libunwind8* linux-headers-6.11.0-8* linux-headers-6.11.0-8-generic* 625s linux-image-6.11.0-8-generic* linux-modules-6.11.0-8-generic* 625s linux-tools-6.11.0-8* linux-tools-6.11.0-8-generic* 625s 0 upgraded, 0 newly installed, 11 to remove and 5 not upgraded. 625s After this operation, 267 MB disk space will be freed. 625s (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 ... 117701 files and directories currently installed.) 625s Removing linux-tools-6.11.0-8-generic (6.11.0-8.8) ... 625s Removing linux-tools-6.11.0-8 (6.11.0-8.8) ... 625s Removing libpython3.12t64:arm64 (3.12.9-1) ... 625s Removing libpython3.12-stdlib:arm64 (3.12.9-1) ... 625s Removing libnsl2:arm64 (1.3.0-3build3) ... 625s Removing libpython3.12-minimal:arm64 (3.12.9-1) ... 625s Removing libunwind8:arm64 (1.6.2-3.1) ... 625s Removing linux-headers-6.11.0-8-generic (6.11.0-8.8) ... 626s Removing linux-headers-6.11.0-8 (6.11.0-8.8) ... 627s Removing linux-image-6.11.0-8-generic (6.11.0-8.8) ... 628s I: /boot/vmlinuz.old is now a symlink to vmlinuz-6.14.0-10-generic 628s I: /boot/initrd.img.old is now a symlink to initrd.img-6.14.0-10-generic 628s /etc/kernel/postrm.d/initramfs-tools: 628s update-initramfs: Deleting /boot/initrd.img-6.11.0-8-generic 628s /etc/kernel/postrm.d/zz-flash-kernel: 628s flash-kernel: Kernel 6.11.0-8-generic has been removed. 628s flash-kernel: A higher version (6.14.0-10-generic) is still installed, no reflashing required. 628s /etc/kernel/postrm.d/zz-update-grub: 628s Sourcing file `/etc/default/grub' 628s Sourcing file `/etc/default/grub.d/50-cloudimg-settings.cfg' 628s Generating grub configuration file ... 628s Found linux image: /boot/vmlinuz-6.14.0-10-generic 628s Found initrd image: /boot/initrd.img-6.14.0-10-generic 629s Warning: os-prober will not be executed to detect other bootable partitions. 629s Systems on them will not be added to the GRUB boot configuration. 629s Check GRUB_DISABLE_OS_PROBER documentation entry. 629s Adding boot menu entry for UEFI Firmware Settings ... 629s done 629s Removing linux-modules-6.11.0-8-generic (6.11.0-8.8) ... 629s Processing triggers for libc-bin (2.41-1ubuntu1) ... 629s (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 ... 81650 files and directories currently installed.) 629s Purging configuration files for linux-image-6.11.0-8-generic (6.11.0-8.8) ... 629s Purging configuration files for libpython3.12-minimal:arm64 (3.12.9-1) ... 630s Purging configuration files for linux-modules-6.11.0-8-generic (6.11.0-8.8) ... 630s autopkgtest [15:50:19]: upgrading testbed (apt dist-upgrade and autopurge) 630s Reading package lists... 630s Building dependency tree... 630s Reading state information... 631s Calculating upgrade...Starting pkgProblemResolver with broken count: 0 631s Starting 2 pkgProblemResolver with broken count: 0 631s Done 632s Entering ResolveByKeep 632s 632s Calculating upgrade... 633s The following packages will be upgraded: 633s libc-bin libc-dev-bin libc6 libc6-dev locales 633s 5 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 633s Need to get 9530 kB of archives. 633s After this operation, 0 B of additional disk space will be used. 633s Get:1 http://ftpmaster.internal/ubuntu plucky-proposed/main arm64 libc6-dev arm64 2.41-1ubuntu2 [1750 kB] 636s Get:2 http://ftpmaster.internal/ubuntu plucky-proposed/main arm64 libc-dev-bin arm64 2.41-1ubuntu2 [24.0 kB] 636s Get:3 http://ftpmaster.internal/ubuntu plucky-proposed/main arm64 libc6 arm64 2.41-1ubuntu2 [2910 kB] 639s Get:4 http://ftpmaster.internal/ubuntu plucky-proposed/main arm64 libc-bin arm64 2.41-1ubuntu2 [600 kB] 639s Get:5 http://ftpmaster.internal/ubuntu plucky-proposed/main arm64 locales all 2.41-1ubuntu2 [4246 kB] 645s Preconfiguring packages ... 645s Fetched 9530 kB in 12s (805 kB/s) 645s (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 ... 81647 files and directories currently installed.) 645s Preparing to unpack .../libc6-dev_2.41-1ubuntu2_arm64.deb ... 645s Unpacking libc6-dev:arm64 (2.41-1ubuntu2) over (2.41-1ubuntu1) ... 646s Preparing to unpack .../libc-dev-bin_2.41-1ubuntu2_arm64.deb ... 646s Unpacking libc-dev-bin (2.41-1ubuntu2) over (2.41-1ubuntu1) ... 646s Preparing to unpack .../libc6_2.41-1ubuntu2_arm64.deb ... 646s Unpacking libc6:arm64 (2.41-1ubuntu2) over (2.41-1ubuntu1) ... 646s Setting up libc6:arm64 (2.41-1ubuntu2) ... 646s (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 ... 81647 files and directories currently installed.) 646s Preparing to unpack .../libc-bin_2.41-1ubuntu2_arm64.deb ... 646s Unpacking libc-bin (2.41-1ubuntu2) over (2.41-1ubuntu1) ... 646s Setting up libc-bin (2.41-1ubuntu2) ... 647s (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 ... 81647 files and directories currently installed.) 647s Preparing to unpack .../locales_2.41-1ubuntu2_all.deb ... 647s Unpacking locales (2.41-1ubuntu2) over (2.41-1ubuntu1) ... 647s Setting up locales (2.41-1ubuntu2) ... 648s Generating locales (this might take a while)... 649s en_US.UTF-8... done 649s Generation complete. 649s Setting up libc-dev-bin (2.41-1ubuntu2) ... 649s Setting up libc6-dev:arm64 (2.41-1ubuntu2) ... 649s Processing triggers for man-db (2.13.0-1) ... 650s Processing triggers for systemd (257.3-1ubuntu3) ... 651s Reading package lists... 652s Building dependency tree... 652s Reading state information... 652s Starting pkgProblemResolver with broken count: 0 652s Starting 2 pkgProblemResolver with broken count: 0 652s Done 653s Solving dependencies... 653s 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 653s autopkgtest [15:50:42]: rebooting testbed after setup commands that affected boot 688s autopkgtest-virt-ssh: WARNING: ssh connection failed. Retrying in 3 seconds... 698s Reading package lists... 699s Building dependency tree... 699s Reading state information... 699s Starting pkgProblemResolver with broken count: 0 699s Starting 2 pkgProblemResolver with broken count: 0 699s Done 700s The following NEW packages will be installed: 700s build-essential cpp cpp-14 cpp-14-aarch64-linux-gnu cpp-aarch64-linux-gnu 700s dctrl-tools fontconfig fontconfig-config fonts-dejavu-core fonts-dejavu-mono 700s fonts-glyphicons-halflings fonts-mathjax g++ g++-14 g++-14-aarch64-linux-gnu 700s g++-aarch64-linux-gnu gcc gcc-14 gcc-14-aarch64-linux-gnu 700s gcc-aarch64-linux-gnu gfortran gfortran-14 gfortran-14-aarch64-linux-gnu 700s gfortran-aarch64-linux-gnu icu-devtools libasan8 libblas-dev libblas3 700s libbz2-dev libcairo2 libcc1-0 libdatrie1 libdeflate-dev libdeflate0 700s libfontconfig1 libgcc-14-dev libgfortran-14-dev libgfortran5 libgomp1 700s libgraphite2-3 libharfbuzz0b libhwasan0 libice6 libicu-dev libisl23 libitm1 700s libjbig0 libjpeg-dev libjpeg-turbo8 libjpeg-turbo8-dev libjpeg8 libjpeg8-dev 700s libjs-bootstrap libjs-highlight.js libjs-jquery libjs-jquery-datatables 700s libjs-mathjax liblapack-dev liblapack3 liblerc4 liblsan0 liblzma-dev libmpc3 700s libncurses-dev libpango-1.0-0 libpangocairo-1.0-0 libpangoft2-1.0-0 700s libpaper-utils libpaper2 libpcre2-16-0 libpcre2-32-0 libpcre2-dev 700s libpcre2-posix3 libpixman-1-0 libpkgconf3 libpng-dev libreadline-dev 700s libsharpyuv0 libsm6 libstdc++-14-dev libtcl8.6 libthai-data libthai0 700s libtiff6 libtirpc-dev libtk8.6 libtsan2 libubsan1 libwebp7 libxcb-render0 700s libxcb-shm0 libxft2 libxrender1 libxss1 libxt6t64 node-normalize.css 700s pkg-r-autopkgtest pkgconf pkgconf-bin r-base-core r-base-dev 700s r-cran-base64enc r-cran-cli r-cran-colorspace r-cran-commonmark 700s r-cran-evaluate r-cran-fansi r-cran-farver r-cran-ggplot2 r-cran-glue 700s r-cran-gtable r-cran-highr r-cran-isoband r-cran-knitr r-cran-labeling 700s r-cran-lattice r-cran-lifecycle r-cran-magrittr r-cran-markdown r-cran-mass 700s r-cran-matrix r-cran-matrixstats r-cran-mgcv r-cran-munsell r-cran-nlme 700s r-cran-pillar r-cran-pkgconfig r-cran-r6 r-cran-rcolorbrewer r-cran-rlang 700s r-cran-scales r-cran-tibble r-cran-utf8 r-cran-vctrs r-cran-viridislite 700s r-cran-withr r-cran-xfun r-cran-yaml unzip x11-common xdg-utils zip 700s zlib1g-dev 700s 0 upgraded, 143 newly installed, 0 to remove and 0 not upgraded. 700s Need to get 172 MB of archives. 700s After this operation, 518 MB of additional disk space will be used. 700s Get:1 http://ftpmaster.internal/ubuntu plucky/main arm64 libisl23 arm64 0.27-1 [676 kB] 701s Get:2 http://ftpmaster.internal/ubuntu plucky/main arm64 libmpc3 arm64 1.3.1-1build2 [56.8 kB] 702s Get:3 http://ftpmaster.internal/ubuntu plucky/main arm64 cpp-14-aarch64-linux-gnu arm64 14.2.0-17ubuntu3 [10.6 MB] 714s Get:4 http://ftpmaster.internal/ubuntu plucky/main arm64 cpp-14 arm64 14.2.0-17ubuntu3 [1028 B] 714s Get:5 http://ftpmaster.internal/ubuntu plucky/main arm64 cpp-aarch64-linux-gnu arm64 4:14.2.0-1ubuntu1 [5558 B] 714s Get:6 http://ftpmaster.internal/ubuntu plucky/main arm64 cpp arm64 4:14.2.0-1ubuntu1 [22.4 kB] 714s Get:7 http://ftpmaster.internal/ubuntu plucky/main arm64 libcc1-0 arm64 15-20250222-0ubuntu1 [44.2 kB] 714s Get:8 http://ftpmaster.internal/ubuntu plucky/main arm64 libgomp1 arm64 15-20250222-0ubuntu1 [146 kB] 714s Get:9 http://ftpmaster.internal/ubuntu plucky/main arm64 libitm1 arm64 15-20250222-0ubuntu1 [28.0 kB] 714s Get:10 http://ftpmaster.internal/ubuntu plucky/main arm64 libasan8 arm64 15-20250222-0ubuntu1 [2924 kB] 717s Get:11 http://ftpmaster.internal/ubuntu plucky/main arm64 liblsan0 arm64 15-20250222-0ubuntu1 [1319 kB] 718s Get:12 http://ftpmaster.internal/ubuntu plucky/main arm64 libtsan2 arm64 15-20250222-0ubuntu1 [2694 kB] 721s Get:13 http://ftpmaster.internal/ubuntu plucky/main arm64 libubsan1 arm64 15-20250222-0ubuntu1 [1178 kB] 722s Get:14 http://ftpmaster.internal/ubuntu plucky/main arm64 libhwasan0 arm64 15-20250222-0ubuntu1 [1642 kB] 724s Get:15 http://ftpmaster.internal/ubuntu plucky/main arm64 libgcc-14-dev arm64 14.2.0-17ubuntu3 [2593 kB] 727s Get:16 http://ftpmaster.internal/ubuntu plucky/main arm64 gcc-14-aarch64-linux-gnu arm64 14.2.0-17ubuntu3 [20.9 MB] 751s Get:17 http://ftpmaster.internal/ubuntu plucky/main arm64 gcc-14 arm64 14.2.0-17ubuntu3 [526 kB] 752s Get:18 http://ftpmaster.internal/ubuntu plucky/main arm64 gcc-aarch64-linux-gnu arm64 4:14.2.0-1ubuntu1 [1200 B] 752s Get:19 http://ftpmaster.internal/ubuntu plucky/main arm64 gcc arm64 4:14.2.0-1ubuntu1 [4998 B] 752s Get:20 http://ftpmaster.internal/ubuntu plucky/main arm64 libstdc++-14-dev arm64 14.2.0-17ubuntu3 [2499 kB] 754s Get:21 http://ftpmaster.internal/ubuntu plucky/main arm64 g++-14-aarch64-linux-gnu arm64 14.2.0-17ubuntu3 [12.1 MB] 767s Get:22 http://ftpmaster.internal/ubuntu plucky/main arm64 g++-14 arm64 14.2.0-17ubuntu3 [21.8 kB] 767s Get:23 http://ftpmaster.internal/ubuntu plucky/main arm64 g++-aarch64-linux-gnu arm64 4:14.2.0-1ubuntu1 [956 B] 767s Get:24 http://ftpmaster.internal/ubuntu plucky/main arm64 g++ arm64 4:14.2.0-1ubuntu1 [1080 B] 767s Get:25 http://ftpmaster.internal/ubuntu plucky/main arm64 build-essential arm64 12.10ubuntu1 [4932 B] 767s Get:26 http://ftpmaster.internal/ubuntu plucky/main arm64 dctrl-tools arm64 2.24-3build3 [103 kB] 767s Get:27 http://ftpmaster.internal/ubuntu plucky/main arm64 fonts-dejavu-mono all 2.37-8 [502 kB] 768s Get:28 http://ftpmaster.internal/ubuntu plucky/main arm64 fonts-dejavu-core all 2.37-8 [835 kB] 769s Get:29 http://ftpmaster.internal/ubuntu plucky/main arm64 fontconfig-config arm64 2.15.0-2ubuntu1 [37.5 kB] 769s Get:30 http://ftpmaster.internal/ubuntu plucky/main arm64 libfontconfig1 arm64 2.15.0-2ubuntu1 [144 kB] 770s Get:31 http://ftpmaster.internal/ubuntu plucky/main arm64 fontconfig arm64 2.15.0-2ubuntu1 [191 kB] 770s Get:32 http://ftpmaster.internal/ubuntu plucky/universe arm64 fonts-glyphicons-halflings all 1.009~3.4.1+dfsg-3 [118 kB] 770s Get:33 http://ftpmaster.internal/ubuntu plucky/main arm64 fonts-mathjax all 2.7.9+dfsg-1 [2208 kB] 771s Get:34 http://ftpmaster.internal/ubuntu plucky/main arm64 libgfortran5 arm64 15-20250222-0ubuntu1 [444 kB] 772s Get:35 http://ftpmaster.internal/ubuntu plucky/main arm64 libgfortran-14-dev arm64 14.2.0-17ubuntu3 [498 kB] 773s Get:36 http://ftpmaster.internal/ubuntu plucky/main arm64 gfortran-14-aarch64-linux-gnu arm64 14.2.0-17ubuntu3 [11.4 MB] 785s Get:37 http://ftpmaster.internal/ubuntu plucky/main arm64 gfortran-14 arm64 14.2.0-17ubuntu3 [13.6 kB] 785s Get:38 http://ftpmaster.internal/ubuntu plucky/main arm64 gfortran-aarch64-linux-gnu arm64 4:14.2.0-1ubuntu1 [1022 B] 785s Get:39 http://ftpmaster.internal/ubuntu plucky/main arm64 gfortran arm64 4:14.2.0-1ubuntu1 [1166 B] 785s Get:40 http://ftpmaster.internal/ubuntu plucky/main arm64 icu-devtools arm64 76.1-1ubuntu2 [213 kB] 785s Get:41 http://ftpmaster.internal/ubuntu plucky/main arm64 libblas3 arm64 3.12.1-2 [161 kB] 785s Get:42 http://ftpmaster.internal/ubuntu plucky/main arm64 libblas-dev arm64 3.12.1-2 [126 kB] 785s Get:43 http://ftpmaster.internal/ubuntu plucky/main arm64 libbz2-dev arm64 1.0.8-6 [36.1 kB] 786s Get:44 http://ftpmaster.internal/ubuntu plucky/main arm64 libpixman-1-0 arm64 0.44.0-3 [197 kB] 786s Get:45 http://ftpmaster.internal/ubuntu plucky/main arm64 libxcb-render0 arm64 1.17.0-2 [16.6 kB] 786s Get:46 http://ftpmaster.internal/ubuntu plucky/main arm64 libxcb-shm0 arm64 1.17.0-2 [5884 B] 786s Get:47 http://ftpmaster.internal/ubuntu plucky/main arm64 libxrender1 arm64 1:0.9.10-1.1build1 [18.8 kB] 786s Get:48 http://ftpmaster.internal/ubuntu plucky/main arm64 libcairo2 arm64 1.18.2-2 [560 kB] 786s Get:49 http://ftpmaster.internal/ubuntu plucky/main arm64 libdatrie1 arm64 0.2.13-3build1 [19.2 kB] 786s Get:50 http://ftpmaster.internal/ubuntu plucky/main arm64 libdeflate0 arm64 1.23-1 [46.2 kB] 786s Get:51 http://ftpmaster.internal/ubuntu plucky/main arm64 libdeflate-dev arm64 1.23-1 [53.7 kB] 786s Get:52 http://ftpmaster.internal/ubuntu plucky/main arm64 libgraphite2-3 arm64 1.3.14-2ubuntu1 [70.6 kB] 787s Get:53 http://ftpmaster.internal/ubuntu plucky/main arm64 libharfbuzz0b arm64 10.2.0-1 [490 kB] 787s Get:54 http://ftpmaster.internal/ubuntu plucky/main arm64 x11-common all 1:7.7+23ubuntu3 [21.7 kB] 787s Get:55 http://ftpmaster.internal/ubuntu plucky/main arm64 libice6 arm64 2:1.1.1-1 [42.3 kB] 787s Get:56 http://ftpmaster.internal/ubuntu plucky/main arm64 libicu-dev arm64 76.1-1ubuntu2 [12.2 MB] 800s Get:57 http://ftpmaster.internal/ubuntu plucky/main arm64 libjpeg-turbo8 arm64 2.1.5-3ubuntu2 [165 kB] 800s Get:58 http://ftpmaster.internal/ubuntu plucky/main arm64 libjpeg-turbo8-dev arm64 2.1.5-3ubuntu2 [306 kB] 801s Get:59 http://ftpmaster.internal/ubuntu plucky/main arm64 libjpeg8 arm64 8c-2ubuntu11 [2148 B] 801s Get:60 http://ftpmaster.internal/ubuntu plucky/main arm64 libjpeg8-dev arm64 8c-2ubuntu11 [1484 B] 801s Get:61 http://ftpmaster.internal/ubuntu plucky/main arm64 libjpeg-dev arm64 8c-2ubuntu11 [1482 B] 801s Get:62 http://ftpmaster.internal/ubuntu plucky/universe arm64 libjs-bootstrap all 3.4.1+dfsg-3 [129 kB] 801s Get:63 http://ftpmaster.internal/ubuntu plucky/universe arm64 libjs-highlight.js all 9.18.5+dfsg1-2 [385 kB] 801s Get:64 http://ftpmaster.internal/ubuntu plucky/main arm64 libjs-jquery all 3.6.1+dfsg+~3.5.14-1 [328 kB] 802s Get:65 http://ftpmaster.internal/ubuntu plucky/universe arm64 libjs-jquery-datatables all 1.11.5+dfsg-2 [146 kB] 802s Get:66 http://ftpmaster.internal/ubuntu plucky/main arm64 liblapack3 arm64 3.12.1-2 [2307 kB] 805s Get:67 http://ftpmaster.internal/ubuntu plucky/main arm64 liblapack-dev arm64 3.12.1-2 [4439 kB] 810s Get:68 http://ftpmaster.internal/ubuntu plucky/main arm64 liblerc4 arm64 4.0.0+ds-5ubuntu1 [167 kB] 810s Get:69 http://ftpmaster.internal/ubuntu plucky/main arm64 libncurses-dev arm64 6.5+20250216-2 [389 kB] 810s Get:70 http://ftpmaster.internal/ubuntu plucky/main arm64 libthai-data all 0.1.29-2build1 [158 kB] 810s Get:71 http://ftpmaster.internal/ubuntu plucky/main arm64 libthai0 arm64 0.1.29-2build1 [18.2 kB] 810s Get:72 http://ftpmaster.internal/ubuntu plucky/main arm64 libpango-1.0-0 arm64 1.56.2-1 [237 kB] 811s Get:73 http://ftpmaster.internal/ubuntu plucky/main arm64 libpangoft2-1.0-0 arm64 1.56.2-1 [49.5 kB] 811s Get:74 http://ftpmaster.internal/ubuntu plucky/main arm64 libpangocairo-1.0-0 arm64 1.56.2-1 [27.6 kB] 811s Get:75 http://ftpmaster.internal/ubuntu plucky/main arm64 libpaper2 arm64 2.2.5-0.3 [17.3 kB] 811s Get:76 http://ftpmaster.internal/ubuntu plucky/main arm64 libpaper-utils arm64 2.2.5-0.3 [15.4 kB] 811s Get:77 http://ftpmaster.internal/ubuntu plucky/main arm64 libpcre2-16-0 arm64 10.45-1 [222 kB] 811s Get:78 http://ftpmaster.internal/ubuntu plucky/main arm64 libpcre2-32-0 arm64 10.45-1 [210 kB] 811s Get:79 http://ftpmaster.internal/ubuntu plucky/main arm64 libpcre2-posix3 arm64 10.45-1 [7084 B] 811s Get:80 http://ftpmaster.internal/ubuntu plucky/main arm64 libpcre2-dev arm64 10.45-1 [768 kB] 812s Get:81 http://ftpmaster.internal/ubuntu plucky/main arm64 libpkgconf3 arm64 1.8.1-4 [31.4 kB] 812s Get:82 http://ftpmaster.internal/ubuntu plucky/main arm64 zlib1g-dev arm64 1:1.3.dfsg+really1.3.1-1ubuntu1 [894 kB] 813s Get:83 http://ftpmaster.internal/ubuntu plucky/main arm64 libpng-dev arm64 1.6.47-1 [269 kB] 813s Get:84 http://ftpmaster.internal/ubuntu plucky/main arm64 libreadline-dev arm64 8.2-6 [179 kB] 814s Get:85 http://ftpmaster.internal/ubuntu plucky/main arm64 libsharpyuv0 arm64 1.5.0-0.1 [16.9 kB] 814s Get:86 http://ftpmaster.internal/ubuntu plucky/main arm64 libsm6 arm64 2:1.2.4-1 [16.4 kB] 814s Get:87 http://ftpmaster.internal/ubuntu plucky/main arm64 libtcl8.6 arm64 8.6.16+dfsg-1 [987 kB] 815s Get:88 http://ftpmaster.internal/ubuntu plucky/main arm64 libjbig0 arm64 2.1-6.1ubuntu2 [29.3 kB] 815s Get:89 http://ftpmaster.internal/ubuntu plucky/main arm64 libwebp7 arm64 1.5.0-0.1 [194 kB] 815s Get:90 http://ftpmaster.internal/ubuntu plucky/main arm64 libtiff6 arm64 4.5.1+git230720-4ubuntu4 [193 kB] 815s Get:91 http://ftpmaster.internal/ubuntu plucky/main arm64 libxft2 arm64 2.3.6-1build1 [44.1 kB] 815s Get:92 http://ftpmaster.internal/ubuntu plucky/main arm64 libxss1 arm64 1:1.2.3-1build3 [7244 B] 815s Get:93 http://ftpmaster.internal/ubuntu plucky/main arm64 libtk8.6 arm64 8.6.16-1 [776 kB] 816s Get:94 http://ftpmaster.internal/ubuntu plucky/main arm64 libxt6t64 arm64 1:1.2.1-1.2build1 [168 kB] 816s Get:95 http://ftpmaster.internal/ubuntu plucky/universe arm64 node-normalize.css all 8.0.1-5 [10.8 kB] 816s Get:96 http://ftpmaster.internal/ubuntu plucky/main arm64 zip arm64 3.0-14ubuntu2 [173 kB] 816s Get:97 http://ftpmaster.internal/ubuntu plucky/main arm64 unzip arm64 6.0-28ubuntu6 [178 kB] 816s Get:98 http://ftpmaster.internal/ubuntu plucky/main arm64 xdg-utils all 1.2.1-2ubuntu1 [66.0 kB] 817s Get:99 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-base-core arm64 4.4.3-1 [28.4 MB] 846s Get:100 http://ftpmaster.internal/ubuntu plucky/main arm64 liblzma-dev arm64 5.6.4-1 [180 kB] 846s Get:101 http://ftpmaster.internal/ubuntu plucky/main arm64 pkgconf-bin arm64 1.8.1-4 [20.9 kB] 847s Get:102 http://ftpmaster.internal/ubuntu plucky/main arm64 pkgconf arm64 1.8.1-4 [16.7 kB] 847s Get:103 http://ftpmaster.internal/ubuntu plucky/main arm64 libtirpc-dev arm64 1.3.4+ds-1.3 [201 kB] 847s Get:104 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-base-dev all 4.4.3-1 [4176 B] 847s Get:105 http://ftpmaster.internal/ubuntu plucky/universe arm64 pkg-r-autopkgtest all 20231212ubuntu1 [6448 B] 847s Get:106 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-base64enc arm64 0.1-3-3 [27.4 kB] 847s Get:107 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-cli arm64 3.6.4-1 [1374 kB] 848s Get:108 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-colorspace arm64 2.1-1+dfsg-1 [1563 kB] 850s Get:109 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-commonmark arm64 1.9.2-2 [129 kB] 850s Get:110 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-evaluate all 1.0.3-1 [114 kB] 850s Get:111 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-fansi arm64 1.0.5-1 [616 kB] 851s Get:112 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-farver arm64 2.1.2-1 [1344 kB] 852s Get:113 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-glue arm64 1.8.0-1 [163 kB] 852s Get:114 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-rlang arm64 1.1.5-1 [1707 kB] 854s Get:115 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-lifecycle all 1.0.4+dfsg-1 [110 kB] 854s Get:116 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-gtable all 0.3.6+dfsg-1 [199 kB] 854s Get:117 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-isoband arm64 0.2.7-1 [1481 kB] 856s Get:118 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-mass arm64 7.3-64-1 [1110 kB] 857s Get:119 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-lattice arm64 0.22-6-1 [1363 kB] 858s Get:120 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-nlme arm64 3.1.167-1 [2311 kB] 861s Get:121 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-matrix arm64 1.7-3-1 [4045 kB] 865s Get:122 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-mgcv arm64 1.9-1-1 [3248 kB] 869s Get:123 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-labeling all 0.4.3-1 [62.1 kB] 869s Get:124 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-munsell all 0.5.1-1 [213 kB] 870s Get:125 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-r6 all 2.6.1-1 [101 kB] 870s Get:126 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-rcolorbrewer all 1.1-3-1build1 [55.4 kB] 870s Get:127 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-viridislite all 0.4.2-2 [1088 kB] 873s Get:128 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-scales all 1.3.0-1 [603 kB] 875s Get:129 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-magrittr arm64 2.0.3-1 [154 kB] 875s Get:130 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-utf8 arm64 1.2.4-1 [140 kB] 875s Get:131 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-vctrs arm64 0.6.5-1 [1327 kB] 877s Get:132 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-pillar all 1.10.1+dfsg-1 [453 kB] 878s Get:133 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-pkgconfig all 2.0.3-2build1 [19.7 kB] 878s Get:134 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-tibble arm64 3.2.1+dfsg-3 [420 kB] 878s Get:135 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-withr all 3.0.2+dfsg-1 [214 kB] 879s Get:136 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-ggplot2 all 3.5.1+dfsg-1 [3940 kB] 883s Get:137 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-xfun arm64 0.51+dfsg-1 [573 kB] 884s Get:138 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-highr all 0.11+dfsg-1 [38.5 kB] 884s Get:139 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-yaml arm64 2.3.10-1 [108 kB] 884s Get:140 http://ftpmaster.internal/ubuntu plucky/main arm64 libjs-mathjax all 2.7.9+dfsg-1 [5665 kB] 890s Get:141 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-knitr all 1.49+dfsg-1 [859 kB] 890s Get:142 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-markdown all 1.13-1 [162 kB] 891s Get:143 http://ftpmaster.internal/ubuntu plucky/universe arm64 r-cran-matrixstats arm64 1.5.0-1 [496 kB] 892s Preconfiguring packages ... 892s Fetched 172 MB in 3min 11s (901 kB/s) 892s Selecting previously unselected package libisl23:arm64. 892s (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 ... 81647 files and directories currently installed.) 892s Preparing to unpack .../000-libisl23_0.27-1_arm64.deb ... 892s Unpacking libisl23:arm64 (0.27-1) ... 892s Selecting previously unselected package libmpc3:arm64. 892s Preparing to unpack .../001-libmpc3_1.3.1-1build2_arm64.deb ... 892s Unpacking libmpc3:arm64 (1.3.1-1build2) ... 892s Selecting previously unselected package cpp-14-aarch64-linux-gnu. 892s Preparing to unpack .../002-cpp-14-aarch64-linux-gnu_14.2.0-17ubuntu3_arm64.deb ... 892s Unpacking cpp-14-aarch64-linux-gnu (14.2.0-17ubuntu3) ... 893s Selecting previously unselected package cpp-14. 893s Preparing to unpack .../003-cpp-14_14.2.0-17ubuntu3_arm64.deb ... 893s Unpacking cpp-14 (14.2.0-17ubuntu3) ... 893s Selecting previously unselected package cpp-aarch64-linux-gnu. 893s Preparing to unpack .../004-cpp-aarch64-linux-gnu_4%3a14.2.0-1ubuntu1_arm64.deb ... 893s Unpacking cpp-aarch64-linux-gnu (4:14.2.0-1ubuntu1) ... 893s Selecting previously unselected package cpp. 893s Preparing to unpack .../005-cpp_4%3a14.2.0-1ubuntu1_arm64.deb ... 893s Unpacking cpp (4:14.2.0-1ubuntu1) ... 893s Selecting previously unselected package libcc1-0:arm64. 893s Preparing to unpack .../006-libcc1-0_15-20250222-0ubuntu1_arm64.deb ... 893s Unpacking libcc1-0:arm64 (15-20250222-0ubuntu1) ... 893s Selecting previously unselected package libgomp1:arm64. 893s Preparing to unpack .../007-libgomp1_15-20250222-0ubuntu1_arm64.deb ... 893s Unpacking libgomp1:arm64 (15-20250222-0ubuntu1) ... 893s Selecting previously unselected package libitm1:arm64. 893s Preparing to unpack .../008-libitm1_15-20250222-0ubuntu1_arm64.deb ... 893s Unpacking libitm1:arm64 (15-20250222-0ubuntu1) ... 893s Selecting previously unselected package libasan8:arm64. 893s Preparing to unpack .../009-libasan8_15-20250222-0ubuntu1_arm64.deb ... 893s Unpacking libasan8:arm64 (15-20250222-0ubuntu1) ... 893s Selecting previously unselected package liblsan0:arm64. 893s Preparing to unpack .../010-liblsan0_15-20250222-0ubuntu1_arm64.deb ... 893s Unpacking liblsan0:arm64 (15-20250222-0ubuntu1) ... 893s Selecting previously unselected package libtsan2:arm64. 893s Preparing to unpack .../011-libtsan2_15-20250222-0ubuntu1_arm64.deb ... 893s Unpacking libtsan2:arm64 (15-20250222-0ubuntu1) ... 893s Selecting previously unselected package libubsan1:arm64. 893s Preparing to unpack .../012-libubsan1_15-20250222-0ubuntu1_arm64.deb ... 893s Unpacking libubsan1:arm64 (15-20250222-0ubuntu1) ... 893s Selecting previously unselected package libhwasan0:arm64. 893s Preparing to unpack .../013-libhwasan0_15-20250222-0ubuntu1_arm64.deb ... 893s Unpacking libhwasan0:arm64 (15-20250222-0ubuntu1) ... 893s Selecting previously unselected package libgcc-14-dev:arm64. 894s Preparing to unpack .../014-libgcc-14-dev_14.2.0-17ubuntu3_arm64.deb ... 894s Unpacking libgcc-14-dev:arm64 (14.2.0-17ubuntu3) ... 894s Selecting previously unselected package gcc-14-aarch64-linux-gnu. 894s Preparing to unpack .../015-gcc-14-aarch64-linux-gnu_14.2.0-17ubuntu3_arm64.deb ... 894s Unpacking gcc-14-aarch64-linux-gnu (14.2.0-17ubuntu3) ... 894s Selecting previously unselected package gcc-14. 894s Preparing to unpack .../016-gcc-14_14.2.0-17ubuntu3_arm64.deb ... 894s Unpacking gcc-14 (14.2.0-17ubuntu3) ... 895s Selecting previously unselected package gcc-aarch64-linux-gnu. 895s Preparing to unpack .../017-gcc-aarch64-linux-gnu_4%3a14.2.0-1ubuntu1_arm64.deb ... 895s Unpacking gcc-aarch64-linux-gnu (4:14.2.0-1ubuntu1) ... 895s Selecting previously unselected package gcc. 895s Preparing to unpack .../018-gcc_4%3a14.2.0-1ubuntu1_arm64.deb ... 895s Unpacking gcc (4:14.2.0-1ubuntu1) ... 895s Selecting previously unselected package libstdc++-14-dev:arm64. 895s Preparing to unpack .../019-libstdc++-14-dev_14.2.0-17ubuntu3_arm64.deb ... 895s Unpacking libstdc++-14-dev:arm64 (14.2.0-17ubuntu3) ... 895s Selecting previously unselected package g++-14-aarch64-linux-gnu. 895s Preparing to unpack .../020-g++-14-aarch64-linux-gnu_14.2.0-17ubuntu3_arm64.deb ... 895s Unpacking g++-14-aarch64-linux-gnu (14.2.0-17ubuntu3) ... 895s Selecting previously unselected package g++-14. 895s Preparing to unpack .../021-g++-14_14.2.0-17ubuntu3_arm64.deb ... 895s Unpacking g++-14 (14.2.0-17ubuntu3) ... 895s Selecting previously unselected package g++-aarch64-linux-gnu. 895s Preparing to unpack .../022-g++-aarch64-linux-gnu_4%3a14.2.0-1ubuntu1_arm64.deb ... 895s Unpacking g++-aarch64-linux-gnu (4:14.2.0-1ubuntu1) ... 895s Selecting previously unselected package g++. 895s Preparing to unpack .../023-g++_4%3a14.2.0-1ubuntu1_arm64.deb ... 895s Unpacking g++ (4:14.2.0-1ubuntu1) ... 895s Selecting previously unselected package build-essential. 895s Preparing to unpack .../024-build-essential_12.10ubuntu1_arm64.deb ... 895s Unpacking build-essential (12.10ubuntu1) ... 895s Selecting previously unselected package dctrl-tools. 895s Preparing to unpack .../025-dctrl-tools_2.24-3build3_arm64.deb ... 895s Unpacking dctrl-tools (2.24-3build3) ... 895s Selecting previously unselected package fonts-dejavu-mono. 895s Preparing to unpack .../026-fonts-dejavu-mono_2.37-8_all.deb ... 895s Unpacking fonts-dejavu-mono (2.37-8) ... 895s Selecting previously unselected package fonts-dejavu-core. 895s Preparing to unpack .../027-fonts-dejavu-core_2.37-8_all.deb ... 895s Unpacking fonts-dejavu-core (2.37-8) ... 895s Selecting previously unselected package fontconfig-config. 895s Preparing to unpack .../028-fontconfig-config_2.15.0-2ubuntu1_arm64.deb ... 896s Unpacking fontconfig-config (2.15.0-2ubuntu1) ... 896s Selecting previously unselected package libfontconfig1:arm64. 896s Preparing to unpack .../029-libfontconfig1_2.15.0-2ubuntu1_arm64.deb ... 896s Unpacking libfontconfig1:arm64 (2.15.0-2ubuntu1) ... 896s Selecting previously unselected package fontconfig. 896s Preparing to unpack .../030-fontconfig_2.15.0-2ubuntu1_arm64.deb ... 896s Unpacking fontconfig (2.15.0-2ubuntu1) ... 896s Selecting previously unselected package fonts-glyphicons-halflings. 896s Preparing to unpack .../031-fonts-glyphicons-halflings_1.009~3.4.1+dfsg-3_all.deb ... 896s Unpacking fonts-glyphicons-halflings (1.009~3.4.1+dfsg-3) ... 896s Selecting previously unselected package fonts-mathjax. 896s Preparing to unpack .../032-fonts-mathjax_2.7.9+dfsg-1_all.deb ... 896s Unpacking fonts-mathjax (2.7.9+dfsg-1) ... 896s Selecting previously unselected package libgfortran5:arm64. 896s Preparing to unpack .../033-libgfortran5_15-20250222-0ubuntu1_arm64.deb ... 896s Unpacking libgfortran5:arm64 (15-20250222-0ubuntu1) ... 896s Selecting previously unselected package libgfortran-14-dev:arm64. 896s Preparing to unpack .../034-libgfortran-14-dev_14.2.0-17ubuntu3_arm64.deb ... 896s Unpacking libgfortran-14-dev:arm64 (14.2.0-17ubuntu3) ... 896s Selecting previously unselected package gfortran-14-aarch64-linux-gnu. 896s Preparing to unpack .../035-gfortran-14-aarch64-linux-gnu_14.2.0-17ubuntu3_arm64.deb ... 896s Unpacking gfortran-14-aarch64-linux-gnu (14.2.0-17ubuntu3) ... 897s Selecting previously unselected package gfortran-14. 897s Preparing to unpack .../036-gfortran-14_14.2.0-17ubuntu3_arm64.deb ... 897s Unpacking gfortran-14 (14.2.0-17ubuntu3) ... 897s Selecting previously unselected package gfortran-aarch64-linux-gnu. 897s Preparing to unpack .../037-gfortran-aarch64-linux-gnu_4%3a14.2.0-1ubuntu1_arm64.deb ... 897s Unpacking gfortran-aarch64-linux-gnu (4:14.2.0-1ubuntu1) ... 897s Selecting previously unselected package gfortran. 897s Preparing to unpack .../038-gfortran_4%3a14.2.0-1ubuntu1_arm64.deb ... 897s Unpacking gfortran (4:14.2.0-1ubuntu1) ... 897s Selecting previously unselected package icu-devtools. 897s Preparing to unpack .../039-icu-devtools_76.1-1ubuntu2_arm64.deb ... 897s Unpacking icu-devtools (76.1-1ubuntu2) ... 897s Selecting previously unselected package libblas3:arm64. 897s Preparing to unpack .../040-libblas3_3.12.1-2_arm64.deb ... 897s Unpacking libblas3:arm64 (3.12.1-2) ... 897s Selecting previously unselected package libblas-dev:arm64. 897s Preparing to unpack .../041-libblas-dev_3.12.1-2_arm64.deb ... 897s Unpacking libblas-dev:arm64 (3.12.1-2) ... 897s Selecting previously unselected package libbz2-dev:arm64. 897s Preparing to unpack .../042-libbz2-dev_1.0.8-6_arm64.deb ... 897s Unpacking libbz2-dev:arm64 (1.0.8-6) ... 897s Selecting previously unselected package libpixman-1-0:arm64. 897s Preparing to unpack .../043-libpixman-1-0_0.44.0-3_arm64.deb ... 897s Unpacking libpixman-1-0:arm64 (0.44.0-3) ... 897s Selecting previously unselected package libxcb-render0:arm64. 897s Preparing to unpack .../044-libxcb-render0_1.17.0-2_arm64.deb ... 897s Unpacking libxcb-render0:arm64 (1.17.0-2) ... 897s Selecting previously unselected package libxcb-shm0:arm64. 897s Preparing to unpack .../045-libxcb-shm0_1.17.0-2_arm64.deb ... 897s Unpacking libxcb-shm0:arm64 (1.17.0-2) ... 897s Selecting previously unselected package libxrender1:arm64. 897s Preparing to unpack .../046-libxrender1_1%3a0.9.10-1.1build1_arm64.deb ... 897s Unpacking libxrender1:arm64 (1:0.9.10-1.1build1) ... 897s Selecting previously unselected package libcairo2:arm64. 897s Preparing to unpack .../047-libcairo2_1.18.2-2_arm64.deb ... 897s Unpacking libcairo2:arm64 (1.18.2-2) ... 897s Selecting previously unselected package libdatrie1:arm64. 897s Preparing to unpack .../048-libdatrie1_0.2.13-3build1_arm64.deb ... 897s Unpacking libdatrie1:arm64 (0.2.13-3build1) ... 897s Selecting previously unselected package libdeflate0:arm64. 897s Preparing to unpack .../049-libdeflate0_1.23-1_arm64.deb ... 897s Unpacking libdeflate0:arm64 (1.23-1) ... 897s Selecting previously unselected package libdeflate-dev:arm64. 897s Preparing to unpack .../050-libdeflate-dev_1.23-1_arm64.deb ... 897s Unpacking libdeflate-dev:arm64 (1.23-1) ... 897s Selecting previously unselected package libgraphite2-3:arm64. 897s Preparing to unpack .../051-libgraphite2-3_1.3.14-2ubuntu1_arm64.deb ... 897s Unpacking libgraphite2-3:arm64 (1.3.14-2ubuntu1) ... 898s Selecting previously unselected package libharfbuzz0b:arm64. 898s Preparing to unpack .../052-libharfbuzz0b_10.2.0-1_arm64.deb ... 898s Unpacking libharfbuzz0b:arm64 (10.2.0-1) ... 898s Selecting previously unselected package x11-common. 898s Preparing to unpack .../053-x11-common_1%3a7.7+23ubuntu3_all.deb ... 898s Unpacking x11-common (1:7.7+23ubuntu3) ... 898s Selecting previously unselected package libice6:arm64. 898s Preparing to unpack .../054-libice6_2%3a1.1.1-1_arm64.deb ... 898s Unpacking libice6:arm64 (2:1.1.1-1) ... 898s Selecting previously unselected package libicu-dev:arm64. 898s Preparing to unpack .../055-libicu-dev_76.1-1ubuntu2_arm64.deb ... 898s Unpacking libicu-dev:arm64 (76.1-1ubuntu2) ... 898s Selecting previously unselected package libjpeg-turbo8:arm64. 898s Preparing to unpack .../056-libjpeg-turbo8_2.1.5-3ubuntu2_arm64.deb ... 898s Unpacking libjpeg-turbo8:arm64 (2.1.5-3ubuntu2) ... 898s Selecting previously unselected package libjpeg-turbo8-dev:arm64. 898s Preparing to unpack .../057-libjpeg-turbo8-dev_2.1.5-3ubuntu2_arm64.deb ... 898s Unpacking libjpeg-turbo8-dev:arm64 (2.1.5-3ubuntu2) ... 898s Selecting previously unselected package libjpeg8:arm64. 898s Preparing to unpack .../058-libjpeg8_8c-2ubuntu11_arm64.deb ... 898s Unpacking libjpeg8:arm64 (8c-2ubuntu11) ... 898s Selecting previously unselected package libjpeg8-dev:arm64. 898s Preparing to unpack .../059-libjpeg8-dev_8c-2ubuntu11_arm64.deb ... 898s Unpacking libjpeg8-dev:arm64 (8c-2ubuntu11) ... 898s Selecting previously unselected package libjpeg-dev:arm64. 898s Preparing to unpack .../060-libjpeg-dev_8c-2ubuntu11_arm64.deb ... 898s Unpacking libjpeg-dev:arm64 (8c-2ubuntu11) ... 898s Selecting previously unselected package libjs-bootstrap. 898s Preparing to unpack .../061-libjs-bootstrap_3.4.1+dfsg-3_all.deb ... 898s Unpacking libjs-bootstrap (3.4.1+dfsg-3) ... 898s Selecting previously unselected package libjs-highlight.js. 898s Preparing to unpack .../062-libjs-highlight.js_9.18.5+dfsg1-2_all.deb ... 898s Unpacking libjs-highlight.js (9.18.5+dfsg1-2) ... 898s Selecting previously unselected package libjs-jquery. 899s Preparing to unpack .../063-libjs-jquery_3.6.1+dfsg+~3.5.14-1_all.deb ... 899s Unpacking libjs-jquery (3.6.1+dfsg+~3.5.14-1) ... 899s Selecting previously unselected package libjs-jquery-datatables. 899s Preparing to unpack .../064-libjs-jquery-datatables_1.11.5+dfsg-2_all.deb ... 899s Unpacking libjs-jquery-datatables (1.11.5+dfsg-2) ... 899s Selecting previously unselected package liblapack3:arm64. 899s Preparing to unpack .../065-liblapack3_3.12.1-2_arm64.deb ... 899s Unpacking liblapack3:arm64 (3.12.1-2) ... 899s Selecting previously unselected package liblapack-dev:arm64. 899s Preparing to unpack .../066-liblapack-dev_3.12.1-2_arm64.deb ... 899s Unpacking liblapack-dev:arm64 (3.12.1-2) ... 899s Selecting previously unselected package liblerc4:arm64. 899s Preparing to unpack .../067-liblerc4_4.0.0+ds-5ubuntu1_arm64.deb ... 899s Unpacking liblerc4:arm64 (4.0.0+ds-5ubuntu1) ... 899s Selecting previously unselected package libncurses-dev:arm64. 899s Preparing to unpack .../068-libncurses-dev_6.5+20250216-2_arm64.deb ... 899s Unpacking libncurses-dev:arm64 (6.5+20250216-2) ... 899s Selecting previously unselected package libthai-data. 899s Preparing to unpack .../069-libthai-data_0.1.29-2build1_all.deb ... 899s Unpacking libthai-data (0.1.29-2build1) ... 899s Selecting previously unselected package libthai0:arm64. 899s Preparing to unpack .../070-libthai0_0.1.29-2build1_arm64.deb ... 899s Unpacking libthai0:arm64 (0.1.29-2build1) ... 899s Selecting previously unselected package libpango-1.0-0:arm64. 899s Preparing to unpack .../071-libpango-1.0-0_1.56.2-1_arm64.deb ... 899s Unpacking libpango-1.0-0:arm64 (1.56.2-1) ... 900s Selecting previously unselected package libpangoft2-1.0-0:arm64. 900s Preparing to unpack .../072-libpangoft2-1.0-0_1.56.2-1_arm64.deb ... 900s Unpacking libpangoft2-1.0-0:arm64 (1.56.2-1) ... 900s Selecting previously unselected package libpangocairo-1.0-0:arm64. 900s Preparing to unpack .../073-libpangocairo-1.0-0_1.56.2-1_arm64.deb ... 900s Unpacking libpangocairo-1.0-0:arm64 (1.56.2-1) ... 900s Selecting previously unselected package libpaper2:arm64. 900s Preparing to unpack .../074-libpaper2_2.2.5-0.3_arm64.deb ... 900s Unpacking libpaper2:arm64 (2.2.5-0.3) ... 900s Selecting previously unselected package libpaper-utils. 900s Preparing to unpack .../075-libpaper-utils_2.2.5-0.3_arm64.deb ... 900s Unpacking libpaper-utils (2.2.5-0.3) ... 900s Selecting previously unselected package libpcre2-16-0:arm64. 900s Preparing to unpack .../076-libpcre2-16-0_10.45-1_arm64.deb ... 900s Unpacking libpcre2-16-0:arm64 (10.45-1) ... 900s Selecting previously unselected package libpcre2-32-0:arm64. 900s Preparing to unpack .../077-libpcre2-32-0_10.45-1_arm64.deb ... 900s Unpacking libpcre2-32-0:arm64 (10.45-1) ... 900s Selecting previously unselected package libpcre2-posix3:arm64. 900s Preparing to unpack .../078-libpcre2-posix3_10.45-1_arm64.deb ... 900s Unpacking libpcre2-posix3:arm64 (10.45-1) ... 900s Selecting previously unselected package libpcre2-dev:arm64. 900s Preparing to unpack .../079-libpcre2-dev_10.45-1_arm64.deb ... 900s Unpacking libpcre2-dev:arm64 (10.45-1) ... 900s Selecting previously unselected package libpkgconf3:arm64. 900s Preparing to unpack .../080-libpkgconf3_1.8.1-4_arm64.deb ... 900s Unpacking libpkgconf3:arm64 (1.8.1-4) ... 900s Selecting previously unselected package zlib1g-dev:arm64. 900s Preparing to unpack .../081-zlib1g-dev_1%3a1.3.dfsg+really1.3.1-1ubuntu1_arm64.deb ... 900s Unpacking zlib1g-dev:arm64 (1:1.3.dfsg+really1.3.1-1ubuntu1) ... 900s Selecting previously unselected package libpng-dev:arm64. 900s Preparing to unpack .../082-libpng-dev_1.6.47-1_arm64.deb ... 900s Unpacking libpng-dev:arm64 (1.6.47-1) ... 900s Selecting previously unselected package libreadline-dev:arm64. 900s Preparing to unpack .../083-libreadline-dev_8.2-6_arm64.deb ... 900s Unpacking libreadline-dev:arm64 (8.2-6) ... 900s Selecting previously unselected package libsharpyuv0:arm64. 900s Preparing to unpack .../084-libsharpyuv0_1.5.0-0.1_arm64.deb ... 900s Unpacking libsharpyuv0:arm64 (1.5.0-0.1) ... 900s Selecting previously unselected package libsm6:arm64. 900s Preparing to unpack .../085-libsm6_2%3a1.2.4-1_arm64.deb ... 900s Unpacking libsm6:arm64 (2:1.2.4-1) ... 900s Selecting previously unselected package libtcl8.6:arm64. 900s Preparing to unpack .../086-libtcl8.6_8.6.16+dfsg-1_arm64.deb ... 900s Unpacking libtcl8.6:arm64 (8.6.16+dfsg-1) ... 900s Selecting previously unselected package libjbig0:arm64. 900s Preparing to unpack .../087-libjbig0_2.1-6.1ubuntu2_arm64.deb ... 900s Unpacking libjbig0:arm64 (2.1-6.1ubuntu2) ... 900s Selecting previously unselected package libwebp7:arm64. 900s Preparing to unpack .../088-libwebp7_1.5.0-0.1_arm64.deb ... 900s Unpacking libwebp7:arm64 (1.5.0-0.1) ... 901s Selecting previously unselected package libtiff6:arm64. 901s Preparing to unpack .../089-libtiff6_4.5.1+git230720-4ubuntu4_arm64.deb ... 901s Unpacking libtiff6:arm64 (4.5.1+git230720-4ubuntu4) ... 901s Selecting previously unselected package libxft2:arm64. 901s Preparing to unpack .../090-libxft2_2.3.6-1build1_arm64.deb ... 901s Unpacking libxft2:arm64 (2.3.6-1build1) ... 901s Selecting previously unselected package libxss1:arm64. 901s Preparing to unpack .../091-libxss1_1%3a1.2.3-1build3_arm64.deb ... 901s Unpacking libxss1:arm64 (1:1.2.3-1build3) ... 901s Selecting previously unselected package libtk8.6:arm64. 901s Preparing to unpack .../092-libtk8.6_8.6.16-1_arm64.deb ... 901s Unpacking libtk8.6:arm64 (8.6.16-1) ... 901s Selecting previously unselected package libxt6t64:arm64. 901s Preparing to unpack .../093-libxt6t64_1%3a1.2.1-1.2build1_arm64.deb ... 901s Unpacking libxt6t64:arm64 (1:1.2.1-1.2build1) ... 901s Selecting previously unselected package node-normalize.css. 901s Preparing to unpack .../094-node-normalize.css_8.0.1-5_all.deb ... 901s Unpacking node-normalize.css (8.0.1-5) ... 901s Selecting previously unselected package zip. 901s Preparing to unpack .../095-zip_3.0-14ubuntu2_arm64.deb ... 901s Unpacking zip (3.0-14ubuntu2) ... 901s Selecting previously unselected package unzip. 901s Preparing to unpack .../096-unzip_6.0-28ubuntu6_arm64.deb ... 901s Unpacking unzip (6.0-28ubuntu6) ... 901s Selecting previously unselected package xdg-utils. 901s Preparing to unpack .../097-xdg-utils_1.2.1-2ubuntu1_all.deb ... 901s Unpacking xdg-utils (1.2.1-2ubuntu1) ... 901s Selecting previously unselected package r-base-core. 901s Preparing to unpack .../098-r-base-core_4.4.3-1_arm64.deb ... 901s Unpacking r-base-core (4.4.3-1) ... 902s Selecting previously unselected package liblzma-dev:arm64. 902s Preparing to unpack .../099-liblzma-dev_5.6.4-1_arm64.deb ... 902s Unpacking liblzma-dev:arm64 (5.6.4-1) ... 902s Selecting previously unselected package pkgconf-bin. 902s Preparing to unpack .../100-pkgconf-bin_1.8.1-4_arm64.deb ... 902s Unpacking pkgconf-bin (1.8.1-4) ... 902s Selecting previously unselected package pkgconf:arm64. 902s Preparing to unpack .../101-pkgconf_1.8.1-4_arm64.deb ... 902s Unpacking pkgconf:arm64 (1.8.1-4) ... 902s Selecting previously unselected package libtirpc-dev:arm64. 902s Preparing to unpack .../102-libtirpc-dev_1.3.4+ds-1.3_arm64.deb ... 902s Unpacking libtirpc-dev:arm64 (1.3.4+ds-1.3) ... 902s Selecting previously unselected package r-base-dev. 902s Preparing to unpack .../103-r-base-dev_4.4.3-1_all.deb ... 902s Unpacking r-base-dev (4.4.3-1) ... 902s Selecting previously unselected package pkg-r-autopkgtest. 902s Preparing to unpack .../104-pkg-r-autopkgtest_20231212ubuntu1_all.deb ... 902s Unpacking pkg-r-autopkgtest (20231212ubuntu1) ... 902s Selecting previously unselected package r-cran-base64enc. 902s Preparing to unpack .../105-r-cran-base64enc_0.1-3-3_arm64.deb ... 902s Unpacking r-cran-base64enc (0.1-3-3) ... 902s Selecting previously unselected package r-cran-cli. 902s Preparing to unpack .../106-r-cran-cli_3.6.4-1_arm64.deb ... 902s Unpacking r-cran-cli (3.6.4-1) ... 902s Selecting previously unselected package r-cran-colorspace. 902s Preparing to unpack .../107-r-cran-colorspace_2.1-1+dfsg-1_arm64.deb ... 902s Unpacking r-cran-colorspace (2.1-1+dfsg-1) ... 902s Selecting previously unselected package r-cran-commonmark. 902s Preparing to unpack .../108-r-cran-commonmark_1.9.2-2_arm64.deb ... 902s Unpacking r-cran-commonmark (1.9.2-2) ... 902s Selecting previously unselected package r-cran-evaluate. 902s Preparing to unpack .../109-r-cran-evaluate_1.0.3-1_all.deb ... 902s Unpacking r-cran-evaluate (1.0.3-1) ... 902s Selecting previously unselected package r-cran-fansi. 902s Preparing to unpack .../110-r-cran-fansi_1.0.5-1_arm64.deb ... 902s Unpacking r-cran-fansi (1.0.5-1) ... 903s Selecting previously unselected package r-cran-farver. 903s Preparing to unpack .../111-r-cran-farver_2.1.2-1_arm64.deb ... 903s Unpacking r-cran-farver (2.1.2-1) ... 903s Selecting previously unselected package r-cran-glue. 903s Preparing to unpack .../112-r-cran-glue_1.8.0-1_arm64.deb ... 903s Unpacking r-cran-glue (1.8.0-1) ... 903s Selecting previously unselected package r-cran-rlang. 903s Preparing to unpack .../113-r-cran-rlang_1.1.5-1_arm64.deb ... 903s Unpacking r-cran-rlang (1.1.5-1) ... 903s Selecting previously unselected package r-cran-lifecycle. 903s Preparing to unpack .../114-r-cran-lifecycle_1.0.4+dfsg-1_all.deb ... 903s Unpacking r-cran-lifecycle (1.0.4+dfsg-1) ... 903s Selecting previously unselected package r-cran-gtable. 903s Preparing to unpack .../115-r-cran-gtable_0.3.6+dfsg-1_all.deb ... 903s Unpacking r-cran-gtable (0.3.6+dfsg-1) ... 903s Selecting previously unselected package r-cran-isoband. 903s Preparing to unpack .../116-r-cran-isoband_0.2.7-1_arm64.deb ... 903s Unpacking r-cran-isoband (0.2.7-1) ... 903s Selecting previously unselected package r-cran-mass. 903s Preparing to unpack .../117-r-cran-mass_7.3-64-1_arm64.deb ... 903s Unpacking r-cran-mass (7.3-64-1) ... 903s Selecting previously unselected package r-cran-lattice. 903s Preparing to unpack .../118-r-cran-lattice_0.22-6-1_arm64.deb ... 903s Unpacking r-cran-lattice (0.22-6-1) ... 903s Selecting previously unselected package r-cran-nlme. 903s Preparing to unpack .../119-r-cran-nlme_3.1.167-1_arm64.deb ... 903s Unpacking r-cran-nlme (3.1.167-1) ... 903s Selecting previously unselected package r-cran-matrix. 903s Preparing to unpack .../120-r-cran-matrix_1.7-3-1_arm64.deb ... 903s Unpacking r-cran-matrix (1.7-3-1) ... 903s Selecting previously unselected package r-cran-mgcv. 903s Preparing to unpack .../121-r-cran-mgcv_1.9-1-1_arm64.deb ... 903s Unpacking r-cran-mgcv (1.9-1-1) ... 903s Selecting previously unselected package r-cran-labeling. 903s Preparing to unpack .../122-r-cran-labeling_0.4.3-1_all.deb ... 903s Unpacking r-cran-labeling (0.4.3-1) ... 903s Selecting previously unselected package r-cran-munsell. 904s Preparing to unpack .../123-r-cran-munsell_0.5.1-1_all.deb ... 904s Unpacking r-cran-munsell (0.5.1-1) ... 904s Selecting previously unselected package r-cran-r6. 904s Preparing to unpack .../124-r-cran-r6_2.6.1-1_all.deb ... 904s Unpacking r-cran-r6 (2.6.1-1) ... 904s Selecting previously unselected package r-cran-rcolorbrewer. 904s Preparing to unpack .../125-r-cran-rcolorbrewer_1.1-3-1build1_all.deb ... 904s Unpacking r-cran-rcolorbrewer (1.1-3-1build1) ... 904s Selecting previously unselected package r-cran-viridislite. 904s Preparing to unpack .../126-r-cran-viridislite_0.4.2-2_all.deb ... 904s Unpacking r-cran-viridislite (0.4.2-2) ... 904s Selecting previously unselected package r-cran-scales. 904s Preparing to unpack .../127-r-cran-scales_1.3.0-1_all.deb ... 904s Unpacking r-cran-scales (1.3.0-1) ... 904s Selecting previously unselected package r-cran-magrittr. 904s Preparing to unpack .../128-r-cran-magrittr_2.0.3-1_arm64.deb ... 904s Unpacking r-cran-magrittr (2.0.3-1) ... 904s Selecting previously unselected package r-cran-utf8. 904s Preparing to unpack .../129-r-cran-utf8_1.2.4-1_arm64.deb ... 904s Unpacking r-cran-utf8 (1.2.4-1) ... 904s Selecting previously unselected package r-cran-vctrs. 904s Preparing to unpack .../130-r-cran-vctrs_0.6.5-1_arm64.deb ... 904s Unpacking r-cran-vctrs (0.6.5-1) ... 904s Selecting previously unselected package r-cran-pillar. 904s Preparing to unpack .../131-r-cran-pillar_1.10.1+dfsg-1_all.deb ... 904s Unpacking r-cran-pillar (1.10.1+dfsg-1) ... 904s Selecting previously unselected package r-cran-pkgconfig. 904s Preparing to unpack .../132-r-cran-pkgconfig_2.0.3-2build1_all.deb ... 904s Unpacking r-cran-pkgconfig (2.0.3-2build1) ... 904s Selecting previously unselected package r-cran-tibble. 904s Preparing to unpack .../133-r-cran-tibble_3.2.1+dfsg-3_arm64.deb ... 904s Unpacking r-cran-tibble (3.2.1+dfsg-3) ... 904s Selecting previously unselected package r-cran-withr. 904s Preparing to unpack .../134-r-cran-withr_3.0.2+dfsg-1_all.deb ... 904s Unpacking r-cran-withr (3.0.2+dfsg-1) ... 904s Selecting previously unselected package r-cran-ggplot2. 904s Preparing to unpack .../135-r-cran-ggplot2_3.5.1+dfsg-1_all.deb ... 904s Unpacking r-cran-ggplot2 (3.5.1+dfsg-1) ... 905s Selecting previously unselected package r-cran-xfun. 905s Preparing to unpack .../136-r-cran-xfun_0.51+dfsg-1_arm64.deb ... 905s Unpacking r-cran-xfun (0.51+dfsg-1) ... 905s Selecting previously unselected package r-cran-highr. 905s Preparing to unpack .../137-r-cran-highr_0.11+dfsg-1_all.deb ... 905s Unpacking r-cran-highr (0.11+dfsg-1) ... 905s Selecting previously unselected package r-cran-yaml. 905s Preparing to unpack .../138-r-cran-yaml_2.3.10-1_arm64.deb ... 905s Unpacking r-cran-yaml (2.3.10-1) ... 905s Selecting previously unselected package libjs-mathjax. 905s Preparing to unpack .../139-libjs-mathjax_2.7.9+dfsg-1_all.deb ... 905s Unpacking libjs-mathjax (2.7.9+dfsg-1) ... 906s Selecting previously unselected package r-cran-knitr. 906s Preparing to unpack .../140-r-cran-knitr_1.49+dfsg-1_all.deb ... 906s Unpacking r-cran-knitr (1.49+dfsg-1) ... 906s Selecting previously unselected package r-cran-markdown. 906s Preparing to unpack .../141-r-cran-markdown_1.13-1_all.deb ... 906s Unpacking r-cran-markdown (1.13-1) ... 906s Selecting previously unselected package r-cran-matrixstats. 906s Preparing to unpack .../142-r-cran-matrixstats_1.5.0-1_arm64.deb ... 906s Unpacking r-cran-matrixstats (1.5.0-1) ... 906s Setting up libgraphite2-3:arm64 (1.3.14-2ubuntu1) ... 906s Setting up libpixman-1-0:arm64 (0.44.0-3) ... 906s Setting up libsharpyuv0:arm64 (1.5.0-0.1) ... 906s Setting up libncurses-dev:arm64 (6.5+20250216-2) ... 906s Setting up fonts-mathjax (2.7.9+dfsg-1) ... 906s Setting up liblerc4:arm64 (4.0.0+ds-5ubuntu1) ... 906s Setting up libjs-mathjax (2.7.9+dfsg-1) ... 906s Setting up libxrender1:arm64 (1:0.9.10-1.1build1) ... 906s Setting up libdatrie1:arm64 (0.2.13-3build1) ... 906s Setting up libxcb-render0:arm64 (1.17.0-2) ... 906s Setting up fonts-glyphicons-halflings (1.009~3.4.1+dfsg-3) ... 906s Setting up unzip (6.0-28ubuntu6) ... 906s Setting up x11-common (1:7.7+23ubuntu3) ... 907s Setting up libdeflate0:arm64 (1.23-1) ... 907s Setting up libxcb-shm0:arm64 (1.17.0-2) ... 907s Setting up libreadline-dev:arm64 (8.2-6) ... 907s Setting up libgomp1:arm64 (15-20250222-0ubuntu1) ... 907s Setting up libjbig0:arm64 (2.1-6.1ubuntu2) ... 907s Setting up libpcre2-16-0:arm64 (10.45-1) ... 907s Setting up zip (3.0-14ubuntu2) ... 907s Setting up libpcre2-32-0:arm64 (10.45-1) ... 907s Setting up libblas3:arm64 (3.12.1-2) ... 907s update-alternatives: using /usr/lib/aarch64-linux-gnu/blas/libblas.so.3 to provide /usr/lib/aarch64-linux-gnu/libblas.so.3 (libblas.so.3-aarch64-linux-gnu) in auto mode 907s Setting up libtirpc-dev:arm64 (1.3.4+ds-1.3) ... 907s Setting up libpkgconf3:arm64 (1.8.1-4) ... 907s Setting up fonts-dejavu-mono (2.37-8) ... 907s Setting up libmpc3:arm64 (1.3.1-1build2) ... 907s Setting up libtcl8.6:arm64 (8.6.16+dfsg-1) ... 907s Setting up icu-devtools (76.1-1ubuntu2) ... 907s Setting up fonts-dejavu-core (2.37-8) ... 907s Setting up pkgconf-bin (1.8.1-4) ... 907s Setting up libjpeg-turbo8:arm64 (2.1.5-3ubuntu2) ... 907s Setting up libgfortran5:arm64 (15-20250222-0ubuntu1) ... 907s Setting up libwebp7:arm64 (1.5.0-0.1) ... 907s Setting up liblzma-dev:arm64 (5.6.4-1) ... 907s Setting up libubsan1:arm64 (15-20250222-0ubuntu1) ... 907s Setting up zlib1g-dev:arm64 (1:1.3.dfsg+really1.3.1-1ubuntu1) ... 907s Setting up libpcre2-posix3:arm64 (10.45-1) ... 907s Setting up libjs-highlight.js (9.18.5+dfsg1-2) ... 907s Setting up libhwasan0:arm64 (15-20250222-0ubuntu1) ... 907s Setting up libasan8:arm64 (15-20250222-0ubuntu1) ... 907s Setting up libharfbuzz0b:arm64 (10.2.0-1) ... 907s Setting up libthai-data (0.1.29-2build1) ... 907s Setting up libxss1:arm64 (1:1.2.3-1build3) ... 907s Setting up libpaper2:arm64 (2.2.5-0.3) ... 907s Setting up libtsan2:arm64 (15-20250222-0ubuntu1) ... 907s Setting up libjs-jquery (3.6.1+dfsg+~3.5.14-1) ... 907s Setting up libisl23:arm64 (0.27-1) ... 907s Setting up libdeflate-dev:arm64 (1.23-1) ... 907s Setting up node-normalize.css (8.0.1-5) ... 907s Setting up libicu-dev:arm64 (76.1-1ubuntu2) ... 907s Setting up xdg-utils (1.2.1-2ubuntu1) ... 907s update-alternatives: using /usr/bin/xdg-open to provide /usr/bin/open (open) in auto mode 907s Setting up libcc1-0:arm64 (15-20250222-0ubuntu1) ... 907s Setting up liblsan0:arm64 (15-20250222-0ubuntu1) ... 907s Setting up libblas-dev:arm64 (3.12.1-2) ... 907s update-alternatives: using /usr/lib/aarch64-linux-gnu/blas/libblas.so to provide /usr/lib/aarch64-linux-gnu/libblas.so (libblas.so-aarch64-linux-gnu) in auto mode 907s Setting up dctrl-tools (2.24-3build3) ... 907s Setting up libjs-bootstrap (3.4.1+dfsg-3) ... 907s Setting up libitm1:arm64 (15-20250222-0ubuntu1) ... 907s Setting up libbz2-dev:arm64 (1.0.8-6) ... 907s Setting up libjpeg8:arm64 (8c-2ubuntu11) ... 907s Setting up libice6:arm64 (2:1.1.1-1) ... 907s Setting up libjpeg-turbo8-dev:arm64 (2.1.5-3ubuntu2) ... 907s Setting up liblapack3:arm64 (3.12.1-2) ... 907s update-alternatives: using /usr/lib/aarch64-linux-gnu/lapack/liblapack.so.3 to provide /usr/lib/aarch64-linux-gnu/liblapack.so.3 (liblapack.so.3-aarch64-linux-gnu) in auto mode 907s Setting up libpcre2-dev:arm64 (10.45-1) ... 907s Setting up fontconfig-config (2.15.0-2ubuntu1) ... 907s Setting up libpng-dev:arm64 (1.6.47-1) ... 907s Setting up libpaper-utils (2.2.5-0.3) ... 907s Setting up libjs-jquery-datatables (1.11.5+dfsg-2) ... 907s Setting up pkgconf:arm64 (1.8.1-4) ... 907s Setting up libthai0:arm64 (0.1.29-2build1) ... 907s Setting up liblapack-dev:arm64 (3.12.1-2) ... 907s update-alternatives: using /usr/lib/aarch64-linux-gnu/lapack/liblapack.so to provide /usr/lib/aarch64-linux-gnu/liblapack.so (liblapack.so-aarch64-linux-gnu) in auto mode 907s Setting up cpp-14-aarch64-linux-gnu (14.2.0-17ubuntu3) ... 907s Setting up libtiff6:arm64 (4.5.1+git230720-4ubuntu4) ... 907s Setting up libfontconfig1:arm64 (2.15.0-2ubuntu1) ... 907s Setting up libgcc-14-dev:arm64 (14.2.0-17ubuntu3) ... 907s Setting up libjpeg8-dev:arm64 (8c-2ubuntu11) ... 907s Setting up libstdc++-14-dev:arm64 (14.2.0-17ubuntu3) ... 907s Setting up libsm6:arm64 (2:1.2.4-1) ... 907s Setting up libgfortran-14-dev:arm64 (14.2.0-17ubuntu3) ... 907s Setting up fontconfig (2.15.0-2ubuntu1) ... 909s Regenerating fonts cache... done. 909s Setting up libxft2:arm64 (2.3.6-1build1) ... 909s Setting up libtk8.6:arm64 (8.6.16-1) ... 909s Setting up libpango-1.0-0:arm64 (1.56.2-1) ... 909s Setting up libjpeg-dev:arm64 (8c-2ubuntu11) ... 910s Setting up libcairo2:arm64 (1.18.2-2) ... 910s Setting up cpp-aarch64-linux-gnu (4:14.2.0-1ubuntu1) ... 910s Setting up libxt6t64:arm64 (1:1.2.1-1.2build1) ... 910s Setting up cpp-14 (14.2.0-17ubuntu3) ... 910s Setting up cpp (4:14.2.0-1ubuntu1) ... 910s Setting up gcc-14-aarch64-linux-gnu (14.2.0-17ubuntu3) ... 910s Setting up libpangoft2-1.0-0:arm64 (1.56.2-1) ... 910s Setting up libpangocairo-1.0-0:arm64 (1.56.2-1) ... 910s Setting up gcc-aarch64-linux-gnu (4:14.2.0-1ubuntu1) ... 910s Setting up g++-14-aarch64-linux-gnu (14.2.0-17ubuntu3) ... 910s Setting up gcc-14 (14.2.0-17ubuntu3) ... 910s Setting up r-base-core (4.4.3-1) ... 910s Creating config file /etc/R/Renviron with new version 910s Setting up r-cran-labeling (0.4.3-1) ... 910s Setting up r-cran-lattice (0.22-6-1) ... 910s Setting up r-cran-nlme (3.1.167-1) ... 910s Setting up r-cran-farver (2.1.2-1) ... 910s Setting up r-cran-viridislite (0.4.2-2) ... 910s Setting up gfortran-14-aarch64-linux-gnu (14.2.0-17ubuntu3) ... 910s Setting up g++-aarch64-linux-gnu (4:14.2.0-1ubuntu1) ... 910s Setting up gfortran-aarch64-linux-gnu (4:14.2.0-1ubuntu1) ... 910s Setting up r-cran-commonmark (1.9.2-2) ... 910s Setting up g++-14 (14.2.0-17ubuntu3) ... 910s Setting up r-cran-r6 (2.6.1-1) ... 910s Setting up gfortran-14 (14.2.0-17ubuntu3) ... 910s Setting up r-cran-magrittr (2.0.3-1) ... 910s Setting up r-cran-rlang (1.1.5-1) ... 910s Setting up r-cran-matrixstats (1.5.0-1) ... 910s Setting up r-cran-xfun (0.51+dfsg-1) ... 910s Setting up r-cran-withr (3.0.2+dfsg-1) ... 910s Setting up r-cran-base64enc (0.1-3-3) ... 910s Setting up r-cran-yaml (2.3.10-1) ... 910s Setting up r-cran-evaluate (1.0.3-1) ... 910s Setting up r-cran-highr (0.11+dfsg-1) ... 910s Setting up r-cran-fansi (1.0.5-1) ... 910s Setting up r-cran-mass (7.3-64-1) ... 910s Setting up r-cran-glue (1.8.0-1) ... 910s Setting up r-cran-cli (3.6.4-1) ... 910s Setting up r-cran-lifecycle (1.0.4+dfsg-1) ... 910s Setting up gcc (4:14.2.0-1ubuntu1) ... 910s Setting up r-cran-pkgconfig (2.0.3-2build1) ... 910s Setting up r-cran-utf8 (1.2.4-1) ... 910s Setting up r-cran-colorspace (2.1-1+dfsg-1) ... 910s Setting up r-cran-markdown (1.13-1) ... 910s Setting up r-cran-rcolorbrewer (1.1-3-1build1) ... 910s Setting up r-cran-isoband (0.2.7-1) ... 910s Setting up r-cran-gtable (0.3.6+dfsg-1) ... 910s Setting up r-cran-matrix (1.7-3-1) ... 910s Setting up r-cran-knitr (1.49+dfsg-1) ... 910s Setting up r-cran-mgcv (1.9-1-1) ... 910s Setting up g++ (4:14.2.0-1ubuntu1) ... 910s update-alternatives: using /usr/bin/g++ to provide /usr/bin/c++ (c++) in auto mode 910s Setting up build-essential (12.10ubuntu1) ... 910s Setting up r-cran-vctrs (0.6.5-1) ... 910s Setting up r-cran-pillar (1.10.1+dfsg-1) ... 910s Setting up r-cran-munsell (0.5.1-1) ... 910s Setting up r-cran-tibble (3.2.1+dfsg-3) ... 910s Setting up gfortran (4:14.2.0-1ubuntu1) ... 910s update-alternatives: using /usr/bin/gfortran to provide /usr/bin/f95 (f95) in auto mode 910s 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 910s update-alternatives: using /usr/bin/gfortran to provide /usr/bin/f77 (f77) in auto mode 910s 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 910s Setting up r-cran-scales (1.3.0-1) ... 910s Setting up r-base-dev (4.4.3-1) ... 910s Setting up r-cran-ggplot2 (3.5.1+dfsg-1) ... 910s Setting up pkg-r-autopkgtest (20231212ubuntu1) ... 910s Processing triggers for libc-bin (2.41-1ubuntu2) ... 910s Processing triggers for man-db (2.13.0-1) ... 912s Processing triggers for install-info (7.1.1-1) ... 915s autopkgtest [15:55:04]: test pkg-r-autopkgtest: /usr/share/dh-r/pkg-r-autopkgtest 915s autopkgtest [15:55:04]: test pkg-r-autopkgtest: [----------------------- 916s Test: Try to load the R library matrixStats 916s 916s R version 4.4.3 (2025-02-28) -- "Trophy Case" 916s Copyright (C) 2025 The R Foundation for Statistical Computing 916s Platform: aarch64-unknown-linux-gnu 916s 916s R is free software and comes with ABSOLUTELY NO WARRANTY. 916s You are welcome to redistribute it under certain conditions. 916s Type 'license()' or 'licence()' for distribution details. 916s 916s R is a collaborative project with many contributors. 916s Type 'contributors()' for more information and 916s 'citation()' on how to cite R or R packages in publications. 916s 916s Type 'demo()' for some demos, 'help()' for on-line help, or 916s 'help.start()' for an HTML browser interface to help. 916s Type 'q()' to quit R. 916s 916s > library('matrixStats') 916s > 916s > 916s Other tests are currently unsupported! 916s They will be progressively added. 916s autopkgtest [15:55:05]: test pkg-r-autopkgtest: -----------------------] 917s autopkgtest [15:55:06]: test pkg-r-autopkgtest: - - - - - - - - - - results - - - - - - - - - - 917s pkg-r-autopkgtest PASS 917s autopkgtest [15:55:06]: @@@@@@@@@@@@@@@@@@@@ summary 917s run-unit-test PASS 917s pkg-r-autopkgtest PASS 923s nova [W] Using flock in prodstack6-arm64 923s Creating nova instance adt-plucky-arm64-r-cran-matrixstats-20250315-153949-juju-7f2275-prod-proposed-migration-environment-20-1887113b-412b-40db-85c4-4da79e0a4b43 from image adt/ubuntu-plucky-arm64-server-20250315.img (UUID bd6e766c-b51f-4b53-86d6-23aa4d18f524)... 923s nova [W] Timed out waiting for 17cd20e4-7ca0-4aa6-a26b-315dfc6d24ad to get deleted. 923s nova [W] Using flock in prodstack6-arm64 923s Creating nova instance adt-plucky-arm64-r-cran-matrixstats-20250315-153949-juju-7f2275-prod-proposed-migration-environment-20-1887113b-412b-40db-85c4-4da79e0a4b43 from image adt/ubuntu-plucky-arm64-server-20250315.img (UUID bd6e766c-b51f-4b53-86d6-23aa4d18f524)... 923s nova [W] Timed out waiting for e41a20e3-0062-473f-9172-4da07a18922a to get deleted.