Her you just make the functions. R> calculate <- function(x,y){z <- x + y} R> recalculate <- function(z){a <- z^2}
You should run the functions, by take z as output for the first function ans z as input for the next function: R> calculate <- function(x,y){z <- x + y} R> recalculate <- function(z){a <- z^2} R> z <- calculate(1,2) R> a <- recalculate(z) R> z [1] 3 R> a [1] 9 Good luck, Kristel David Hajage wrote: > Hello, > > I'm a new user... > > I have a function : > > calculate <- function(x,y) > { > z <- x + y > } > I would like to use the result (z) with another function : > > recalculate <- function(...) > { > a <- z^2 > } > > But R says that z does not exist... > > How can I use z in an another function ? > > Thank you for your answer... > > -- > David > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@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 -- __________________________________________ Kristel Joossens Ph.D. Student Research Center ORSTAT K.U. Leuven Naamsestraat 69 Tel: +32 16 326929 3000 Leuven, Belgium Fax: +32 16 326732 E-mail: [EMAIL PROTECTED] http://www.econ.kuleuven.be/public/ndbae49 Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm ______________________________________________ R-help@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