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 Thank you Regards Kunal
This is not answering your question directly. I usually use the BATCH command for running R non-interactively. You can also use commandArgs() to get any arguments from the command line. For more information, see help(BATCH) or help(commandArgs). On Thu, 2004-10-07 at 16:14, 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 > Thank you > Regards > Kunal > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html >
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 problemThere are several approaches possible, depending on what you find convenient at the time. 1. Have a look at the history-related commands: ?history savehistory(file="mycommands") 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. history(max.show=15) 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 happy. 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! Ted. -------------------------------------------------------------------- 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 ------------------------------
Hi, On Thu, 7 Oct 2004, Kunal Shetty wrote:> Example for calculating the mean of a data set > > x <- c(8,11,16,18,6,4,20,25,9,13) > u <- mean(x) > uR is an interpreted language, not a compiled one like C++ or Java. Therefore you don't compile it. And for such a simple example, there isn't much need in doing so. However, compilation may come in handy when you are running simulations and/or with some long loops, as interpreted languages aren't really good at handling loops -- although you can get around with many loops by vectorisation. I think Luke Tierney is working on an R Compiler, which will allow you to compile such simulation and will decrease the running time a lot...but I'm not sure when it will be released. Cheers, Kevin -------------------------------- Ko-Kang Kevin Wang PhD Student Centre for Mathematics and its Applications Building 27, Room 1004 Mathematical Sciences Institute (MSI) Australian National University Canberra, ACT 0200 Australia Homepage: http://wwwmaths.anu.edu.au/~wangk/ Ph (W): +61-2-6125-2431 Ph (H): +61-2-6125-7407 Ph (M): +61-40-451-8301
On 7 Oct 2004 at 17:49, Adaikalavan Ramasamy wrote:> This is not answering your question directly. > > I usually use the BATCH command for running R non-interactively. You > can also use commandArgs() to get any arguments from the command line. > For more information, see help(BATCH) or help(commandArgs). >Or you can make a function from your commands and use it to process your data. See ?function and "Writing your own functions" in intro docs. Or you can copy/paste to some suitable text editor, save it as plain text and copy/paste it back to R later (with any modifications). Cheers Petr> > On Thu, 2004-10-07 at 16:14, 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 > > Thank you > > Regards > > Kunal > > > > ______________________________________________ > > R-help at stat.math.ethz.ch mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide! > > http://www.R-project.org/posting-guide.html > > > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.htmlPetr Pikal petr.pikal at precheza.cz