Loading user defined functions autometically each time I start R

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

Loading user defined functions autometically each time I start R

Arun.stat
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]]

______________________________________________
[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: Loading user defined functions autometically each time I start R

Arun.stat
I am using R 2.6.2. under windows

On Wed, Feb 27, 2008 at 12:43 PM, <[hidden email]> wrote:

> >From: Arun Kumar Saha <[hidden email]>
> >Date: 2008/02/27 Wed AM 01:03:26 CST
> >To: "[hidden email]" <[hidden email]>
> >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]]
> >
> >______________________________________________
> >[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<http://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: [hidden email]
           [hidden email]
----------------------------------------------------------------------------------------------------------------------

        [[alternative HTML version deleted]]

______________________________________________
[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: Loading user defined functions autometically each time I start R

anna freni sterrantino
In reply to this post by Arun.stat
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 <[hidden email]>
A: "[hidden email]" <[hidden email]>
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]]

______________________________________________
[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.






      ___________________________________



        [[alternative HTML version deleted]]


______________________________________________
[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: Loading user defined functions autometically each time I start R

Richard Cotton
In reply to this post by Arun.stat
> 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}}

______________________________________________
[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: Loading user defined functions autometically each time I start R

Patrick Connolly-4
On Wed, 27-Feb-2008 at 10:06AM +0000, [hidden email] 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
         
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.

______________________________________________
[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.