Error: install.packages("DescTools")

I also tried CRAN, but failed. I am using R.4.4.1.

install.packages("DescTools")

Downloading packages -------------------------------------------------------

  • Downloading DescTools from CRAN ... OK [2.5 Mb in 0.73s]
    Successfully downloaded 1 package in 1.1 seconds.

The following package(s) will be installed:

  • DescTools [0.99.56]
    These packages will be installed into "~/Shiny/6236-001/Eff/renv/library/linux-rhel-8.9/R-4.4/x86_64-pc-linux-gnu".

Do you want to proceed? [Y/n]: Y

Installing packages --------------------------------------------------------

  • Installing DescTools ... FAILED
    Error: Error installing package 'DescTools':
    =====================================
  • installing source package ‘DescTools’ ...
    ** package ‘DescTools’ successfully unpacked and MD5 sums checked
    ** using staged installation
    ** libs
    using C compiler: ‘gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-22)’
    using Fortran compiler: ‘GNU Fortran (GCC) 8.5.0 20210514 (Red Hat 8.5.0-22)’
    using C++ compiler: ‘g++ (GCC) 8.5.0 20210514 (Red Hat 8.5.0-22)’
    using C++17
    gcc -I"/home/shared_R-versions/4.4.1/lib64/R/include" -DNDEBUG -I'/home/jyue/Shiny/6236-001/Eff/renv/library/linux-rhel-8.9/R-4.4/x86_64-pc-linux-gnu/Rcpp/include' -I/usr/local/include -fpic -g -O2 -c ADinf.c -o ADinf.o
    gcc -I"/home/shared_R-versions/4.4.1/lib64/R/include" -DNDEBUG -I'/home/jyue/Shiny/6236-001/Eff/renv/library/linux-rhel-8.9/R-4.4/x86_64-pc-linux-gnu/Rcpp/include' -I/usr/local/include -fpic -g -O2 -c AnDarl.c -o AnDarl.o
    g++ -std=gnu++17 -I"/home/shared_R-versions/4.4.1/lib64/R/include" -DNDEBUG -I'/home/jyue/Shiny/6236-001/Eff/renv/library/linux-rhel-8.9/R-4.4/x86_64-pc-linux-gnu/Rcpp/include' -I/usr/local/include -fpic -g -O2 -c RcppExports.cpp -o RcppExports.o
    g++ -std=gnu++17 -I"/home/shared_R-versions/4.4.1/lib64/R/include" -DNDEBUG -I'/home/jyue/Shiny/6236-001/Eff/renv/library/linux-rhel-8.9/R-4.4/x86_64-pc-linux-gnu/Rcpp/include' -I/usr/local/include -fpic -g -O2 -c TukeyBiweight.cpp -o TukeyBiweight.o
    TukeyBiweight.cpp: In function ‘double tbrm(const std::vector&, double)’:
    TukeyBiweight.cpp:91:16: error: ‘reduce’ is not a member of ‘std’
    std::reduce(wtx.begin(), wtx.end(), 0.0, std::plus())
    ^~~~~~
    TukeyBiweight.cpp:91:16: note: suggested alternative: ‘replace’
    std::reduce(wtx.begin(), wtx.end(), 0.0, std::plus())
    ^~~~~~
    replace
    TukeyBiweight.cpp:92:20: error: ‘reduce’ is not a member of ‘std’
    / std::reduce(wt.begin(), wt.end(), 0.0, std::plus());
    ^~~~~~
    TukeyBiweight.cpp:92:20: note: suggested alternative: ‘replace’
    / std::reduce(wt.begin(), wt.end(), 0.0, std::plus());
    ^~~~~~
    replace
    make: *** [/home/shared_R-versions/4.4.1/lib64/R/etc/Makeconf:204: TukeyBiweight.o] Error 1
    ERROR: compilation failed for package ‘DescTools’
  • removing ‘/home/jyue/Shiny/6236-001/Eff/renv/staging/1/DescTools’
    install of package 'DescTools' failed [error code 1]

Unfortunately it seems that DescTools does not build with the default C++ compiler that RHEL 8 has. This is also why P3M [1] does not have a binary package for RHEL 8. You might want to report this to the package maintainer, in case they can and want to support the default compiler in RHEL 8.

On my RHEL 8 (UBI) container, I could install these two packages to get gcc 12:

dnf install gcc-toolset-12-gcc-gfortran gcc-toolset-12-gcc-c++

and then configure gcc-12 + etc. to be the default compilers for R. You can do this via a ~/.R/Makevars file, but if only a single package is the problem, then you can also do it temporarily:

PATH=/opt/rh/gcc-toolset-12/root/bin/:$PATH R

and then install the package from source:

install.packages("DescTools")
library(DescTools)

[1] Posit Package Manager