[R] functions and getting them into R

ripley@stats.ox.ac.uk ripley at stats.ox.ac.uk
Mon May 27 18:21:01 CEST 2002


On Mon, 27 May 2002, Guy Forrester wrote:

> Dear All,
>
> I am new to R and can see it is a very powerful and versatile system for
> programming and statistical analysis.
>
> Say I have written a simple function and want to use it on a regular
> basis. I have the file as a text file say 'c:\R-funcs\func.txt' how do I
> get R to find it on the hard disc

source("c:\\R-funcs\\func.txt")

(or replace \\ by /).

> or alternatively where is the default
> location for looking up functions where I can place this file.  eg where
> are functions such as var(), mean() etc stored?

In packages, and the best way of all would be to create a small package
containing your functions.  They you can use

library(mypackage)

to make them available.  But creating a package on Windows is not
for absolute beginners.

> At the moment I'm pasting the text of the function into the GUI prompt,
> not very satisfactory if it is to be used in a programme.
>
> Please forgive any naivety on my part as I am just starting out
>
> Many thanks in advance
>
> Guy
>
>
> ----------------------------------------------------------------------
> Guy J. Forrester			Phone:  01453 860777
> CSL Research Unit			Fax:    01453 860132
> Woodchester Park			e-mail:  g.forrester at csl.gov.uk
> Nymsfield
> Stonehouse
> Gloucestershire
> GL10 3UJ	    			http://www.csl.gov.uk
> ----------------------------------------------------------------------
>
> Disclaimer
> The information contained in this message may include privileged,
> proprietary or confidential information. Please treat it with the same
> respect that you would expect for your own information.  If you have
> received it in error, we apologise, and ask that you contact the CSL
> sender immediately and erase it from your computer. Thank you for your
> co-operation.
>
> Further information on confidentiality of our communications, can be
> found at http://www.csl.gov.uk/email.htm
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list