In Revolution R Enterprise console,

devtools::check("C:/Users/User/Documents/Revolution/mypackage") 

produced

checking sizes of PDF files under 'inst/doc' ... NOTE Unable to find GhostScript executable to run checks on size reduction 

with no any other warnings/errors/notes. So, (even though AFAIK this note is not that much important for eventual check), I wanted to get rid of this warning (since I wanna put .PDF files into mypackage\inst\doc folder produced outside of R).

I have Ghostscript installed in my notebook. I got helped via:

> 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] "" 

What I did (and took error again) is:

> 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 

Upon deepening, I found: ["These errors occur when one tries to assign a value to a variable that doesn't exist, or that R can't treat as a name. (A name is a variable type that holds a variable name."]

What I am basically trying to do is to set my GS executable (C:\Program Files (x86)\gs\gs9.19\bin\gswin32c.exe) to "R_GSCMD". Any help would be greatly appreciated.

2 Answers

On consulting ?Sys.setenv it confirms my expectation that the call should instead be:

Sys.setenv(R_GSCMD = "C:\\Program Files (x86)\\gs\\gs9.19\\bin\\gswin32c.exe") 
3

Because the gs versions change all the time, you may like a little R script for it!

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.exe 

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.