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?
Use Sys.which()
.
R> testForMyProg <- function(prg) { if (Sys.which(prg) == "") message("Please install ", prg) }
R> testForMyProg("lalalalaNope")
Please install lalalalaNope
R> testForMyProg("gcc")
R>
R>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With