Skip to content
Prev 269909 / 398502 Next

How to vectorize a function to handle two vectors

On Aug 26, 2011, at 2:43 PM, Newbie wrote:

            
? mapply
Oh, you thought of that.
Huh?
I think the problem is (at least) slightly more complex than you first  
described. You should spend more time describing in unambiguous  
language the conditions and operations. Keep reading.
Hmmmm, I get 16 values. Maybe you should put some more time into  
understanding why it does not return the structure you expect.  
phiHubHeston returns a function. Was that what you designed?
This is what I get with the mapply call I would have expected for use  
of a function which is what phiHeston(subHeston) returns:

 > # This should give 4 values
 > mapply(phiHeston(subHeston), kV, tV)
[1] 0.9973156-0.0029158i 0.9862950-0.0124475i 0.9752339-0.0178313i
[4] 0.9406358-0.0336025i

Whether these are the "right" 4 values is for you to determine.