[R] gradient vector

Tim Sulser tim at sulser.com
Sun Jan 26 20:25:03 CET 2003

Greetings R-folk,

I'll greatly appreciate any help you can offer...

I can't figure out how to add the gradient vector of a function f(x,y) 
evaluated at a point (x1,y1) onto a contour() graph.  I see that 
deriv(...,func=TRUE) gives a function that takes (x1,y1) and gives the 
correct gradient (x2,y2) as part of it's output, but I haven't been able to 
feed that info into an arrows(x1,y1,x1+x2,y1+y2) command.  I've tried using 
attr(eval(deriv(...),"gradient"), but can't make it work  Or is there 
something I've completely missed?



tim at sulser.com

More information about the R-help mailing list