In R, when I try to assign a function via ifelse , I get the following error:
> my.func <- ifelse(cond, sqrt, identity) Error in rep(yes, length.out = length(ans)) : attempt to replicate an object of type 'builtin'
If cond is FALSE , the error looks equivalent, R complains about
attempt to replicate an object of type 'closure'
What can I do to assign one of two functions to a variable and what happens here?
r functional-programming
quazgar
source share