Surface for R outside of R

classic Classic list List threaded Threaded
5 messages Options
koj
Reply | Threaded
Open this post in threaded view
|

Surface for R outside of R

koj
Hi all,

i am new here and this is my first posting. My coding experience in R ist okay, but I have a problem which is related to another aspect of R.

I am searching for a surface which execute my commands in R via a click on a button OUTSIDE of R. Concrete: I will write some programs in R and want to execute this files outside of R, so I don't want to start R eyery time if i 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?

Thank you very much,

Jens.
Reply | Threaded
Open this post in threaded view
|

Re: Surface for R outside of R

Duncan Murdoch
On 04/05/2009 4:12 AM, koj wrote:

> Hi all,
>
> i am new here and this is my first posting. My coding experience in R ist
> okay, but I have a problem which is related to another aspect of R.
>
> I am searching for a surface which execute my commands in R via a click on a
> button OUTSIDE of R. Concrete: I will write some programs in R and want to
> execute this files outside of R, so I don't want to start R eyery time if i
> 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?

There are many solutions.  Java (through JRI in rJava) may be the most
portable one; there are others that are specific to particular operating
systems.

Duncan Murdoch

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Surface for R outside of R

Hans-Peter Suter
In reply to this post by koj
> 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

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Surface for R outside of R

Francisco J. Zagmutt
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
>

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Surface for R outside of R

Gabor Grothendieck
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
<[hidden email]> 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
>>
>
> ______________________________________________
> [hidden email] 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.
>

______________________________________________
[hidden email] 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.