Installing R Packages in Jupyter rstatix

Options

I am able to install some R packages in my Jupyter Workspace (tidyverse, ggplot2), but others I hit a wall, getting an error like:

“installation of package ‘rstatix’ had non-zero exit status”
Updating HTML index of packages in '.Library'

The current one I'm struggling with is rstatix, which is a pretty popular library and a dependency of several other libraries I'd like to use.

Does anyone have good troubleshooting tips for installing libraries that won't install?

Please 💡/💖/👍/😊 this post if you read it and found it helpful.

Please accept the answer if it solved your problem.

Best Answer

  • DavidChurchman
    Answer ✓
    Options

    I think I found a solution (at least for rstatix), but hopefully this helps with others as well:

    A dependency of a lot of R packages is the 'nloptr' package (including rstatix), which in turn requires 'cmake'. I believe cmake should be available on the operating system already, but for some reason the Jupyter environment can't see it. I was able to install cmake using a terminal with this:

    pip install cmake

    Then, I was able to run install.packages('rstatix') in a notebook. This took over 5 minutes to execute.

    Also, throughout the troubleshooting process, I had to "restore kernel defaults" a bunch of times. I would know I needed to do this because I would try installing a package like ggplot2 that I was able to install before, but would get an error. You should definitely start with this, and then if something doesn't work, do it again.

    Please 💡/💖/👍/😊 this post if you read it and found it helpful.

    Please accept the answer if it solved your problem.

Answers

  • ArborRose
    Options

    I don't work with R, but I have a friend who has significant R experience. Passing this along….

    1. Check Internet Connection: Ensure that your internet connection is stable and that you can access CRAN (Comprehensive R Archive Network), where R packages are hosted. Sometimes, network issues can lead to failed installations.
    2. Update R and RStudio: Make sure you are using the latest versions of R and RStudio. Older versions may have compatibility issues with newer packages.
    3. Check Package Dependencies: Some R packages depend on other software or libraries that need to be installed separately. Make sure you have all the necessary dependencies installed on your system.
    4. Install System Dependencies: Certain R packages require system-level dependencies to be installed. These dependencies may include external libraries or tools. You can often find information about required system dependencies in the package documentation or on the package's CRAN page.
    5. Check Package Documentation: Review the documentation for the package you are trying to install. Sometimes, package authors provide specific instructions or troubleshooting tips for installation.
    6. Try Installing from Source: Instead of installing the package binary, try installing the package from source. You can do this by setting type = "source" in the install.packages() function.

    ** Was this post helpful? Click Agree or Like below. **
    ** Did this solve your problem? Accept it as a solution! **

  • DavidChurchman
    Options

    Unfortunately, I cannot update the version of R, since that's managed by Domo. I'm working through dependencies, but it's turtles all the way down. They get the same error. I'll play with 'try installing from source', but I'm curious if anyone has any actual experience with Jupyter and R? Most of the documentation and troubleshooting online is geared (like this answer from ArborRose) to RStudio, which is installed locally.

    Please 💡/💖/👍/😊 this post if you read it and found it helpful.

    Please accept the answer if it solved your problem.

  • DavidChurchman
    Answer ✓
    Options

    I think I found a solution (at least for rstatix), but hopefully this helps with others as well:

    A dependency of a lot of R packages is the 'nloptr' package (including rstatix), which in turn requires 'cmake'. I believe cmake should be available on the operating system already, but for some reason the Jupyter environment can't see it. I was able to install cmake using a terminal with this:

    pip install cmake

    Then, I was able to run install.packages('rstatix') in a notebook. This took over 5 minutes to execute.

    Also, throughout the troubleshooting process, I had to "restore kernel defaults" a bunch of times. I would know I needed to do this because I would try installing a package like ggplot2 that I was able to install before, but would get an error. You should definitely start with this, and then if something doesn't work, do it again.

    Please 💡/💖/👍/😊 this post if you read it and found it helpful.

    Please accept the answer if it solved your problem.