Hello List ! I want to use R as statistical & Graphical Tool for biological simulation programs. So, I want to combine my programs (written under cygnus-gcc on NT4.0) with R 1.0.1.1 under Windows. The data, produced by my program will be sent to R. There it should be statistically "transformed" and graphically displayed. The simulation program may wait until R has calculated and displayed the data. (Well, if both may work independently, "online" display of the data this would be nice as well, but there is no need to.) Following possibilities came to my attention by the email-Archives (& thanks to Yves Gauvreau) 1) embedding the C-Program into R ( .C - Call) 2) using the DCom/StatConnector 3) use the R-Source code and compile it into my program About 1): I want to keep the simulation program seperated from the (graphical) output. So, anybody who wants to check (or use) the proghram without graphic can do so easily. So, it would be easier, not to change the program into this concept. I would appreciate an other solution. About 2) I have problems in finding documentation about DCom/StatConnector. 2a: Where can I get a Docu about it ? (Like interface specifications ?) 2b Has anybody a (simple) example, how he used it ? Best from within a C/C++ Program ? 2c It is possible, to link Windows-DLLs to a Cygwin-Gcc program, thus making it (possibly ?) DCom aware. Has anybody done this before ? 3) Compiling the source code will be tedious :) I fear. Especially I will loose all possibilities to use the different packages in future programms. Has anybody tried this ? I tend to the opinion, that 1) would be the easiest (but not to the general solucion for my problems) and 2) the nicest possibility, but not too easy. But, I'd like to know more about this. Greetings, Oliver PS.: please note the new telefon numbers of the University of Mainz -------------------------------------- Oliver Lange Tel. 0049-(0)6131-3924424 FAX. 0049-(0)6131-3923731 email: lango000 at mail.uni-mainz.de Johannes-Gutenberg-Universit?t Mainz Zoologisches Institut Abteilung Oekologie 55099 Mainz visit our homepage at http://perdix.biologie.uni-mainz.de or the Complex System Research Association at http://biophysik.biologie.uni-mainz.de/vortraege/csra_main.htm -------------------------------------- -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Thu, 5 Oct 2000, Oliver Lange wrote:> Hello List ! > > I want to use R as statistical & Graphical Tool for biological > simulation programs. So, I want to combine my programs (written > under cygnus-gcc on NT4.0) with R 1.0.1.1 under Windows. > > The data, produced by my program will be sent to R. There it should > be statistically "transformed" and graphically displayed. The > simulation program may wait until R has calculated and displayed > the data. (Well, if both may work independently, "online" display of > the data this would be nice as well, but there is no need to.) > > Following possibilities came to my attention by the email-Archives (& > thanks to Yves Gauvreau) > 1) embedding the C-Program into R ( .C - Call) > 2) using the DCom/StatConnector > 3) use the R-Source code and compile it into my program > > > About 1): I want to keep the simulation program seperated from the > (graphical) output. So, anybody who wants to check (or use) the > proghram without graphic can do so easily. So, it would be easier, > not to change the program into this concept. I would appreciate an > other solution. > > About 2) I have problems in finding documentation about > DCom/StatConnector. > 2a: Where can I get a Docu about it ? (Like interface specifications > ?)In the sources on CRAN.> 2b Has anybody a (simple) example, how he used it ? Best from > within a C/C++ Program ?It comes with a Visual Basic example. Writing any DCOM code in Cygwin-Gcc is pretty tedious.> 2c It is possible, to link Windows-DLLs to a Cygwin-Gcc program, > thus making it (possibly ?) DCom aware. Has anybody done this > before ? > > 3) Compiling the source code will be tedious :) I fear. Especially I > will loose all possibilities to use the different packages in future > programms. Has anybody tried this ?You will need far, far more than the compiled source code, as R needs lots of pacakge code just to start up. Take a look at the examples in the R sources directory src/gnuwin32/front-ends. They show you how you link the R.dll to your program and submit simple commands to R. Basically, like using DCom/StatConnector without the DCOM overhead.> I tend to the opinion, that 1) would be the easiest (but not to the > general solucion for my problems) and 2) the nicest possibility, but > not too easy. But, I'd like to know more about this.The simplest solution of all seems to be to use files to communicate. Write your simulation output to a file, and invoke an R script (via a system call) to read that file. A further step is to pipe the input to the R process: your C program can then write to the pipe and R will process the script as you send it (and you will need to be careful to flush the output when a command is ready to be executed). That way all you need is a working R installation. Normally pipes are suspect from Windows applications, but not from Cygwin I think. I am assuming that you don't need any output from R back in your C program. If you do, then DCOM is perhaps the easiest route. -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Oliver-- I used to do this sort of thing extensively wirh S-plus on a unix box, but perhaps the same strategy will work under R-windows as well. The key was to write the simulation program as an independent, standalone routine that read its input parameters from a text file and output its results to another file. Then, it was easy to write an S-plus wrapper program that used system calls to write the desired parameters to the input file, run the model as a spawned process, and then suck in the model output file for display, analyses, etc. It isn't strictly necessary to use the wrapper function as both a front end and back end, but that's handy because it allows you to write a function that will re-run the simulation routine with parameters modified according to the analyses of the output from previous runs. This allows the routine to automatically do things like brute force optimization of the input parameters, explore interesting regions of the parameter space, etc. I spent a fair amount of my later grad school years enjoying myself in the local beer hall while my S-plus wrapper chugged away on thousands of simulation runs in my absence.... I assume there is some equivalent way to invoke a shell and execute a command in R-win(?). Sorry, I can't check at present because I'm not using a windows box. If this approach won't work for R-win you might want to install linux! Oh-- one other thing-- I think this is easier than passing control to your simulation via .C calls because it allows the simulation to manage all of its own variables and memory use. Since the compiled code is typically far faster than R, and since the output can be read in at the end of the simulation run, there is no need for complicated memory structures in most simulations-- the current model state can simply be appended to the output file after each time step. --Mike C. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Michael A. Camann Voice: 707-826-3676 Assistant Professor of Zoology Fax: 707-826-3201 Institute for Forest Canopy Research Email: mac24 at axe.humboldt.edu Department of Biology ifcr at axe.humboldt.edu Humboldt State University Arcata, CA 95521 URL:http://www.humboldt.edu/~mac24/ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._