3

Suppose I need to run a system executable (myexecutable) file within R. I want to print a message "Please install myexecutable to run this proprogram" if it is not installed. How do I do it in R?

MAPK
  • 5,365
  • 2
  • 32
  • 74

1 Answers1

5

Use Sys.which().

Worked example

R> testForMyProg <- function(prg) { if (Sys.which(prg) == "") message("Please install ", prg) }
R> testForMyProg("lalalalaNope")
Please install lalalalaNope
R> testForMyProg("gcc")
R> 
R> 
Dirk Eddelbuettel
  • 347,098
  • 55
  • 623
  • 708