Explicitly calling return in a function or not

0 votes
A while back, Simon Urbanek from the R core team (I believe) chastised me for advising a user to use return directly at the end of a function (his comment was later removed):

The formula foo = function() + return(value)
Rather, he suggested:

value = function() + foo
Probably, in this circumstance, it is necessary to:

"foo" = "function()"; "if(a)" "return(a)" "otherwise" "return(b)"
His reply clarified the benefits of not calling return unless absolutely necessary, but it was taken down.

Why doesn't calling return sooner or better, and hence be preferred?
Jul 6, 2022 in Data Science by avinash
• 1,840 points
355 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Data Science

0 votes
0 answers

To speed up the tapply function in R, or another function to convert data frame into a matrix

I must turn a sizable dataset into ...READ MORE

Jun 24, 2022 in Data Science by Sohail
• 3,040 points
358 views
0 votes
0 answers

In R, how to get an object's name after it is sent to a function?

I'm trying to find the opposite of ...READ MORE

Jul 5, 2022 in Data Science by avinash
• 1,840 points
297 views
0 votes
1 answer

How to make loop for one-at-a time logistic regression in R?

You're probably looking for something similar to ...READ MORE

answered Jun 20, 2022 in Data Science by Sohail
• 3,040 points
1,036 views
0 votes
1 answer

Why is it not advisable to use attach() in R, and what should I use instead?

There is one more option that applies ...READ MORE

answered Jun 24, 2022 in Data Science by Sohail
• 3,040 points
465 views
0 votes
1 answer

rnorm function in R - Usage

y = rnorm(12, rep(c(1,2,1), each=4, 0.2)) I can ...READ MORE

answered Jun 24, 2022 in Data Science by Sohail
• 3,040 points
645 views
0 votes
1 answer

Filter multiple values on a string column in dplyr

The filter() function is used to select ...READ MORE

answered Jun 14, 2022 in Data Science by Sohail
• 3,040 points
1,045 views
0 votes
1 answer

Big Data transformations with R

Dear Koushik, Hope you are doing great. You can ...READ MORE

answered Dec 18, 2017 in Data Analytics by Sudhir
• 1,570 points
1,030 views
0 votes
2 answers

Transforming a key/value string into distinct rows in R

We would start off by loading the ...READ MORE

answered Mar 26, 2018 in Data Analytics by Bharani
• 4,660 points
1,178 views
0 votes
1 answer

Finding frequency of observations in R

You can use the "dplyr" package to ...READ MORE

answered Mar 26, 2018 in Data Analytics by Bharani
• 4,660 points
5,890 views
0 votes
1 answer

Left Join and Right Join using "dplyr"

The below is the code to perform ...READ MORE

answered Mar 27, 2018 in Data Analytics by Bharani
• 4,660 points
1,112 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP