[R] Questions on formula in princomp
Berton Gunter
gunter.berton at gene.com
Mon Apr 17 17:43:16 CEST 2006
As always, please read the Help file, in particular the details on encoding
of factors. It's dense, but it explains everything.
-- Bert
> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Sasha Pustota
> Sent: Friday, April 14, 2006 9:08 PM
> To: r-help at stat.math.ethz.ch
> Subject: Re: [R] Questions on formula in princomp
>
> jim holtman <jholtman at gmail.com> wrote:
> > does this explain it?
> >
> > > groups <- factor(c(rep("Z",5),rep("X",5),rep("Y",5)))
> > >
> > > groups
> > [1] Z Z Z Z Z X X X X X Y Y Y Y Y
> > Levels: X Y Z
> > > as.integer(groups)
> >
> > [1] 3 3 3 3 3 1 1 1 1 1 2 2 2 2 2
> > > c(1,2,3)[groups]
> > [1] 3 3 3 3 3 1 1 1 1 1 2 2 2 2 2
>
> I did notice the lexicographical ordering of Z,X,Y. I don't understand
> the meaning of c(1,2,3) "subscription" by a factor. I understand
> subscription by an integer, or by a single item as in associative
> arrays. Or does "[]" have a different meaning here?
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>
More information about the R-help
mailing list