Re: [R] Undestanding return()

From: jim holtman <jholtman_at_gmail.com>
Date: Tue, 26 Apr 2011 17:08:53 -0400

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?

______________________________________________
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.
Received on Tue 26 Apr 2011 - 21:10:25 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 Wed 27 Apr 2011 - 09:40:33 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.

list of date sections of archive