首页 > 解决方案 > 无法在 R 3.5.1 中安装包 data.table

问题描述

我正在使用下面的脚本来安装一些软件包。除包 data.table 外,所有包都已安装。

# ipak function: install and load multiple R packages.
# check to see if packages are installed. Install them if they are not, then load them into the R session.
ipak <- function(pkg){
  new.pkg <- pkg[!(pkg %in% installed.packages()[, "Package"])]
  if (length(new.pkg))
    install.packages(new.pkg, dependencies = TRUE, repos='http://cran.rstudio.com/')
  sapply(pkg, require, character.only = TRUE)
}

# usage
list.of.packages <- c("curl", "methods", "jsonlite", "tseries", "forecast", "sweep","timetk","tidyquant","data.table","stringr","httr","zoo","lubridate","tidyr","tidyverse","forecastHybrid")
ipak(list.of.packages)

我应该怎么做才能在 Mac 的 R3.5.1 中安装 data.table 包?

我得到的错误信息是:

* installing *source* package ‘data.table’ ...
** package ‘data.table’ successfully unpacked and MD5 sums checked
** libs
clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/usr/local/include  -fopenmp -fPIC  -Wall -g -O2  -c assign.c -o assign.o
clang: error: unsupported option '-fopenmp'
make: *** [assign.o] Error 1
ERROR: compilation failed for package ‘data.table’
* removing ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/data.table’

    Warning messages:
    1: In install.packages(new.pkg, dependencies = TRUE, repos = "http://cran.rstudio.com/") :
      installation of package ‘data.table’ had non-zero exit status
    2: In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE,  :
      there is no package called ‘data.table’

我还尝试使用 -> 安装 data.table

install.packages("data.table", type = "source",
    repos = "http://Rdatatable.github.io/data.table")

这也失败了。

我也尝试在下面使用它也失败了->

library(devtools)
install_github("Rdatatable/data.table", build_vignettes=FALSE)

标签: rdata.tableinstall.packages

解决方案


推荐阅读