[R] design matrix creation in R

Duncan Murdoch murdoch.duncan at gmail.com
Tue Jul 3 22:39:15 CEST 2012


On 03/07/2012 4:10 PM, mmstat at comcast.net wrote:
> Hello,
>
> I want to create a design matrix using R. Can you explain the code which creates the following please? I understand the first part.
> b=g1(?) does what?

That is gl, not g1 (i.e. gee ell not gee one).    See ?gl for a 
description.

Duncan Murdoch
>
> dd <- data.frame(a = gl(3,4), b = gl(4,1,12)) # balanced 2-way
> dd
> a b
> 1 1 1
> 2 1 2
> 3 1 3
> 4 1 4
> 5 2 1
> 6 2 2
> 7 2 3
> 8 2 4
> 9 3 1
> 10 3 2
> 11 3 3
> 12 3 4
>
> I am using the tree dataset in R. I want to form a reparameterized design matrix in ones, zeroes and minus ones. The dataframe dd is very important here.
>
> Can anyone assist here? Thanks in advance.
>
> Mary A. Marion
>
>
>
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list