[Solved] How can I use the chain operator do calculation with itself in R?


Promoting my comment to an answer as the OP appears to agree (and removing a spurious ) in the process):

computeY <- function(x) { sqrt(1-(x-1)^2) }

which at the prompt works as well:

R> computeY <- function(x) { sqrt(1-(x-1)^2) }
R> sapply((1:5)/10, computeY)
[1] 0.435890 0.600000 0.714143 0.800000 0.866025
R> 

Disclaimer: No pipes were hurt in the production of this answer.

1

solved How can I use the chain operator do calculation with itself in R?