tags:

views:

107

answers:

2

Does anyone have any suggestions for a good way to call R from S-Plus? Ideally I would like to just pass code to R and get data back without having to write anything too elaborate to integrate them.

I should add that I'm familiar with the RinS package on Omegahat, but I haven't used it. I was under the impression that Insightful had made an effort to integrate the environments before Tibco took over.

Edit: It turns out that RinS doesn't work on Windows. I found that the easiest solution was to just use Rscript. I can call this from S-Plus with the system() command. For example, here's a simple script:

#! Rscript --vanilla --default-packages=utils
args <- commandArgs(TRUE)
print(args)
print(1:100)
Sys.sleep(2)
res <- "hello world"
class(res) <- "try-error"
if(inherits(res, "try-error")) q(status=1) else q()

And calling it from S-Plus:

system("rscript c://test.rscript 'some text'")

Then I just store the results into a text file and import it into S-Plus after the script is run.

+3  A: 

RSPlus is the only option i'm aware of. I used it almost daily for about a year, but haven't used it since R 2.7. From your Q, it seems like you just want to run R inside SPlus, which RSPlus can certainly do (R is a separate interpreter accessible via an interface comprised of a few SPlus functions, the most-often used is '.R()', e.g., .R("fivenum", 1:10).

I think we are talking about the same thing though, because 'RinS' is one of two modules (SpinR being the other) that together comprise RSPlus (i.e., there's only a single interface, regardless of the direction you want to go--R to SPlus, or SPllus to R). Although it wasn't obvious to me at the time, i had to install both modules to get RinS to work.

doug
A: 

Why would you use S-PLUS to run R? If you have R code to run, download R and run the code in R, it is as simple as that!

S-PLUS is dead and burried....

jeroen
-1 Thanks for being supremely unhelpful!
Shane
+1 to offset the downvote. It's tedious having to sort through juvenile remarks like this, not just because of their effect on the signal-noise ratio, but because they're disrespectful. Unless the intent is humor, which there's no evidence of here, i hope answers of this sort don't become routine on SO, or at least not on on the boards/tags i watch.
doug
My comment just above is directed at the proffered answer ("What would you use...." ), not to Shane's comment below it.
doug