Last data update: 2014.03.03

R: Incidence Matrix of Levels within a Factor
at.levelR Documentation

Incidence Matrix of Levels within a Factor

Description

Incidence matrix of levels within a factor

Usage

at.level(x, level)

Arguments

x

factor

level

factor level

Value

incidence matrix for level in x

Author(s)

Jarrod Hadfield j.hadfield@ed.ac.uk

See Also

at.set

Examples

fac<-gl(3,10,30, labels=letters[1:3])
x<-rnorm(30)
model.matrix(~at.level(fac,"b"):x)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(MCMCglmm)
Loading required package: Matrix
Loading required package: coda
Loading required package: ape
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/MCMCglmm/at.level.Rd_%03d_medium.png", width=480, height=480)
> ### Name: at.level
> ### Title: Incidence Matrix of Levels within a Factor
> ### Aliases: at.level
> ### Keywords: manip
> 
> ### ** Examples
> 
> fac<-gl(3,10,30, labels=letters[1:3])
> x<-rnorm(30)
> model.matrix(~at.level(fac,"b"):x)
   (Intercept) at.level(fac, "b"):x
1            1           0.00000000
2            1           0.00000000
3            1           0.00000000
4            1           0.00000000
5            1           0.00000000
6            1           0.00000000
7            1           0.00000000
8            1           0.00000000
9            1           0.00000000
10           1           0.00000000
11           1           0.76547413
12           1          -0.04707389
13           1          -0.03880977
14           1          -1.42269183
15           1           1.99537651
16           1           1.11665490
17           1           0.94056238
18           1           0.38497422
19           1          -0.05477439
20           1          -2.18873834
21           1           0.00000000
22           1           0.00000000
23           1           0.00000000
24           1           0.00000000
25           1           0.00000000
26           1           0.00000000
27           1           0.00000000
28           1           0.00000000
29           1           0.00000000
30           1           0.00000000
attr(,"assign")
[1] 0 1
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>