将软件包安装到R上 [英] Installing packages onto R

查看:88
本文介绍了将软件包安装到R上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于某种原因,我突然无法在R中安装软件包(我随后已更新到R的最新版本,并且正在运行Windows 7).例如,如果我输入:

For some reason I am suddenly not able to install packages in R (I have subsequently updated to the latest version of R and am running Windows 7). For example, if I type:

install.packages('beeswarm')

将软件包安装到"D:/Rlibs"中(因为未指定"lib") ---请选择要在此会话中使用的CRAN镜像---尝试使用URL'

Installing package into ‘D:/Rlibs’ (as ‘lib’ is unspecified) --- Please select a CRAN mirror for use in this session --- trying URL 'http://www.stats.bris.ac.uk/R/bin/windows/contrib/3.0/beeswarm_0.1.5.zip' Content type 'text/html' length unknown opened URL downloaded 1859 bytes

read.dcf(file.path(pkgname,"DESCRIPTION"),c("Package", 类型")):无法打开连接另外:警告 消息:1:在解压缩(zipname,exdir = dest)中:提取错误1 来自zip文件2:在read.dcf(file.path(pkgname,"DESCRIPTION"))中, c("Package","Type")):无法打开压缩文件 'beeswarm/DESCRIPTION',可能的原因是'No such file or directory'

Error in read.dcf(file.path(pkgname, "DESCRIPTION"), c("Package", "Type")) : cannot open the connection In addition: Warning messages: 1: In unzip(zipname, exdir = dest) : error 1 in extracting from zip file 2: In read.dcf(file.path(pkgname, "DESCRIPTION"), c("Package", "Type")) : cannot open compressed file 'beeswarm/DESCRIPTION', probable reason 'No such file or directory'

我已阅读到在Windows 7中对写入某些文件夹等的权限可能存在重要限制.因此,我花了一些时间在我计算机的非默认区域中安装R和库文件夹,并允许本人拥有某些文件夹的权利,但无济于事.可能也很重要的是当我键入以下内容:

I have read that in Windows 7 there can be important restrictions on rights to writing to certain folders etc. so I've gone to some lengths to install R and library folders in non-default areas of my computer, and to allow myself rights to certain folders, but to no avail. Possibly also of importance is when I type:

.libPaths()

# [1] "D:/Rlibs"                                             
# [2] "C:/Users/L.Halsey/Documents/R/win-library/3.0"        
# [3] "C:/Users/L.Halsey/Documents/Documents/R-3.0.1/library"

我创建了几个文件夹,以尝试创建一个可以成功安装库的文件夹,并使用开始按钮中的环境变量"将其设置为R识别.我不知道如何删除它们中的任何一个-不知道这是否与我由于某种原因现在无法安装/更新软件包的整体问题有关.

I have created several folders in an attempt to create one that I could successfully install libraries into and set them up to be recognised by R using 'environment variables' from the start button. I don't know how to delete any of them though - not sure if this is relevant to my overall problem of not now being able to install/update packages for some reason.

推荐答案

所报告的错误是无法打开连接.在Windows中,通常防火墙问题,请参见Windows R常见问题解答.通常的第一次尝试应该是运行internet2.dll.在控制台会话中,您可以使用:

The error being reported is inability to open a connection. In Windows that is often a firewall problem and is in the Windows R FAQ. The usual first attempt should be to run internet2.dll. From a console session you can use:

setInternet2(TRUE)

(您以为这不是由于您的库设置而引起的错误.该错误没有说明权限.)我不认为仅键入.libPaths会返回该字符向量,因为在我的计算机上,我需要键入.libPaths()看到类似的内容.如果要减少库的位数,可以使用.libPaths函数来设置值.这将选择现有路径的第二和第三条

(You are correct in thinking this is not due to your library setup. The error says nothing about permissions.) I don't think just typing .libPaths should return that character vector since on my machine I would need to type .libPaths() to see something like that. If you wanted to reduce the number of places for libraries you can use the .libPaths function for setting the values. This would pick the second and third of the existing paths

 .libPaths( .libPaths()[2:3] )

内部调用检索路径向量,而外部调用将其设置为简化向量.

The inner call retrieves the path vector and the outer call sets it to a reduced vector.

这篇关于将软件包安装到R上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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