It seems like your task boils down to two things:
- Reading some data in R
- Using that data in
system
command
The first subject is discussed at lengths at SO and on the net so there is little point in covering it one more time. Broadly speaking, in majority of cases you will need to load into R environment whatever you want to use, fish out, the first line/cell/etc. and pass those values to along with your system
syntax.
Launching your app
If I understand your request correctly you are simply interested in passing some string to the system
command, on the lines of this discussion. So your code could look like:
system("C:\\me\\my_app.EXE")
Passing parameters is simple, you could make use of the paste
function:
paste("C:\\me\\my_app.EXE", "/switch_on", sep = " ")
Naturally, the second element could be created dynamically:
if (this == that) {
mySwitch <- "/yes"
}
Then you would simply use mySwitch
in your paste
syntax:
paste("C:\\me\\my_app.EXE", mySwitch, sep = " ")
As side point, you may also consider making use of the file.path
if you wish to construct a dynamic path to your file.
Alternative approach
If passing single line via system
is not enough, you could consider writing your lines to a text file and running a more elaborate batch file. This would be rather exotic solution but if you insist on some deep integration with an external application it may make sense. You could then automatically write a number of lines to your batch file each consisting of command to process another chunk of data or send different command, etc. Or on the lines of this solution you may run your external program in a loop, jumping though bits of data, which probably would make better sense in your case.