5

I have a S-Plus library which I'd like to convert to R. I am a programmer, but I don't know anything about S-Plus or R. From my research it seems that they are highly compatibile. Is that true? The code I want to convert only uses core S-Plus libraries.

I have attached a picture of the library as seen in the S-Plus 8.0 Object Explorer. Besides function source files, there are a few entries which I'm not sure how to transpose to R. For example the last 5 (oneDay, ...), which seem to be some sort of global variables, and have specific values assigned to them. What would be the equivalent of them in R?

alt text

csgillespie
  • 11,849
  • 9
  • 56
  • 85
Meh
  • 1,135
  • 2
  • 10
  • 12

3 Answers3

4

I would say that your functions will mostly work in R, but that is far from being universally true. I went through the same conversion before myself, and it was actually quite painful. Especially given all the functions that are actually writing in a foreign language (like C).

As an example: it looks like you have some S-Plus timeSeries objects in there. It can be painful to convert functions that use or rely on the timeSeries object in S-Plus, and you will have a slightly rude awakening because the R time series libraries simply aren't as standardized or as user friendly. This is not to criticize the R libraries, but simply to point out that S-Plus was created by one company and there is only one timeSeries object and everything uses it consistently.

Shane
  • 11,961
  • 17
  • 71
  • 89
  • When I had to convert a library a few years ago many functions needed small changes. The most fundamental problem I hit was scoping differences, that might relate to your 'global variables'. See http://socserv.mcmaster.ca/jfox/Books/Companion-1E/appendix-scope.pdf – user20637 Jun 05 '15 at 08:42
2

Your S+ functions should work in R, except if they have dependencies on some Libraries that are not currently supported on R (most of the time, it is the reverse, though). About your "global" variables, the easiest way is to use single assignment in your script file (although you can explicitely can write to the global environment from within a function, see help("<<-"), but this is not recommended), unless you plan to make an R package. In this case, you should look at the R documentation, Writing R Extensions.

Maybe you can also take a look at Using R and S-Plus together: The Best of Both Worlds

chl
  • 50,972
  • 18
  • 205
  • 364
0

did you convert the aforementioned library to R? I need to convert the same library into R and wanted to ask if you might share your results?

Thanks