Achal Neupane
Achal Neupane

Reputation: 5729

How do I test if system executable is present within R

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?

Upvotes: 4

Views: 124

Answers (1)

Dirk is no longer here
Dirk is no longer here

Reputation: 368599

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> 

Upvotes: 6

Related Questions