model.frame mangles time series (PR#121)

Peter Dalgaard BSA p.dalgaard@biostat.ku.dk
18 Feb 1999 17:51:01 +0100


Thomas Lumley <thomas@biostat.washington.edu> writes:

> This is the attributes/subsetting problem rearing its ugly head again.
> model.frame(,subset) has to copy *some* attributes over (eg contrasts) and
> can't copy *all* of them (eg dim).
> 
> Currently we use copyMostAttributes to drop the dangerous ones. It
> clearly didn't know about tsp. 
> 
> Questions:
> (1) How do we know which attributes to copy?
> (2) For an unknown attribute what should the default be?
> (3) Is there just one set of attributes that needs special treatment (in
> which case copyMostAttributes is broken) or are there different sets in
> different circumstances (in which case we need a new function)?
> (4) Could we just handle this by having the subset operator retain
> attributes?

(5) is there really any reason to do subsetting in the .Internal code?
the hot spot is 

    variables <- eval(attr(formula, "variables"), data, sys.frame(sys.parent()))
    extranames <- as.character(substitute(list(...))[-1])
    extras <- substitute(list(...))
    extras <- eval(extras, data, sys.frame(sys.parent()))
    subset <- eval(substitute(subset), data, sys.frame(sys.parent()))
    data <- .Internal(model.frame(formula, rownames, variables, 
        varnames, extras, extranames, subset, na.action))

but what's keeping us from saying 
    data <- .Internal(model.frame(formula, rownames, variables, 
        varnames, extras, extranames, na.action))[subset,]

or ("Uncle Scrooge" version)

   data <- .Internal(model.frame(formula, rownames, variables[subset,], 
        varnames, extras[subset,], extranames, na.action))

(well, variables and extras are lists, not dataframes, but you get the
picture. Do we allow unequal length variables anyway?)

(6) since [subset,] seems to work, perhaps do_subset is what should be
called from inside do_modelframe?

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._