[R] (not so real) function (more like #include)

Meinhard Ploner meinhardploner at gmx.net
Wed Oct 4 17:01:32 CEST 2006


Hello R users,

I have a very long function with parts of that looking like a list of  
jobs. The first part of the function defines a lot of local  
variables, which are used by the jobs. Now I extracted the "job" part  
und putted them into an external file, used by "source(, local=T)",  
which is more comfortable to me. Apart from that it gives me the  
opportunity that more users can work on the project. Is it possible  
to define a function for that code and passing to it the environment  
of f() without save(list=ls()) and load() .... ?

Thanks in advance
Meinhard Ploner

longfun <- f() {

	## lot of local variables:
	a <- ...
	b <- ...
	d <- ...
	...

	out <- ...

	source("job1.txt", local=TRUE)	 #changes out, uses a, b, d, ...
	
	source("job2.txt", local=TRUE)	# changes out, uses a, b, d, ...
	...
}



version
                _
platform       i386-apple-darwin8.6.1
arch           i386
os             darwin8.6.1
system         i386, darwin8.6.1
status
major          2
minor          3.1
year           2006
month          06
day            01
svn rev        38247
language       R
version.string Version 2.3.1 (2006-06-01)



More information about the R-help mailing list