Skip to content
Back to formatted view

Raw Message

Message-ID: <Pine.LNX.4.64.0809081601180.4760@parser.ilovebacon.org>
Date: 2008-09-08T23:02:38Z
From: Adam D. I. Kramer
Subject: Saving functions
In-Reply-To: <47449876FE77EA468DD9029D978FD621ADF078@EXXMAIL02.desktop.frd.metoffice.com>

Hi Robin,

source("filename.R")

will open filename.R from the working directory and behave as if you had
typed in its contents, line by line.

You can include a full path if you like, or use file.choose() for a file not
in your working directory.

--Adam

On Mon, 8 Sep 2008, Williams, Robin wrote:

> Hi,
>  Appologies for the simple nature of this question, I am unable to find
> the answer in manuals (EG and introduciton to R).
>  I have written a function in a text editor and saved it with an .R
> extension. It is saved in my working directory. How can I run it, do I
> need to use source? If so, how do I supply the arguments to the
> function? Or does it need to be saved in a particular directory?
>  Do I need a different file extension?
> Many thanks for any help.
>
>
> Robin Williams
> Met Office summer intern - Health Forecasting
> robin.williams at metoffice.gov.uk
>
>
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
>