我想使用Rcpp,但是当我使用cppFunction()时,我收到一条消息来安装Rtools,如下所示。
即使我安装它,我也想继续安装。
当我使用3.4.1时,我曾经拥有它,但是我遇到了问题,所以我删除了它并安装了版本3.4.2。
也许有一个原因,但我不知道如何解决它。我使用以下代码删除所有包并重新安装Rcpp。
> cppFunction("
+ NumericVector insertsortcpp(NumericVector vector) {
+ int n = vector.size();
+ double tmp;
+ for(int i=1; i<n; i=i+1) {
+ tmp=vector[i];
+ int j=i-1;
+ while(j>=0 && vector[j]>tmp) {
+ vector[j+1]=vector[j];
+ j=j-1;
+ }
+ vector[j+1]=tmp;
+ }
+ return vector;
+ }")
c:/Rtools/mingw_64/bin/g++ -I"C:/R/R-34~1.2/include" -DNDEBUG -I"C:/Users/ji/Documents/R/win-library/3.4/Rcpp/include" -I"C:/Users/ji/AppData/Local/Temp/RtmpQjHy3A/sourceCpp-x86_64-w64-mingw32-0.12.14" -I"d:/Compiler/gcc-4.9.3/local330/include" -O2 -Wall -mtune=core2 -c file22cc1b9753bc.cpp -o file22cc1b9753bc.o
c:/Rtools/mingw_64/bin/g++: not found
make: *** [file22cc1b9753bc.o] Error 127
Warning message:
running command 'make -f "C:/R/R-34~1.2/etc/x64/Makeconf" -f "C:/R/R-34~1.2/share/make/winshlib.mk" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="sourceCpp_4.dll" WIN=64 TCLBIN=64 OBJECTS="file22cc1b9753bc.o"' had status 2
Error in sourceCpp(code = code, env = env, rebuild = rebuild, cacheDir = cacheDir, :
Error 1 occurred building shared library.
我的代码和错误陈述。
R version 3.4.2 (2017-09-28) -- "Short Summer"
Copyright (C) 2017 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
[Workspace loaded from ~/.RData]
这是R的初始屏幕。
我知道很多问题,但我无处可问。
感谢您的帮助。