Unable to run RStoolbox for remote sensing classification because I cannot install/re-install package XML

I am rather new at R and ran into problems with RStoolbox after not having used it for 1.5 years:

install_github("bleutner/RStoolbox")
Downloading GitHub repo bleutner/RStoolbox@master

Error: Failed to install 'RStoolbox' from GitHub:
(converted from warning) package ‘XML’ is not available (for R version 3.6.3)

I get the following error when trying to install XML directly:

  • installing source package 'XML' ...
    ** using staged installation
    Please define LIB_XML (and LIB_ZLIB, LIB_ICONV)
    ERROR: configuration failed for package 'XML'
  • removing 'C:/Programs/R/R-3.6.3/library/XML'
    Warning in install.packages :
    installation of package ‘C:/Users/petra.kaczensky/AppData/Local/Temp/RtmpawUMuv/downloaded_packages/XML_3.99-0.tar.gz’ had non-zero exit status

This happens because the latest version of XML is only available for R version 4.

You have two options:

  • Upgrade to R version 4.x
  • Install an older version of XML

To achieve the second option, you could try:

devtools::install_version('XML', '3.99-0.3')

You can find more about old versions of XML at https://packagemanager.rstudio.com/client/#/repos/1/packages/XML

Thanks - I fixed it.