Re: [R] source a specific function

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Mon, 18 Jun 2007 10:28:35 -0400

This loads all the functions into an anonymous environment defined by local and then exports f to the global environment.

f <- local({

	source("/a.R", local = TRUE)
	environment(f) <- .GlobalEnv
	f

})

On 6/18/07, Weiwei Shi <helprhelp_at_gmail.com> 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).
>
> Thanks,
>
> --
> Weiwei Shi, Ph.D
> Research Scientist
> GeneGO, Inc.
>
> "Did you always know?"
> "No, I did not. But I believed..."
> ---Matrix III
>
> ______________________________________________
> R-help_at_stat.math.ethz.ch 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-help_at_stat.math.ethz.ch 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. Received on Mon 18 Jun 2007 - 17:29:39 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 18 Jun 2007 - 17:32:04 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.