s-news
[Top] [All Lists]

Summary: Using C subroutine is Splus

To: s-news@lists.biostat.wustl.edu
Subject: Summary: Using C subroutine is Splus
From: Jingli Song <jsong@sph.emory.edu>
Date: Fri, 16 Feb 2001 09:36:42 -0500 (EST)
In-reply-to: <20010215195319.12563.qmail@nwcst334.netaddress.usa.net>
References: <20010215195319.12563.qmail@nwcst334.netaddress.usa.net>
I got several responses from Liaw, Andy; David Homiak; Shige Song; ROGER 
NGOUENET;Don MacQueen; and Xiaofei Wang. Many thanks to you guys help. 
Following 
is a summary of all the responses:
                    
Original Message:

Hello, S-users:

 I need to call a C subroutine in Splus simulations. As I just know a little 
 about C, this is hard to me. Can anyone  give me a simple example of how to do 
 this, including if I need to compile the C subroutine first and how to pass the

 parameters from the Splus function to the C subroutine. 

 Thanks and I appreciate your help,

 Jingli Song

 Dept. of Biostatistics
 Emory University

Suggestions:

1.Splus Programmer's guide. (Splus 2000 or splus5 or splus6) can be accessed 
online at ' www.insightful.com'.

2. Modern Applied Statistics with S-plus, (W.N. Venables and B. D. Ripley). 
There is an online resource of this book. the website is:
http://www.stats.ox.ac.uk/pub/MASS3/

3. S Programming(B. D. Ripley), website: 
http://www.stats.ox.ac.uk/pub/MASS3/Sprog/#OnLine
there also have availiable scripts file at:
http://www.stats.ox.ac.uk/pub/MASS3/Sprog/Sprog.zip

4. go to R website at: www.r-project.org

5. an brief introduction from David Homiak (with unix system).

   Then hopefully your unix system includes a C compiler. I believe most do.

   Here's a rough and partial outline.

   If I recall correctly, compile with the -o option (to get only an 
   object file output, you don't need or want to get an executable file).
   Put the output file in the same directory as the Splus function that 
   will call the C subroutine. Use the Splus CHAPTER command to make an 
   Splus shared object (should automatically get named S.so) from the C 
   object file. Actually, you may have to run the unix 'make' command 
   after the Splus CHAPTER command. Then, when you start Splus in that 
   directory, the C routine in S.so will be available.

   Then, you have to write an Splus function that calls the C 
   subroutine. I've done this with fortran, but not C so I can't help 
   you with some of the C stuff.


<Prev in Thread] Current Thread [Next in Thread>