Move S+ functions to R

J

jk90029

Guest
#1
Fine You gave me a point.

Furthermore, may I have one more?

In the Splus version 2000, there are about 100 functions that I wrote myself.
Now to import the S+ functions to R format in R directory, all the 100 times work like 1)save S+ file to text and 2) use R commans source(file="c:\\myfunction1.txt") 100 times to myfunction100.text. This is useless.

I wonder if there is one-shot utility for me to do by ONLY ONE COMMAND.

1) Need a utily to store all 100 S+ functions to one file in Windows.

2) Need a utility to restore it to R files (actually 100 R functions)
 

Dason

Ambassador to the humans
#2
Re: Importing Excel matrix to R.

I really don't understand what you were saying in that last post. Would you mind trying to explain it again?
 
J

jk90029

Guest
#3
Re: Importing Excel matrix to R.

I am a long-time user of S+ and have 100 functions written by myself.

Now the 100 functions f1, f2, ... f100 in S+ data directory is going to move to R directory, with same contents.

Currently I can move piece by piece. First f1 is stored to test mode in c:\a.txt.
For example, the text file c:\a.txt has content f1 <- function(x){return(x^2)}
And source(file="c:\a.txt") in R works and the f1 function showed up in R with same contents.

However, 100 times duplicative work from f1 to f100 is time-consuming. I wonder if there might be some utility to do only ONE-TIME, instead of 100 times.
 

Dason

Ambassador to the humans
#4
Are the functions originally stored as text files? Or do you have to load them in a special way in S+?

Which part is causing the trouble?
 
J

jk90029

Guest
#5
Like in R, S+ data and functions are stored in specific directory under c:\ProgramFiles\splus as a BINARY format.

For example, the f1 function f1 <- function(x){return(x^2)} to sqaure the input numebr in S+

can be seen in S+ but CANNOT by directly imported to R directory, due to different BANY format. So I HAVE TO make one TEXT file a.txt in c:\ with contents

f1 <- function(x){return(x^2)}

and use source(file="c:\\a.txt") in R to move from the text file a.txt to R function in R directory.

Currently it works to me, if I do the above routine ONE by ONE.

Question is "Do I have to repeat the above work 100 times?" Or there might be an easy way.

PS) Due to my short English, I may not make you understood.
 

Dason

Ambassador to the humans
#6
My guess is that you could probably use a loop over all the functions in the S+ directory to write them to files using a combination of dput, paste, and eval/parse. Then once they're written you could use a loop in R to bring them all into the environment using dget and eval/parse. You could possibly then write a loop to put them into a single file.

I know this is pretty abstract right now but I've gotta get going so I thought I might be able to lead you in a direction that could work.

Could you outline how you go about moving a single function from S+ to R?
 
J

jk90029

Guest
#7
f1 <- edit(f1) in S+ will show all the detail as text format in Window notepad.

1) Copy all the text such as

f1 <- fundtion(){
return(x^2)
}

to make a text file in c:\a.txt with Window "paste".

2) Open R to use command source(file="c:\\a.txt") in R shall give you a function f1 in R with same contents as in S+ as before.

-------------

Appreciate again.