A colleague asked me the following question the other day. In the following piece of code, how do you extract the gradient:
> x=5 > a = eval(deriv(~ x^3, \
Not sure these count as better, but:
with(attributes(a), gradient)
or
attributes(a)$gradient
are alternatives that return the attributes as a list from which to select.