If you want to interact with other programming languages from R, there are various packages and bindings available. These packages provide a pretty high degree of integration between the langages and allow you to pass objects back and forth seemlessly. The downside is that you need to have the time, security rights and correct installation sequences available to complete the compilation and installation.
A quick and easy way to return a string from an external program or scripting langage is to call the system function. As you can see from the xamples, you must set intern=TRUE to pass the value back into the R environment. In addition, the value being passed into R is being redirected from STDOUT, so you have to use an appropriate command in your script to effectively return the result.
x=system(‘ruby -e “puts 1+1″‘, intern=TRUE)
x=system(‘perl -e “print 2 + 4″‘, intern=TRUE)
x=system(‘C:\jython2.2.1\jython -c “print 1+3″‘, intern=TRUE)
Obviously not a great approach for a full blown application, but a good “quick and dirty” solution to pass a bit of data between programming language environments.
Copyright © 2020 | MH Corporate basic by MH Themes