Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I test if system executable is present within R

Tags:

r

system

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?

like image 950
MAPK Avatar asked Oct 12 '25 09:10

MAPK


1 Answers

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> 
like image 112
Dirk Eddelbuettel Avatar answered Oct 13 '25 21:10

Dirk Eddelbuettel