无法使用 install.packages 安装 R-forge 包 [英] Cannot install R-forge package using install.packages

查看:34
本文介绍了无法使用 install.packages 安装 R-forge 包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题超过超过结束,在 R-sig-finance 邮件列表中,但我认为它没有被问到堆栈溢出.

This, question, is, asked, over, and, over, and, over, on the R-sig-finance mailing list, but I do not think it has been asked on stackoverflow.

事情是这样的:

在哪里可以获得 R-forge 上托管的最新版本的 XYZ 包?我试图用 install.packages 安装它,但结果是这样的:

Where can I obtain the latest version of package XYZ that is hosted on R-forge? I tried to install it with install.packages, but this is what happened:

> install.packages("XYZ",repos="http://r-forge.r-project.org")
Warning message: package ‘XYZ’ is not available (for R version 2.15.0)

查看 XYZ 的 R-forge 网站,我发现该软件包无法构建.因此,没有下载源的链接.有没有其他办法获取源代码?一旦我得到源代码,我怎样才能把它变成一个我可以用 library("XYZ") 加载的包?

Looking on the R-forge website for XYZ, I see that the package failed to build. Therefore, there is no link to download the source. Is there any other way to get the source code? Once I get the source code, how can I turn that into a package that I can load with library("XYZ")?

推荐答案

R-Forge 可能由于一些不同的原因无法构建包.可能是这样文档尚未更新以反映代码中的最新更改.或者,可能是某些依赖项在构建时不可用.

R-Forge may fail to build a package for a few different reasons. It could be that the documentation has not been updated to reflect recent changes in the code. Or, it could be that some of the dependencies were not available at build time.

您可以使用 svn 检出源代码.首先,在项目上搜索R-Forge 网站并转到项目主页 - 例如 http://r-forge.r-project.org/projects/returnanalytics/单击 SCM 链接可进入这样的页面 http://r-forge.r-project.org/scm/?group_id=579

You can checkout the source code using svn. First, search for the project on the R-Forge website and go to the project home page -- for example http://r-forge.r-project.org/projects/returnanalytics/ Click the SCM link to get to a page like this http://r-forge.r-project.org/scm/?group_id=579

此页面将告诉您用于检出项目的命令.在这种情况下,你得到

This page will tell you the command to use to checkout the project. In this case you get

可以使用以下命令通过匿名访问来检出该项目的 SVN 存储库.

This project's SVN repository can be checked out through anonymous access with the following command(s).

svn 结帐 svn://svn.r-forge.r-project.org/svnroot/returnanalytics/

svn checkout svn://svn.r-forge.r-project.org/svnroot/returnanalytics/

如果您使用的是 Windows,您可能想要下载并安装 TortoiseSVN

If you are on Windows, you probably want to download and install TortoiseSVN

安装 TortoiseSVN 后,您可以在 Windows 资源管理器窗口中右键单击并选择SVN 结帐".在存储库的 URL:"中字段,输入除svn结帐"您在 R-Forge 上找到的命令的一部分.在这种情况下,你会输入svn://svn.r-forge.r-project.org/svnroot/returnanalytics/".

Once you have installed TortoiseSVN, you can right click in a Windows Explorer window and select "SVN checkout". In the "URL of repository:" field, enter everything except the "svn checkout " part of the command that you found on R-Forge. In this case, you'd enter "svn://svn.r-forge.r-project.org/svnroot/returnanalytics/".

点击确定后,项目将下载到当前目录.

When you click OK, the project will be downloaded into the current directory.

如果您使用的是类似 UNIX 的系统(或者如果您安装了命令行客户端工具当您安装 TortoiseSVN for Windows 时,这不是默认设置),您可以在终端(系统终端,而不是 R 终端)中输入 R-forge 给您的命令

If you are on a UNIX-alike system (or if you installed the command line client tools when you installed TortoiseSVN for Windows, which is not the default), you can type the command that R-forge gave you in your terminal (System terminal, not the R terminal)

svn checkout svn://svn.r-forge.r-project.org/svnroot/returnanalytics/

这将在当前工作目录下创建一个新目录包含包中的所有文件.在该目录的顶层将是一个名为pkg"的子目录.这个特定的项目(returnanalytics)包含多个包.

That will create a new directory under the current working directory that contains all of the files in the package. In the top level of that directory will be a subdirectory called "pkg". This particular project (returnanalytics) contains more than one package.

ls returnanalytics/pkg
#FactorAnalytics  MPO  PApages  PerformanceAnalytics  PortfolioAnalytics

但是一些 R-forge 项目只有一个包.例如

But some R-forge projects only have a single package. e.g.

svn checkout svn://svn.r-forge.r-project.org/svnroot/random/
#Checked out revision 14.
ls random/pkg
#DESCRIPTION  inst  man  NAMESPACE  R

现在你有一份所有代码的本地副本,如果你想能够安装包,你必须先构建它.

Now that you have a local copy all of the code, if you would like to be able to install the package, you have to build it first.

注意事项:由于 R-Forge 未能构建软件包,因此很有可能包有问题.因此,如果您只是构建它,您可能会发现有些事情没有按预期工作.特别是,很可能有缺少或不完整的文档.

A WORD OF CAUTION: Since R-Forge failed to build the package, there is a good chance that there are problems with the package. Therefore, if you just build it, you may find that some things do not work as expected. In particular, it is likely that there is missing or incomplete documentation.

如果您使用的是类似 UNIX 的系统,则可以相对轻松地构建和安装该软件包.对于像 returnanalytics 这样的多包项目,如果要安装,例如这PortfolioAnalytics 包,你可以这样做

If you are on a UNIX-alike system, the package can be built and installed relatively easily. For a multi-package project like returnanalytics, if you want to install, e.g. the PortfolioAnalytics package, you can do it like this

R --vanilla CMD INSTALL --build returnanalytics/pkg/PortfolioAnalytics 

投资组合分析"是包含包的目录的名称你想构建/安装.对于单包项目,您可以像这样构建和安装这个

"PortfolioAnalytics" is the name of the directory that contains the package that you want to build/install. For a single-package project, you can build and install like this

R --vanilla CMD INSTALL --build random/pkg

如果您想在 Windows 上构建/安装软件包,请参阅 这个问题 并按照 两个 @JoshuaUlrich 提供的链接

If you would like to build/install a package on Windows, see this question and follow the two links that @JoshuaUlrich provided

更多信息可以在 R 安装和管理中找到R-Forge 用户手册,以及SVN 手册.

More information can be found in R Installation and Administration, the R-Forge User Manual, and the SVN manual.

这篇关于无法使用 install.packages 安装 R-forge 包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆