Re: [R] How to vectorize this function

2018-09-20 Thread Lynette Chang
/sqrt(T)*(sqrt(gamma + y) + ifelse(callM <= call0, -1, 1) * > sqrt(gamma - y)) > > incidentally, I would write > sig <- (sqrt(gamma + y) - sqrt(gamma - y))/sqrt(T) > instead of > sig <- 1/sqrt(T)*(sqrt(gamma + y) - sqrt(gamma - y)) > > -- > Don MacQ

[R] How to vectorize this function

2018-09-20 Thread Lynette Chang
Hello everyone, I’ve a function with five input argument and one output number. impVolC <- function(callM, K, T, F, r) I hope this function can take five vectors as input, then return one vector as output. My vectorization ran into problems with the nested if-else operation