[R] How to vectorize a function to handle two vectors

Newbie lille_knold at hotmail.com
Fri Aug 26 22:52:44 CEST 2011


Thank you for the quick response! I think you are on the right track - but is
there any way of "calling" (is that the word for it) the function price_call
in the mapply, so that this price_call function is changed to handle
vectors. I believe that this should, in theory if it is correct, make the
result be values. 

I have part of a code that works for only one vector. So maybe some where in
the line of: 
callOptionkVec <- function(phi, kVec, t)
{
	sapply(kVec,function(k) {callOption(phi,k,t)})
}
is what I need to do. Do you have any ideas on how to do this?

--
View this message in context: http://r.789695.n4.nabble.com/How-to-vectorize-a-function-to-handle-two-vectors-tp3771705p3771902.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list