Hi all R users: Does anybody have the experience of running an external software in R? I try to use R to run ANSYS software, which is a engineering simulation package. I ever have done this task in Matlab platform by executing the following code line: system('"C:\Program Files\Ansys Inc\v100\ANSYS\bin\intel\ansys100" -b -p ane3fl -i D:\Ansys\MyAnsysCode.txt -o D:\Ansys\vm5.out'); Any idea regarding implementing this work is very welcome. David [[alternative HTML version deleted]]
?system But this begs the question: WHY would you want to do this? More specifically, what should R communicate to your other software, and what should the other software communicate to R? Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Tue, Sep 6, 2016 at 6:13 PM, Marino David <davidmarino838 at gmail.com> wrote:> Hi all R users: > > Does anybody have the experience of running an external software in R? I > try to use R to run ANSYS software, which is a engineering simulation > package. I ever have done this task in Matlab platform by executing > the following code line: > > system('"C:\Program Files\Ansys Inc\v100\ANSYS\bin\intel\ansys100" -b -p > ane3fl -i D:\Ansys\MyAnsysCode.txt -o D:\Ansys\vm5.out'); > > > Any idea regarding implementing this work is very welcome. > > David > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
You can use system() or shell(), which adds "cmd.exe /c " to the front of your command so you can use DOS syntax. Remember to add double quotes when file names have spaces in them. E.g., I can call an old version of R with the following and later read its text output into my current session.> infile <- tempfile() > cat("getRversion()\n", file=infile) > outfile <- tempfile() > shell(paste("\"C:\\Program Files\\R\\R-2.15.1\\bin\\R\" --quiet --vanilla<", infile, ">", outfile))> readLines(outfile)[1] "> getRversion()" "[1] '2.15.1'" "> " Bill Dunlap TIBCO Software wdunlap tibco.com On Tue, Sep 6, 2016 at 6:13 PM, Marino David <davidmarino838 at gmail.com> wrote:> Hi all R users: > > Does anybody have the experience of running an external software in R? I > try to use R to run ANSYS software, which is a engineering simulation > package. I ever have done this task in Matlab platform by executing > the following code line: > > system('"C:\Program Files\Ansys Inc\v100\ANSYS\bin\intel\ansys100" -b -p > ane3fl -i D:\Ansys\MyAnsysCode.txt -o D:\Ansys\vm5.out'); > > > Any idea regarding implementing this work is very welcome. > > David > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/ > posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]
Bert Gunter <bgunter.4567 at gmail.com> writes:> ?system > > But this begs the question: WHY would you want to do this? More > specifically, what should R communicate to your other software, and > what should the other software communicate to R?I am not the OP, buty I can give you an answer why I did this (OK - I user rgrass7 - but under the hood the same in my case). I don't have to say that R is extremely powerful and flexible - and when you are used to R, it even becomes intuitive. So why not use R for scripting, even if it is not statistical stuff? and with system() you can call other languages (bash, grass, whatever you want) when things are easier there - so in some cases, no data transfer between R and the external program is even necessary. But if you are asking about the specific case of the OP, I can't answer this. Cheers, Rainer> > > Cheers, > Bert > > Bert Gunter > > "The trouble with having an open mind is that people keep coming along > and sticking things into it." > -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) > > > On Tue, Sep 6, 2016 at 6:13 PM, Marino David <davidmarino838 at gmail.com> wrote: >> Hi all R users: >> >> Does anybody have the experience of running an external software in R? I >> try to use R to run ANSYS software, which is a engineering simulation >> package. I ever have done this task in Matlab platform by executing >> the following code line: >> >> system('"C:\Program Files\Ansys Inc\v100\ANSYS\bin\intel\ansys100" -b -p >> ane3fl -i D:\Ansys\MyAnsysCode.txt -o D:\Ansys\vm5.out'); >> >> >> Any idea regarding implementing this work is very welcome. >> >> David >> >> [[alternative HTML version deleted]] >> >> ______________________________________________ >> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.-- Rainer M. Krug email: Rainer<at>krugs<dot>de PGP: 0x0F52F982 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 454 bytes Desc: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20160907/92494154/attachment.bin>
I use the opposite approach ... run R from another software (usually a GUI developed in VB), using Rscript from dos command line. Maybe you can get the level of communication you need. David Remotti Il 07/09/2016 03:13, Marino David ha scritto:> Hi all R users: > > Does anybody have the experience of running an external software in R? I > try to use R to run ANSYS software, which is a engineering simulation > package. I ever have done this task in Matlab platform by executing > the following code line: > > system('"C:\Program Files\Ansys Inc\v100\ANSYS\bin\intel\ansys100" -b -p > ane3fl -i D:\Ansys\MyAnsysCode.txt -o D:\Ansys\vm5.out'); > > > Any idea regarding implementing this work is very welcome. > > David > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >