[R] source a specific function

Duncan Murdoch murdoch at stats.uwo.ca
Mon Jun 18 16:36:37 CEST 2007


On 6/18/2007 9:54 AM, Weiwei Shi wrote:
> Dear Listers:
> 
> For example, if I have a .R source file which has more than one
> function, and I want to just load only one of the functions, how could
> I do that? (removing the rest after sourcing is not what I intend b/c
> in my workspace, I might have some of the rest and I don't want to
> change my workspace: i.e., I only change my workspace by adding one
> function from a R source file).

In Windows, open the file in an editor, copy (e.g. by highlighting it 
and hitting Ctrl-C) the part you want to source to the clipboard, and 
then in R enter source("clipboard"), or just paste the selected text.

I think source("clipboard") is Windows-specific, but other platforms 
support copy and paste in their own ways.

Duncan Murdoch



More information about the R-help mailing list