Writing Functions that involve other softwares

Hello

I am trying to write a function that should call a software( .exe file). For normal use, system() command is used. But if we want to write a function based on this how we can do so?

I have been trying with this script and I know its wrong.
testu <- function(infile) {system("software.exe -cater_small infile -output out.fasta")}
infile <- file.path("E:/...../combinedfile.fas")

Kindly explain this.
Thanks

If I understand you correctly, you want to substitute infile with the actual file path, correct?

There are multiple ways to do this:

infile <- "variable"
sprintf("You can put your %s here", infile)
#> [1] "You can put your variable here"
paste0("You can use paste0 to put your ", infile, " inside of a string")
#> [1] "You can use paste0 to put your variable inside of a string"
library(glue)
glue("You can also use `glue` library and put your {infile} like this")
#> You can also use `glue` library and put your variable like this
1 Like

This mailing list thread on specifying external dependencies in R packages might help! (It's a bit old now, though.)

1 Like

Thank you mishabalyasin brother.
I had tried the solutions suggested and they helped me. Finally ended up with manipulations in system2 command that help me writing some functions invoking executeable files.