R自定义包安装文件错误

时间:2013-02-07 15:39:51

标签: windows r install package

我一直在研究模拟项目的R包,在家里的计算机上我已经使用RStudio来成功构建和安装它。然而,在大学的另一台机器上我遇到了麻烦...如果我尝试在RStudio中构建一个二进制文件,它也安装它,我得到一个错误,如果我只是编译一个源来获得.tar.gz它的工作原理,但是当我来安装时,我又得到了错误。两次出现错误的读数如下。我认为这与图书馆有关,但为什么这会与我的家用电脑不同,我不知道,我不是程序员,并且在这台机器上安装R和RTools和RStudio与我个人完全一样机。 - 我有几天的管理员权限。

install.packages("speEaR_1.0.tar.gz", repos=NULL, type="source")
Installing package(s) into ‘\\ueahome5/ressci17/yrq12edu/data/Documents/R/win-library/2.15’
(as ‘lib’ is unspecified)
* installing *source* package 'speEaR' ...
** R
** preparing package for lazy loading
** help
Warning: C:/Users/yrq12edu/AppData/Local/Temp/Rtmp84HJPx/R.INSTALL7e81a241d97/speEaR/man/makeSetMatrix.Rd:25: unknown macro '\begin'
Warning: C:/Users/yrq12edu/AppData/Local/Temp/Rtmp84HJPx/R.INSTALL7e81a241d97/speEaR/man/makeSetMatrix.Rd:26: unknown macro '\item'
Warning: C:/Users/yrq12edu/AppData/Local/Temp/Rtmp84HJPx/R.INSTALL7e81a241d97/speEaR/man/makeSetMatrix.Rd:30: unknown macro '\end'
*** installing help indices
** building package indices
** testing if installed package can be loaded
*** arch - i386
Warning in library(pkg_name, lib.loc = lib, character.only = TRUE, logical.return = TRUE) :
  no library trees found in 'lib.loc'
Error: loading failed
Execution halted
*** arch - x64
Warning in library(pkg_name, lib.loc = lib, character.only = TRUE, logical.return = TRUE) :
  no library trees found in 'lib.loc'
Error: loading failed
Execution halted
ERROR: loading failed for 'i386', 'x64'
* removing '\\ueahome5/ressci17/yrq12edu/data/Documents/R/win-library/2.15/speEaR'
Warning messages:
1: running command 'C:/PROGRA~1/R/R-215~1.2/bin/i386/R CMD INSTALL -l "\\ueahome5/ressci17/yrq12edu/data/Documents/R/win-library/2.15"   "speEaR_1.0.tar.gz"' had status 1 
2: In install.packages("speEaR_1.0.tar.gz", repos = NULL, type = "source") :
  installation of package ‘speEaR_1.0.tar.gz’ had non-zero exit status

2 个答案:

答案 0 :(得分:2)

我几天前遇到过类似的错误。这是因为您正在安装到此目录:

 '\\ueahome5/ressci17/yrq12edu/data/Documents/R/win-library/2.15/speEaR'

我猜它已连接到网络驱动器。你应该做的是转到那个网络驱动器并明确地复制地址,如

 'M:/ressci17/yrq12edu/data/Documents/R/win-library/2.15/'

然后在安装时使用它来指定库位置。例如:

install.packages("speEaR_1.0.tar.gz", repos=NULL, type="source",lib='U:/ressci17/yrq12edu/data/Documents/R/win-library/2.15/')

或尝试 devtools ,解压缩tar球并执行以下操作:

library(devtools)
has_devel() ## check if your Rtools are properly installed
check('speEaR')
##build('speEaR')
install("speEaR",args='-l "U:/ressci17/yrq12edu/data/Documents/R/win-library/2.15/"')

这就是我解决问题的方法。

答案 1 :(得分:0)

我发现问题与R脚本中的roxygen注释中的Windows路径反斜杠有关。解决方案是将反斜杠更改为单个正斜杠。 示例:最初我的roxygen信息是这样的:

#'  Performs a search in MS Windows file system for all files in the
#'  `C:\USERS\MYNAME` directory, and all directories below that

会产生此警告消息:

* installing to library 'C:/Users/MYNAME/Documents/R/win-library/3.2'
* installing *source* package 'whatever' ...
** R
** preparing package for lazy loading
** help
Warning: C:/Users/MYNAME/Documents/R/CODE/whatever/man/func.Rd:11: unknown macro '\USERS'
Warning: C:/Users/MYNAME/Documents/R/CODE/whatever/man/func.Rd:11: unknown macro '\MYNAME'
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (whatever)

线索是文本是橙色而不是RStudio中通常的蓝色。 enter image description here

因此,将反斜杠更改为正斜杠并且不会生成任何警告消息,并且所有的roxygen注释现在都是蓝色。

#'  Performs a search in MS Windows file system for all files in the
#'  `C:/USERS/MYNAME` directory, and all directories below

enter image description here