[R]: global and local variables
allan clark
allan at stats.uct.ac.za
Tue Dec 9 12:17:59 CET 2003
Hi all
I have a problem pertaining to local and global variables.
Say I have a function defined as follows:
a<-function(x)
{y<x^2}
i.e
a(2)
[1] 4
function b is now defined to take the value of y and do some
manipulation with it. As it stands I dont know how to store the
variable y such that other functions are able to reference its value.
I know that I can simply put the operations found in b simply into a
but this is not what I want.
I would like to have stand alone functions say
a, b and c which could be run independently as well as have a function
called say
control that can run a, b and c.
i.e.
control<- function( x)
{
a(x)
b(x)
c(x)
}
I hope that you guys understand what I'm trying to do.
Cheers
Allan
More information about the R-help
mailing list