4

我一直在为模拟项目开发 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
4

2 回答 2

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/"')

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

于 2013-02-07T16:47:07.287 回答
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 中通常的蓝色。 在此处输入图像描述

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

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

在此处输入图像描述

于 2016-04-15T15:51:05.100 回答