As soon as you execute the 'return' , the value is returned. What you did not show is did the code have if-then-else to go down separate paths. On Tue, Apr 26, 2011 at 5:29 PM, Bogaso Christofer <bogaso.christofer at gmail.com> wrote:> Here, I have following generic function: > > > > Fn1 <- function(x) { > > ? ? ? ? ? ? ? ?........ > > ? ? ? ? ? ? ? ?return(x) ?# assume x is calculated in previous steps > > > > ? ? ? ? ? ? ? ?......... > > ? ? ? ? ? ? ? ?return(y) ?# assume y is calculated in previous steps > > > > ? ? ? ? ? ? ? ?.......... > > ? ? ? ? ? ? ? ?return(z) ?# assume z is calculated in previous steps > > } > > > > In this case what fn1 will return. Is it the value of "x" all the time? And > hence this function will never calculate y and z? > > > > Thanks and regards, > > > > > > > ? ? ? ?[[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org 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. >-- Jim Holtman Data Munger Guru What is the problem that you are trying to solve?
Here, I have following generic function: Fn1 <- function(x) { ........ return(x) # assume x is calculated in previous steps ......... return(y) # assume y is calculated in previous steps .......... return(z) # assume z is calculated in previous steps } In this case what fn1 will return. Is it the value of "x" all the time? And hence this function will never calculate y and z? Thanks and regards, [[alternative HTML version deleted]]
Yes, if there are no control statements such as "if" that prevent that return function from being activated. --------------------------------------------------------------------------- Jeff Newmiller The ..... ..... Go Live... DCN:<jdnewmil@dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries O.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --------------------------------------------------------------------------- Sent from my phone. Please excuse my brevity. Bogaso Christofer <bogaso.christofer@gmail.com> wrote: Here, I have following generic function: Fn1 <- function(x) { ........ return(x) # assume x is calculated in previous steps ......... return(y) # assume y is calculated in previous steps .......... return(z) # assume z is calculated in previous steps } In this case what fn1 will return. Is it the value of "x" all the time? And hence this function will never calculate y and z? Thanks and regards, [[alternative HTML version deleted]]_____________________________________________ R-help@r-project.org 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. [[alternative HTML version deleted]]