as.dummies | R Documentation |

Create a matrix of dummy vectors (consisting of 0 and 1 only) from factor `x`.
This may be useful if you want to use dummy predictors
in regression analysis.

as.dummies ( x )

`x` |
input factor. |

Levels of the input factor correspond with columns in the output matrix.
The integer value in cell [i,j] of the returned matrix indicates
whether (value=1) or not (value=0)
the i'th observation in the input factor `x` has the value of
the j'th level of that factor.

`as.dummies(x)`

is similar to `model.matrix(~-1+x)`

.

Matrix of integer values 0 or 1. The number of rows of the returned matrix equals the length of the input factor, and the number of columns equals the number of levels of the input factor.

`levels`

, `matrix`

, `model.matrix`

..

xf <- factor( rep(letters[1:3],each=2) ) as.dummies(xf)

hqmisc documentation built on May 9, 2022, 5:08 p.m.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.