5

我试图弄清楚如何创建一个 http CRAN 存储库。我试图遵循本地 CRAN 存储库但没有真正成功。

基本上我的本地存储库是这样设置的(我不确定源目录是否有意义,但我添加它以防万一):

library(tools)
reposRoot <- "C:\\Software\\repository"
r_ver <- "2.15"
contribPaths <- c(source = "src\\contrib", windows = "bin\\windows\\contrib")
write_PACKAGES(paste(reposRoot, contribPaths["windows"], r_ver, sep="\\"), 
               type="win.binary",
               unpacked=FALSE,
               latestOnly=FALSE,
               verbose=TRUE)
write_PACKAGES(paste(reposRoot, contribPaths["source"], r_ver, sep="\\"), 
               type="source",
               unpacked=FALSE,
               latestOnly=FALSE,
               verbose=TRUE)

然后我将存储库上传到我的网络服务器:cran.gforge.se但是当我尝试找到我得到的包时:

> available.packages(contriburl="http://cran.gforge.se")
Warning: unable to access index for repository http://cran.gforge.se
     Package Version Priority Depends Imports LinkingTo Suggests Enhances OS_type License Archs
     File Repository

所以我的结论是它找不到存储库,但奇怪的是当我尝试时:

> available.packages(contriburl="http://cran.gforge.se/bin/windows/contrib/2.15")
      Package Version Priority Depends                                                   Imports
Gmisc "Gmisc" "0.2"   NA       "grid, testthat, miscTools, rms, Hmisc, survival, cmprsk" NA     
      LinkingTo Suggests Enhances OS_type License      Archs File
Gmisc NA        NA       NA       NA      "GPL (>= 2)" NA    NA  
      Repository                                                    
Gmisc "http://cran.gforge.se/bin/windows/contrib/2.15/./src/contrib"

它实际上找到了我漂亮的包裹,但路径都混淆了。如果我尝试运行安装,我会得到:

> install.packages("Gmisc", contriburl="http://cran.gforge.se/")
Installing package(s) into ‘C:/Users/max/R/win-library/2.15’
(as ‘lib’ is unspecified)
Warning in install.packages :
  package ‘Gmisc’ is not available (for R version 2.15.0)
> install.packages("Gmisc", contriburl="http://cran.gforge.se/bin/windows/contrib/2.15")
Installing package(s) into ‘C:/Users/max/R/win-library/2.15’
(as ‘lib’ is unspecified)
trying URL 'http://cran.gforge.se/bin/windows/contrib/2.15/./src/contrib/Gmisc_0.2.zip'
Warning in install.packages :
  cannot open: HTTP status was '500 Internal Server Error'
Error in download.file(url, destfile, method, mode = "wb", ...) : 
  cannot open URL 'http://cran.gforge.se/bin/windows/contrib/2.15/./src/contrib/Gmisc_0.2.zip'
Warning in install.packages :
  download of package ‘Gmisc’ failed

我已经在手册SONIVIS wiki中寻找任何帮助,但我一定是盲人......请指导我:-S

4

1 回答 1

3

经过一番搜索,我发现:

  1. 包不应该由构建,R CMD BUILD而是由R CMD INSTALL --build
  2. 它似乎与 repos 一起使用,而不是使用 contriburl:

    install.packages("Gmisc", repos=c("http://ftp.sunet.se/pub/lang/CRAN", "http://cran.gforge.se"), dependencies=TRUE)

于 2012-06-19T19:34:27.523 回答