[R] model.matrix()
Peter Dalgaard BSA
p.dalgaard at biostat.ku.dk
Mon Aug 30 10:51:12 CEST 1999
Thomas Yee <yee at wintermute.anu.edu.au> writes:
> whereas in S I get the following:
>
> > attr(i, "assign")
> $"(Intercept)":
> [1] 1
>
> $x:
> [1] 2
>
> $f:
> [1] 3 4 5 6 7 8 9 10
>
> Has anybody written a model.matrix function to get the same
> result as S? It's just that S's output is what I want, viz.,
>
> 1. the names "(Intercept)","x","f", and
>
> 2. the vector values.
Hmm. Do we want to change that? For now, something like
a <-attr (i, "assign")
tt<-terms(~x+f)
a <- factor(a,labels=c(
if(attr(tt,"intercept")) "(Intercept)", attr(tt,"term.labels")))
split(seq(along=a),a)
would seem to do.
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help 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-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list