From jorismeys at gmail.com  Mon Jun  6 20:38:48 2011
From: jorismeys at gmail.com (Joris Meys)
Date: Mon, 6 Jun 2011 20:38:48 +0200
Subject: [Rd] Possible bug in termplot function (stats package) ?
In-Reply-To: <9B2E15B5-AE4F-4849-96D5-A5DE8896DC80@gmail.com>
References: <BANLkTikkDxdR_1+TJNX5LMkr23spvOJ4+A@mail.gmail.com>
	<9B2E15B5-AE4F-4849-96D5-A5DE8896DC80@gmail.com>
Message-ID: <BANLkTi=uHfZ62TSfLa-a+E-n9RU47_vS5A@mail.gmail.com>

On Mon, Jun 6, 2011 at 6:29 PM, peter dalgaard <pdalgd at gmail.com> wrote:
>
> On Jun 6, 2011, at 17:15 , Joris Meys wrote:
>
**snip**
>> If nothing is found, an error is returned. If
>> anything is found, data won't be NULL, so line 20, when reached, will
>> always return FALSE. Can it be that lines 18 and 19 should be removed
>> from the function?
>
>
> I think this is a false assumption. What keeps model$call$data from being NULL?
>
Apart from a dataframe that is explicitly assigned NULL, I can't
imagine a case where model$call$data would be NULL. If it's not found,
the statement returns an error. If it is found and it is NULL, your
model call will have thrown an error earlier, so you won't even have
an object to plot. If you can give me one example where that code
actually makes sense, I'll be very happy. But right now, it doesn't
make any sense at all to me.

> No comments on the remainder, except that it wouldn't be the first time a wrapper function got into trouble with environments and modelling functions...
>
My wrapper function returns a completely sound lm-object. Why wouldn't
I expect a function built to work on lm-objects to work on an
lm-object? At least the help files should note that the dataframe will
be sought in the calling environment, or it won't work on your fitted
objects.

Right now I have to do something like :

termplot.wrapper <- function(x,...){
    x$call$data <- NULL
    termplot(x)
}

which seems at least a tiny bit awkward...

Cheers
Joris


-- 
Joris Meys
Statistical consultant

Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

tel : +32 9 264 59 87
Joris.Meys at Ugent.be
-------------------------------
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php



[Rd] Possible bug in termplot function (stats package) ?
Joris Meys