Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add Rtools\bin to the system path in R

Tags:

r

shiny

Am running a Shiny app from https://github.com/MikeJSeo/SAM and the code to access it:

install.packages(c("samr", "matrixStats", "GSA", "shiny", "openxlsx"))
source("http://bioconductor.org/biocLite.R")
biocLite("impute")
library(shiny)
runGitHub("SAM", "MikeJSeo")

The app runs great but I get a error when trying to save the output. This is the error I obtain:

Warning: Error in : zipping up workbook failed. Please make sure Rtools is installed or a zip application is available to R.
Try installr::install.rtools() on Windows. If the "Rtools\bin" directory does not appear in Sys.getenv("PATH") please add it to the system PATH 
or set this within the R session with Sys.setenv("R_ZIPCMD" = "path/to/zip.exe")

I tried;

Sys.getenv("PATH")

and the output is

[1] "C:\\Program Files\\R\\R-3.4.1\\bin\\x64;C:\\ProgramData\\Oracle\\Java\\javapath;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program Files\\ActivIdentity\\ActivClient\\;C:\\Program Files (x86)\\ActivIdentity\\ActivClient\\;C:\\Program Files (x86)\\Addinsoft\\XLSTAT\\;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\"

Am assuming that my error arrises because I dont have the "Rtools\bin" directory. I have tried,

Sys.setenv("R_ZIPCMD" = "mypath/to/zip.exe")

but not luck. So how can I go about correcting this?

like image 843
Eddy Zavala Avatar asked Nov 28 '17 19:11

Eddy Zavala


2 Answers

This fixed my problem.

library(devtools)
Sys.setenv(PATH = paste("C:/Rtools/bin", Sys.getenv("PATH"), sep=";"))
Sys.setenv(BINPREF = "C:/Rtools/mingw_$(WIN)/bin/")
like image 131
Eddy Zavala Avatar answered Nov 19 '22 03:11

Eddy Zavala


To answer to John Doe's question, you can make sure that Rtools is in the path always and only for R by adding this line to your .Rprofile:

Sys.setenv(PATH = paste("C:/Rtools/bin", Sys.getenv("PATH"), sep=";"))

.Rprofile needs to be located at the path pointed by the command Sys.getenv("HOME").

like image 43
Jean Paul Avatar answered Nov 19 '22 01:11

Jean Paul