Skip to content
Prev 359722 / 398502 Next

Ask if an object will respond to a function or method

On 03/31/2016 04:00 PM, Paul Johnson wrote:
coef(zz) finds stats:::coef.default, which happens to do the right thing 
for zz but also 'works' (returns without an error) for things that don't 
have coefficients, e.g., coef(data.frame()).

stats:::coef.default is

 > stats:::coef.default
function (object, ...)
object$coefficients

Maybe fail on use, rather than trying to guess up-front that the object 
is fully appropriate?

Martin Morgan
This email message may contain legally privileged and/or confidential information.  If you are not the intended recipient(s), or the employee or agent responsible for the delivery of this message to the intended recipient(s), you are hereby notified that any disclosure, copying, distribution, or use of this email message is prohibited.  If you have received this message in error, please notify the sender immediately by e-mail and delete this email message from your computer. Thank you.