在革命R企业控制台,
devtools::check("C:/Users/User/Documents/Revolution/mypackage")生产的
checking sizes of PDF files under 'inst/doc' ... NOTE
Unable to find GhostScript executable to run checks on size reduction没有任何其他警告/错误/注释。所以,(尽管AFAIK这个注释对于最终检查来说并不那么重要),我想去掉这个警告(因为我想把.PDF文件放到R之外产生的mypackage\inst\doc文件夹中)。
我在笔记本上安装了Ghostscript。我通过以下途径得到帮助:
> help("R_GSCMD")
R_GSCMD: Optional. The path to Ghostscript, used by dev2bitmap, bitmap and embedFonts.
Consulted when those functions are invoked.
Since it will be treated as if passed to system, spaces and shell metacharacters should be escaped.
> Sys.getenv("R_GSCMD")
[1] ""我所做的(又犯了错误)是:
> Sys.setenv("R_GSCMD") <- "C:\\Program Files (x86)\\gs\\gs9.19\\bin\\gswin32c.exe"
Error in Sys.setenv("R_GSCMD") <- "C:\\Program Files (x86)\\gs\\gs9.19\\bin\\gswin32c.exe" :
target of assignment expands to non-language object在深化时,我发现:“当一个人试图将一个值赋值给一个不存在的变量,或者R不能被看作是一个名称时,就会发生这些错误。(名称是一个包含变量名的变量类型。”
基本上,我要做的是将我的GS可执行文件(C:\Program (x86)\gs\gs9.19\bin\gswin32c.exe)设置为"R_GSCMD“。任何帮助都将不胜感激。
发布于 2016-05-12 21:57:58
在咨询?Sys.setenv时,它证实了我的期望,即调用应该是:
Sys.setenv(R_GSCMD = "C:\\Program Files (x86)\\gs\\gs9.19\\bin\\gswin32c.exe")发布于 2019-01-03 10:58:30
因为gs版本一直在变化,你可能会喜欢它的一个小R脚本!
system.partition = 'c:'
dirs = c('Program Files', 'Program Files (x86)')
for (dir in dirs) {
dir.list = list.dirs(file.path(system.partition, dir), recursive = FALSE)
GsinList = grepl(pattern = 'gs', x = dir.list)
if (sum(GsinList) > 0) {
gsDirectory = which(GsinList == TRUE)
GsExeFiles = list.files(
dir.list[gsDirectory],
recursive = TRUE,
pattern = 'gswin',
include.dirs = TRUE,
full.names = TRUE
)[1]
message('Gs found! ~> ',GsExeFiles)
Sys.setenv(R_GSCMD = GsExeFiles)
break
}
}
Gs found! ~> c:/Program Files/gs/gs9.21/bin/gswin64.exehttps://stackoverflow.com/questions/37197603
复制相似问题