Re: [R] Loading user defined functions autometically each time I start R
On Wed, 27-Feb-2008 at 10:06AM +, [EMAIL PROTECTED] wrote: | I wrote some user defined function for my own. Now I want to get a | mechanism | so that every time I start R, those function will automatically be | loaded in | R without manually copying pasting. Can gurus here pls tell me how to do | that? Or I have to build my own packages bundled with those functions. | | These instructions are for Windows, there may be a slight difference on | other platforms. | | In R_HOME\etc you should have a file named RProfile.site. | | Inside this file, you can define a .First function, which sources your | functions, e.g. | | .First - function() | { | source(c://myfunction.r) | } Those functions will end up in each working directory you use. Unless you have only a small number of those functions, that will produce a lot of unnecessary duplication. You can avoid that by saving those functions in a .RData type file, and then something like: attach(/path/to/file/.RData) There's no need for a .First file. Having that line in your .Rprofile will be sufficient. It would be tidier to make them into a package, but the above will work easily enough. HTH -- ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. ___Patrick Connolly {~._.~} Great minds discuss ideas _( Y )_Middle minds discuss events (:_~*~_:)Small minds discuss people (_)-(_) . Anon ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. __ R-help@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.
Re: [R] Loading user defined functions autometically each time I start R
Hi, an easy way, is to save your functions in a file and have it in your working directoy and sources it. i.e. source(myfile.r) otherwise you can try to build your own package, see ?package.skeleton Hope it helps Regards A - Messaggio originale - Da: Arun Kumar Saha [EMAIL PROTECTED] A: [EMAIL PROTECTED] [EMAIL PROTECTED] Inviato: Mercoledì 27 febbraio 2008, 8:03:26 Oggetto: [R] Loading user defined functions autometically each time I start R Hi all, I wrote some user defined function for my own. Now I want to get a mechanism so that every time I start R, those function will automatically be loaded in R without manually copying pasting. Can gurus here pls tell me how to do that? Or I have to build my own packages bundled with those functions. However I am not familiar in writing R package yet. Regards, [[alternative HTML version deleted]] __ R-help@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. ___ [[alternative HTML version deleted]] __ R-help@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.
Re: [R] Loading user defined functions autometically each time I start R
I wrote some user defined function for my own. Now I want to get a mechanism so that every time I start R, those function will automatically be loaded in R without manually copying pasting. Can gurus here pls tell me how to do that? Or I have to build my own packages bundled with those functions. These instructions are for Windows, there may be a slight difference on other platforms. In R_HOME\etc you should have a file named RProfile.site. Inside this file, you can define a .First function, which sources your functions, e.g. .First - function() { source(c://myfunction.r) } See also: Section 10.8 of the Intro to R manual, and http://cran.r-project.org/doc/contrib/Lemon-kickstart/kr_first.html Regards, Richie. Mathematical Sciences Unit HSL ATTENTION: This message contains privileged and confidential inform...{{dropped:20}} __ R-help@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.
[R] Loading user defined functions autometically each time I start R
Hi all, I wrote some user defined function for my own. Now I want to get a mechanism so that every time I start R, those function will automatically be loaded in R without manually copying pasting. Can gurus here pls tell me how to do that? Or I have to build my own packages bundled with those functions. However I am not familiar in writing R package yet. Regards, [[alternative HTML version deleted]] __ R-help@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.
Re: [R] Loading user defined functions autometically each time I start R
I am using R 2.6.2. under windows On Wed, Feb 27, 2008 at 12:43 PM, [EMAIL PROTECTED] wrote: From: Arun Kumar Saha [EMAIL PROTECTED] Date: 2008/02/27 Wed AM 01:03:26 CST To: [EMAIL PROTECTED] [EMAIL PROTECTED] Subject: [R] Loading user defined functions autometically each time I start R i'm on linux so if you are not it's probably slightly different on windows but not much. I just put my .Rprofile file ( you need the . in front but I had to take it off when I sent you ) in my /opt/mark ( hiome dorectory on linux ) directory. generally speaking, when you ask questions like that, be sure to specify your OS or people ( not me ) will get annoyed. i you start up R, the .Rprofile should get called and the functions in your arun.R file should be available to you. good luck. I';m no expert so hopefully someone else will reply also ( that's why i emailed privately ). Hi all, I wrote some user defined function for my own. Now I want to get a mechanism so that every time I start R, those function will automatically be loaded in R without manually copying pasting. Can gurus here pls tell me how to do that? Or I have to build my own packages bundled with those functions. However I am not familiar in writing R package yet. Regards, [[alternative HTML version deleted]] __ R-help@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.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- -- Arun Kumar Saha, M.Sc. Statistical Arbitrage Quant RISK MANAGEMENT DIVISION Transgraph Consulting [www.transgraph.com] Hyderabad, INDIA Contact # Home: (91-033) 25558038 [CALCUTTA] Home: (91-040) 40033010 [HYDERABAD] Office: (91-040) 30685012 Ext. 17 [email preferred] FAX: (91-040) 55755003 [if absolutely necessary] Mobile: 919989122010 E-Mail: [EMAIL PROTECTED] [EMAIL PROTECTED] -- [[alternative HTML version deleted]] __ R-help@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.