在Windows上正确安装Rtools

时间:2016-11-16 14:19:59

标签: r installation packages

我在办公室工作的Windows 7企业版,并且遵守相当严格的IT规则,没有管理员权限。

我在“C:\ Program Files(x86)”下安装了Rtools版本3.4.0.1962 当我尝试从源代码安装R软件包时(因为我想要64位版本),我得到了错误

Syntax error: "(" unexpected

可能是“C:\ Program Files(x86)”对Rtools来说是错误的地方吗?

电话

> install.packages("largeVis", type = "source")

给出错误:

Installing package into ‘C:/Users/wkawar/Documents/R/win-library/3.3’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/largeVis_0.1.10.tar.gz'
Content type 'application/x-gzip' length 4968932 bytes (4.7 MB)
downloaded 4.7 MB

* installing *source* package 'largeVis' ...
** package 'largeVis' successfully unpacked and MD5 sums checked
** libs

*** arch - i386
C:/Program Files (x86)/Rtools/mingw_32/bin/g++  -std=c++0x -I"C:/PROGRA~1/R/R-33~1.1/include" -DNDEBUG    -I"C:/Users/wkawar/Documents/R/win-library/3.3/Rcpp/include" -I"C:/Users/wkawar/Documents/R/win-library/3.3/RcppProgress/include" -I"C:/Users/wkawar/Documents/R/win-library/3.3/RcppArmadillo/include" -I"C:/Users/wkawar/Documents/R/win-library/3.3/testthat/include" -I"d:/Compiler/gcc-4.9.3/local330/include" -DARMA_64BIT_WORDR_XTRA_CXXFLAGS = -DARMA_64BIT_WORD -fopenmp   -O2 -Wall  -mtune=core2 -c RcppExports.cpp -o RcppExports.o
Syntax error: "(" unexpected
make: *** [RcppExports.o] Error 2
Warning: running command 'make -f "Makevars" -f "C:/PROGRA~1/R/R-33~1.1/etc/i386/Makeconf" -f "C:/PROGRA~1/R/R-33~1.1/share/make/winshlib.mk" -f "C:/Users/wkawar/Documents/.R/Makevars" CXX='$(CXX1X) $(CXX1XSTD)' CXXFLAGS='$(CXX1XFLAGS)' CXXPICFLAGS='$(CXX1XPICFLAGS)' SHLIB_LDFLAGS='$(SHLIB_CXX1XLDFLAGS)' SHLIB_LD='$(SHLIB_CXX1XLD)' SHLIB="largeVis.dll" OBJECTS="RcppExports.o checkfunctions.o dbscan.o denseneighbors.o distance.o edgeweights.o gradients.o hdbscan.o largeVis.o neighbors.o optics.o sparse.o test-runner.o testcfunctions.o"' had status 2
ERROR: compilation failed for package 'largeVis'
* removing 'C:/Users/wkawar/Documents/R/win-library/3.3/largeVis'
* restoring previous 'C:/Users/wkawar/Documents/R/win-library/3.3/largeVis'
Warning in install.packages :
  running command '"C:/PROGRA~1/R/R-33~1.1/bin/x64/R" CMD INSTALL -l "C:\Users\wkawar\Documents\R\win-library\3.3" C:\Users\wkawar\AppData\Local\Temp\Rtmpai8yTY/downloaded_packages/largeVis_0.1.10.tar.gz' had status 1
Warning in install.packages :
  installation of package ‘largeVis’ had non-zero exit status

这是我的

> sessionInfo()
R version 3.3.1 (2016-06-21)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                           LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] tools_3.3.1

1 个答案:

答案 0 :(得分:1)

适用于 R 3.6.1 上的 RTools 3.4.0.1964 的简单解决方案,无需在其他路径中重新安装。

更改 .Renviron 中的目录标签以使用不带空格的简短格式(基于 Roland 的建议)。

df1 <- data.frame(Cancer = c("AASTR", "ACRM"), Gene = c("IDH1", "NRAS"))
df2 <- data.frame(Acronym = c("AASTR", "ACRM"), Full_Name = c("Anaplastic Astrocytoma", "Acral Melanoma"))

dplyr::left_join(df1, df2, by = c("Cancer" = "Acronym"))

  Cancer Gene              Full_Name
1  AASTR IDH1 Anaplastic Astrocytoma
2   ACRM NRAS         Acral Melanoma

请注意,此 .Renviron 与 RTools 4.0 指令不同,但改编自早期版本的另一个 StackOverflow 解决方案。

此后运行良好,通过了 RTools 4.0 说明中建议的测试:

PATH = "C:/PROGRA~2/Rtools/bin;${PATH}" BINPREF = "C:/PROGRA~2/Rtools/mingw_$(WIN)/bin/" 找到了 make 文件

Sys.which("make") 不再抱怨“(”意外