在 R 中安装包:'stdlib.h' 找不到文件

Install package in R: 'stdlib.h' file not found

我正在尝试从 RStudio 安装 RMark。我注意到无法安装所需的软件包之一。好像 C 有一些问题。你能帮我吗?

> install.packages('mvtnorm')
trying URL 'https://cran.rstudio.com/src/contrib/mvtnorm_1.0-8.tar.gz'
Content type 'application/x-gzip' length 159539 bytes (155 KB)
==================================================
downloaded 155 KB

During startup - Warning messages:
1: Setting LC_CTYPE failed, using "C" 
2: Setting LC_TIME failed, using "C" 
3: Setting LC_MESSAGES failed, using "C" 
4: Setting LC_MONETARY failed, using "C" 
* installing *source* package 'mvtnorm' ...
** package 'mvtnorm' successfully unpacked and MD5 sums checked
** libs
x86_64-apple-darwin13.4.0-clang -I"/anaconda3/lib/R/include" -DNDEBUG   -D_FORTIFY_SOURCE=2 -mmacosx-version-min=10.9 -I/anaconda3/include   -fPIC  -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -I/anaconda3/include -fdebug-prefix-map==/usr/local/src/conda/- -fdebug-prefix-map==/usr/local/src/conda-prefix  -c C_FORTRAN_interface.c -o C_FORTRAN_interface.o
In file included from C_FORTRAN_interface.c:8:
In file included from ./mvtnorm.h:2:
/anaconda3/lib/R/include/R.h:55:11: fatal error: 'stdlib.h' file not found
# include <stdlib.h> /* Not used by R itself, but widely assumed in packages */
          ^~~~~~~~~~
1 error generated.
make: *** [/anaconda3/lib/R/etc/Makeconf:160: C_FORTRAN_interface.o] Error 1
ERROR: compilation failed for package 'mvtnorm'
* removing '/anaconda3/lib/R/library/mvtnorm'
Warning in install.packages :
  installation of package 'mvtnorm' had non-zero exit status

The downloaded source packages are in
 '/private/var/folders/5m/lbpq3yj53n7clgx4r1fy6blr0000gn/T/RtmppNGt3S/downloaded_packages'
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
> 

您已经使用 conda 安装了 R(我猜,从路径)所以使用 conda procedures 而不是 install.packages().

安装包

如果您尝试安装 conda 存储库中不存在的软件包,您还可以安装所需的 SDK headers for Mojave

open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg

Source