创建Web服务器CRAN存储库 - 对目录结构进行故障排除

时间:2012-06-16 11:10:41

标签: r packaging

我正在试图弄清楚如何创建一个http CRAN-repository。我试图遵循local CRAN repository而没有取得真正的成功。

基本上我的本地存储库设置如下(我不确定源目录是否有效,但是为了以防万一我添加了它):

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

我在the manualSONIVIS wiki寻求任何帮助,但我必须是盲人......请指导我:-S

1 个答案:

答案 0 :(得分:3)

经过一番搜索,我发现:

  1. 该软件包不应由R CMD BUILD构建,而应由R CMD INSTALL --build
  2. 构建
  3. 而不是使用贡献,它似乎适用于回购:

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