[R] model.matrix()
Thomas Lumley
thomas at biostat.washington.edu
Mon Aug 30 17:23:08 CEST 1999
On Mon, 30 Aug 1999, Thomas Yee wrote:
> Hi,
>
> In R I get the following:
>
> > x <- 1:9
> > f <- as.factor(1:9)
> > i <- model.matrix(~x+f)
> >
> > attr(i, "assign")
> [1] 0 1 2 2 2 2 2 2 2 2
>
> 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.,
>
As well as the previous suggestions, you will find in library(survival5) a
function attrassign() that converts an 'assign' attribute to the new
style.
-thomas
Thomas Lumley
Assistant Professor, Biostatistics
University of Washington, Seattle
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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