Hi, I wonder if it is possible to create an DLL or EXE file performing R procedures. Instead of running R, reading data and calling some procedures, I would like to use R functions in the following way: "C:\linearRegression.exe data.txt" which would produce let's say file "output.txt" with the results. Is there some way how to do it? Thanks a lot. Pavel Vanecek ____________________________________________________________ Eurotel Data Nonstop - neomezen? p??stup na internet za 649,- (s DPH 681,45) K? m?s??n?! http://ad2.seznam.cz/redir.cgi?instance=67071%26url=http://www.eurotel.cz/site/cz/servicesAndTariffs/specialOffer.html?list=34995
On Tue, 23 Dec 2003, PaTa PaTaS wrote:> I wonder if it is possible to create an DLL or EXE file performing R > procedures. Instead of running R, reading data and calling some > procedures, I would like to use R functions in the following way: > "C:\linearRegression.exe data.txt" which would produce let's say file > "output.txt" with the results. Is there some way how to do it?Yes (quite a few actually). By far the simplest would be to write a small C program making use of the system command to call R on a given script, using either environment variables or the command-line of R to pass arguments such as `data.txt'. You could also call R via one of the D(COM) interfaces although that would seem overkill for something so simple, and I would use a scripting language (e.g. Perl) for this sort of thing. -- 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 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
PaTa PaTaS wrote:> > Hi, > I wonder if it is possible to create an DLL or EXE file performing R procedures. Instead of running R, reading data and calling some procedures, I would like to use R functions in the following way: "C:\linearRegression.exe data.txt" which would produce let's say file "output.txt" with the results. Is there some way how to do it? > Thanks a lot. Pavel VanecekNo. There is not compiler for R code available. Uwe Ligges
Also, if its not necessary that it actually be a compiled
program then a batch file, linreg.bat, along with the
supporting R code file, linreg.r, and the data file, data.txt,
could be created like this (in Windows, modify for others):
--- linreg.bat -------------------------------------------------------
set infile=%1
"C:\Program Files\R\rw1081\bin\Rcmd.exe" BATCH linreg.R linreg.Rout
--- linreg.r -------------------------------------------------------
infile <- Sys.getenv("infile")
z <- read.table(infile, header=T)
with(z, lm(y ~ x))
--- data.txt -------------------------------------------------------
x y
1 2
2 4
3 7
Date: Wed, 24 Dec 2003 07:27:08 -0800
From: Spencer Graves <spencer.graves at pdf.com>
To: Uwe Ligges <ligges at statistik.uni-dortmund.de>
Cc: <r-help at stat.math.ethz.ch>,PaTa PaTaS <vanecekpavel2 at
seznam.cz>
Subject: Re: [R] question: DLL or EXE from R procedures
While Uwe is correct about the absence of a compiler for R, one
can call R from other languages such as C. A description of this can be
found, e.g., from R 1.8.1, help.start() -> "Writing R Extensions"
->
"Evaluating R expressions from C". Also, the many R functions actually
call C code, which could be called directly.
hope this helps.
spencer graves
Uwe Ligges wrote:
>PaTa PaTaS wrote:
>
>
>>Hi,
>>I wonder if it is possible to create an DLL or EXE file performing R
procedures. Instead of running R, reading data and calling some procedures, I
would like to use R functions in the following way:
"C:\linearRegression.exe data.txt" which would produce let's say
file "output.txt" with the results. Is there some way how to do it?
>>Thanks a lot. Pavel Vanecek
>>
>>
>
>No. There is not compiler for R code available.
>
>Uwe Ligges
>
>______________________________________________
>R-help at stat.math.ethz.ch mailing list
>https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>
>