[R] Re:How to create a R -application

(Ted Harding) Ted.Harding at nessie.mcc.ac.uk
Thu Oct 7 20:32:22 CEST 2004

On 07-Oct-04 Kunal Shetty wrote:
> Dear R- users and Helpers
>        I am a beginner for R. I am using R to implement EM algorithm
> for treating Missing values. I would like to know how can save or
> compile my logical R commands to an application; so that the next time
> I could just execute the R- file.
> Example for calculating the mean of  a data set
> x <- c(8,11,16,18,6,4,20,25,9,13)
> u <- mean(x)
> u
> Now I would like to save these commands as batch or an application
> Anybody could please help or direct me in this problem

There are several approaches possible, depending on what you find
convenient at the time.

1. Have a look at the history-related commands:



will save the entire history of your session in "mycommands" which
you can later edit.

2. In developing an application, I often experiment with different
forms of a command or different combinations of commands. When I'm
satisfied with a group of commands, I can copy-and-paste that part
of the R window into a file which I have open in a separate editing
window on the side (using X windows in Linux here, which makes this
very easy).

It can be convenient to use the 'history' command setting the
"max.show" parameter (default=25), e.g.


will give you only the last 15 commands you used. You can then
copy over a selected few of these.

3. A converse version of (2) is to initially enter the commands
into your editing window, and then copy-and-paste these into
the R window to test them. Edit the commands file until you're

While I'm at it, are you aware of the R library packages 'cat',
'norm', 'mix' and 'pan' which implement Shafer's EM methods
for imputing missing data? See CRAN.

Good luck, and welcome to R!

E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk>
Fax-to-email: +44 (0)870 094 0861  [NB: New number!]
Date: 07-Oct-04                                       Time: 19:32:22
------------------------------ XFMail ------------------------------

More information about the R-help mailing list