求助:无法在Mac上安装O'Reilly《R语言袖珍指南》配套nutshell包
nutshell Package Installation on MacOS Catalina Hey there! I totally get how frustrating it is when you’re following a learning book and hit a package installation roadblock. Let’s break down what’s going on and fix this step by step.
Why You’re Seeing This Error
Your R version (3.2.1) is extremely outdated—released back in 2015—and it’s incompatible with both MacOS Catalina’s modern system libraries and the nutshell_2.0 package. Downgrading R was actually the wrong move here; Catalina doesn’t play nice with such old R versions, which is why even local archive installs are failing.
Step-by-Step Fixes
Let’s start with the most critical fix first:
Upgrade your R version
Revert back to R 4.0.2 (or even newer if possible—versions 4.1+ have better Catalina support). Old R versions on Catalina struggle with system-level dependencies, so upgrading will eliminate most compatibility issues right off the bat.Install the
nutshellpackage usingdevtools
Once you’re on a newer R version, the easiest way to install archived packages is with thedevtoolspackage:- First, install
devtoolsif you haven’t already:install.packages("devtools") - Then install the archived
nutshellpackage directly from the URL:devtools::install_url("https://cran.r-project.org/src/contrib/Archive/nutshell/nutshell_2.0.tar.gz")
- First, install
Manual Local Installation (If
devtoolsFails)
If you still want to use the downloaded.tar.gzfile:- Open RStudio, go to Tools > Install Packages
- In the "Install from" dropdown, select Package Archive File (.tar.gz)
- Navigate to your downloaded
nutshell_2.0.tar.gzfile and select it - If you get dependency errors, unpack the tar.gz file and check its
DESCRIPTIONfile to see which packages are required. Install those dependencies first withinstall.packages("dependency_package_name").
Troubleshooting Dependencies
If you run into errors about missing packages (likeggplot2,plyr, etc.), just install those dependencies first usinginstall.packages()—newer R versions will pull compatible versions of these packages automatically.
Key Note
Never downgrade R to match an old package on a modern OS like Catalina. Newer R versions are built to work with current system libraries, and most archived packages will still install correctly with tools like devtools.
内容的提问来源于stack exchange,提问作者SMH

