Re: R-alpha: incompatibilities

Thomas Lumley (thomas@biostat.washington.edu)
Tue, 10 Sep 1996 14:48:32 -0700 (PDT)


Date: Tue, 10 Sep 1996 14:48:32 -0700 (PDT)
From: Thomas Lumley <thomas@biostat.washington.edu>
To: r-testers@stat.math.ethz.ch
Subject: Re: R-alpha: incompatibilities
In-Reply-To: <Pine.SUN.3.91.960910103115.27995A-100000@chekov>

This incompatibility was reported earlier today

> 1. When model.frame() is called with a formula containing literal arguments, 
> the column names are X1,X2 etc, rather than deparse(substitute()) applied 
> to the argument: eg

The following modification to model.frame() correctly handles literals in 
the predictors (but not in the response).

thomas lumley

---------------------------------------------
"model.frame" <-
function (formula, data, weights = NULL, offset = NULL, subset = NULL, 
	na.action = na.fail) 
{
	frame <- attr(terms(formula), "variables")
	if (missing(data)) 
		data <- sys.frame(sys.parent())
	if (is.null(weights) & is.null(offset)) 
		rval <- na.action(eval(frame, data)[subset, , drop = FALSE])
	else if (is.null(offset)) 
		rval <- na.action(data.frame(eval(frame, data), .weights = weights)[subset
			, , drop = FALSE])
	else if (is.null(weights)) 
		rval <- na.action(data.frame(eval(frame, data), .offset = offset)[subset
			, , drop = FALSE])
	else rval <- na.action(data.frame(eval(frame, data), .weights = weights
		, .offset = offset)[subset, , drop = FALSE])
	attr(rval, "terms") <- terms(formula)
	xnames<-attr(terms(formula), "term.labels")   ### changes
        names(rval)[-1]<-xnames                       ###
	rval
	
}
----------------------------------------------------------
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
r-testers mailing list -- To (un)subscribe, send
subscribe	or	unsubscribe
(in the "body", not the subject !)  To: r-testers-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-