You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

R(v3.5.3)从GitHub安装webr包遇依赖运算符错误,求解决方案

Fixing the "Invalid comparison operator in dependency: >=" Error When Installing GitHub's webr Package in R 3.5.3

I’ve run into similar dependency parsing headaches with older R versions before, so here are some practical, actionable solutions tailored to your situation:

1. Manually Clone the Repo and Fix the DESCRIPTION File

The core issue is that your outdated R 3.5.3 doesn’t recognize the modern dependency syntax used in the GitHub repo’s DESCRIPTION file. Here’s how to work around it:

  • First, clone the repository to your local machine (install git2r if you don’t have it already):
    install.packages("git2r")
    git2r::clone("https://github.com/cardiomoon/webr.git")
    # Alternatively, use your system's Git command line: git clone https://github.com/cardiomoon/webr.git
    
  • Navigate to the cloned folder, open the DESCRIPTION file, and scan for lines in Depends, Imports, or Suggests that use syntax like ggplot2 >= 3.0.0. Rewrite these to the old-R-compatible format: ggplot2 (>= 3.0.0) (wrap the version constraint in parentheses).
  • Install the modified local package:
    devtools::install_local("path/to/your/cloned/webr/directory")
    

2. Downgrade devtools to a Version Optimized for Old R

Even though you’re running the latest devtools, newer versions are built for modern R releases. Try reverting to devtools 1.13.6—this version handled legacy dependency syntax much better:

# Uninstall current devtools first
remove.packages("devtools")
# Install the older, compatible version
library(devtools)
install_version("devtools", version = "1.13.6", repos = "http://cran.us.r-project.org")
# Now attempt installing the GitHub webr package again
devtools::install_github("cardiomoon/webr")

3. Upgrade Your R Version (Most Permanent Fix)

R 3.5.3 is quite dated (released in 2019), and most modern packages have dropped support for its strict dependency parsing rules. If you can afford to upgrade to R 4.0 or later, this will not only resolve this specific error but also prevent a host of other compatibility issues down the line. Once upgraded, installing the GitHub webr package should work without hitches.

4. Extract Just the PieDonut() Function

If you only need the PieDonut() function and want to skip full package installation, you can grab the function code directly:

  • Go to the webr repo’s R folder and open PieDonut.R.
  • Copy the entire function definition into your R console or script.
  • Run the code to define the function in your environment—you’ll be able to use it immediately without installing the full package.

内容的提问来源于stack exchange,提问作者LeBasti

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.12 05:11:48