R 4.5 - Make a Returned Result Invisible and Build Recursive Functions

preview_player
Показать описание
Use the invisible() function in place of return() in a function to prevent the output from printing to the user's screen but still allow the result to be stored into an R object. Additionally, when building a recursive function, use the Recall() function.
Рекомендации по теме
Комментарии
Автор

Noticed the ifelse() on a single value, however, he is very clear on the use of invisible() versus return() and cautions the use of invisible(). Then nicely clarified the use of Recall() for recursive functions.

douglasm
Автор

Best explanation on recursion in R.
Thank you :)

Tanukosauro
Автор

aargh: another "misuse" of ifelse() :

He has ifelse(x > 1, Recall(log(x)), x)
in a situation where he only speaks of x of length one.
In such a situation,
if(x > 1) Recall(log(x)) else x
is much more efficient and clearly preferred to the ifelse(., ., .) call.

MartinMaechler
Автор

Memoisation should go along with recursion IMO.

Ilyak
Автор

You should speak up a bit or get closer to the mic.

shanjafri