I am trying to call system functions in R. I am using a mac. If I pass a built-in function (e.g. ln), it works no problem:
command <- "ls"
cat(command, "\n")
try(system(command))
I get a list of the directory.
However, if I install functions from third parties (e.g. binaries), it doesn't work (even if it works in the terminal).
command <- "bedtools ..."
cat(command, "\n")
try(system(command))
I get the following error:
sh: bedtool..:command not found
Do you think it's a PATH problem?
Thank you!
Considered for sure that you 'installed' the command (it exists in a bin somewhere) and after reading yout comment:
if I open RStudio where the function's binaries are located (e.g. open -a RStudio), it works no problem.
I guess that it is a PATH problem indeed. A possible fix would be:
Sys.setenv(PATH=paste(Sys.getenv("PATH"), "/the/bin/folder/of/bedtools", sep=":"))
Where is your bedtools saved? i.e. what is the output from
which bedtools
If it isn't in your
usr/bin
then the system command gives that error. Save betools there and it should work.
from the system help file it suggests trying the
Sys.which
command on your shell input first to see if it will work in system.
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