Description Usage Arguments Value Author(s) Examples
Create dummy variables using dummy.code from the psych
package. The dummy variables' names can be customized and the variables can be added to the input data frame.
1 2 3 |
dat |
A data frame |
cols |
colnames of variables to be dummy coded |
colname.as.prefix |
Logical: If |
delimiter |
A character string by which the variable name and the level name will be separated (only evaluated if |
capitalize |
Logical: If |
nchar |
Number of characters the level names should be truncated to |
add |
Logical: If |
sort.into.dat |
Logical: If |
oneToColname |
Logical: If |
zeroToNA |
Logical: If |
factor.indices |
Logical: If |
A data frame with dummy variables. Depending on add
the returned object contains either the original data frame with the dummy variables appended or only the dummy variables.
Martin Hecht
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | ## Not run:
data(science1)
science1.dum <- make.dummies(science1, c("sex","booklet"))
str(science1.dum[,1:12])
science1.dum <- make.dummies(science1, c("sex","booklet"), nchar = 1)
str(science1.dum[,1:12])
science1.dum <- make.dummies(science1, c("sex","booklet"), delimiter = "_")
str(science1.dum[,1:12])
science1.dum <- make.dummies(science1, c("sex","booklet"), delimiter = "", capitalize = TRUE)
str(science1.dum[,1:12])
science1.dum <- make.dummies(science1, c("sex","booklet"), colname.as.prefix = FALSE)
str(science1.dum[,1:12])
science1.dum <- make.dummies(science1, c("sex","booklet"), sort.into.dat = FALSE)
str(science1.dum[ , (ncol(science1.dum)-9):ncol(science1.dum)])
science1.dum <- make.dummies(science1, c("sex","booklet"), add = FALSE)
str(science1.dum)
science1.dum <- make.dummies(science1, c("sex","booklet"), oneToColname = TRUE, zeroToNA = TRUE)
str(science1.dum[,1:12])
science1.dum <- make.dummies(science1, c("sex","booklet"), factor.indices = TRUE)
str(science1.dum[,1:12])
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.