Dear all, I get an error using the return function.  The following is a
simpler version.

for (j in 1:10)
{
    samples = 5*j
    return(samples)
}

Error: no function to return from, jumping to top level


Similar warning happens with if statement.

Why do I get an error?  print() works fine.  I don't see anywhere in the
documentation says that return() is not allowed inside for loop.

I know the list is for advanced computation topics, and I don't want to
bother the list too much.  Where should I look for things like this in the
future?

?return() nor the R documentation does not mention any of this.

Bob

        [[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.

Reply via email to