[R] Surface for R outside of R

Gabor Grothendieck ggrothendieck at gmail.com
Mon May 4 20:56:25 CEST 2009


Also see Rscript.bat in the same batchfiles distribution.  It
automatically finds Rscript.exe by looking in the registry
in the same way that Rcmd.bat finds Rcmd.exe.

On Mon, May 4, 2009 at 2:43 PM, Francisco J. Zagmutt
<gerifalte28 at hotmail.com> wrote:
> Hi Koj,
>
> I just completed a Windows application using the batch approach and it works
> very well.  In our case, we used VBA for Excel to call different batch files
> that execute R code, but you can do the same from any platform.  Here is a
> simple step-by-step example on how to make the batch files work (in
> Windows):
>
>
> 1. Write your R code and save it the directory where you want your results.
>  Here is a very simple example using a file called "normal.r". This code
> takes 100 random samples from a standard normal and writes the results to a
> file called "data.txt"
>
> write(rnorm(100),"data.txt")
> q(save="no", runLast = F)
>
>
> 2. Make sure that the console finds the path to R without changing your path
> environment variable.  The easiest way to do this is to download the
> batchfiles that Gabor Grothendieck has kindly provided in this site
> http://code.google.com/p/batchfiles/ and put one or all of the files in the
> same directory where your batch and R files will reside.  The only file I
> have needed so far in different WinXP and Vista machines was "Rcmd.bat" but
> you may need to use others.
>
>
> 3. Open a text editor and create a file with a .bat or .cmd extension. Here
> is an example of a file called "TestBatch.CMD" that runs the code in
> "normal.r"
>
> @ECHO OFF
> title Random number generation
> ECHO Taking 100 random samples from a N(0,1)
> Rcmd BATCH --slave normal.r Log.txt
> ECHO Analysis done. See the file data.txt for results
> PING 1.1.1.1 -n 1 -w 1000 >NUL
> @ECHO OFF
>
> The main line here is "Rcmd BATCH --slave normal.r Log.txt" which tells the
> console to run your R code, and to write outputs printed in the console
> (i.e. errors) to the Log.txt file. The PING argument adds a short lag before
> the console closes, so the user can see what is echoed in the console. The
> other lines should be pretty self-explanatory.
>
> 4. Execute the "TestBatch.CMD" file (by hand or via your GUI) and watch the
> results.  You should now see two new files ("data.txt" and "Log.txt") in the
> same directory as the batch file.
>
>
> I hope this helps. Let me know if you have any other questions.
>
> Regards,
>
> Francisco
>
> Francisco J. Zagmutt
> Vose Consulting
> 2891 20th Street
> Boulder, CO, 80304
> USA
> www.voseconsulting.com
>
>
> Hans-Peter Suter wrote:
>>>
>>> want an analysis. The best case were a surface of e.g. 8 Buttons, each
>>> click
>>> leads to start a specific R file. My outputs are JPEG or CSV, so I don`t
>>> need the output inside of R. Could anyone can give me some
>>> recommendations,
>>> what could be a solution (e. g. Java)? Is such a solution possible?
>>
>>  What about batch scripts which would be called by your GUI? (maybe
>> you could even skip the gui...)
>> (see ?Rscript (unix alike) or Windows FAQ, 2.12)
>>
>> --
>> Regards,
>> Hans-Peter
>>
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>




More information about the R-help mailing list