安装R包rDEA失败:编译错误求助
It looks like the core issue here is that rDEA only exists as source code, and your system lacks the necessary compilers to build it from scratch. Let’s walk through targeted fixes step by step, tailored to your operating system:
1. Install Required Compilers
The compilation error occurs because R can’t locate the C/C++/Fortran tools needed to build the package. Here’s how to get them set up:
Windows
- You’ll need Rtools34 (specifically built for R 3.4.x versions). Download it from the official Rtools archive.
- During installation, make sure to check the box labeled "Add Rtools to system PATH"—this is critical; if you skip it, R won’t detect the compilers.
macOS
- First, install Xcode Command Line Tools by running this in your terminal:
xcode-select --install - Next, install gfortran (required for Fortran code compilation). For R 3.4.x, use the gfortran 6.3 binary compatible with older macOS versions.
- After installation, confirm the path to gfortran is set correctly in your shell profile (like
~/.bash_profileor~/.zshrc).
Linux (Debian/Ubuntu-based)
- Open your terminal and run these commands to install build essentials and the Fortran compiler:
sudo apt-get update sudo apt-get install build-essential gfortran
2. Verify Compiler Detection in R
Once compilers are installed, open RStudio and run these commands to confirm R can find them:
# Check for C compiler Sys.which("gcc") # Check for Fortran compiler Sys.which("gfortran")
If both return valid file paths (not empty strings), your setup is ready. If not, double-check that the compilers are added to your system’s PATH.
3. Reinstall rDEA with Source Compilation
Now try installing the package again. Explicitly tell R to use source installation with:
install.packages("rDEA", type = "source")
If you still hit Fortran-related errors, specify the Fortran compiler path directly:
install.packages("rDEA", type = "source", configure.args = "--with-gfortran=/path/to/your/gfortran")
Replace /path/to/your/gfortran with the actual path returned by Sys.which("gfortran").
4. Alternative: Check for Pre-compiled Binaries (If Available)
Third-party repositories sometimes have pre-compiled binaries for older R versions. For Windows, check the CRAN archive for rDEA to see if a binary compatible with R 3.4.4 exists. If you find one, install it using:
install.packages("rDEA", repos = "https://cran.r-project.org/src/contrib/Archive/rDEA/", type = "binary")
Note: This is hit-or-miss, as rDEA may not have had pre-compiled binaries for your R version.
If none of these steps work, it’s possible rDEA has compatibility issues with R 3.4.4. Upgrading to a newer R version (which has better compiler support) could be a last resort if you’re able to update your environment.
内容的提问来源于stack exchange,提问作者Jessica Milligan

