Description Usage Arguments Value Examples
Take a vector of data frame columns which only have two values and convert them into binary factors with common labels and levels
1 |
df |
a dataframe |
vec |
a vector of columns to convert to binary factors such as c(1, 5, 8) |
labels |
desired labels |
levels |
desired levels |
a data frame with columns from vec converted to binary factors
1 2 3 4 5 6 7 | Saturday_Money <-sample(0:1,20,replace=TRUE)
Sunday_Money <-sample(1:2,20,replace=TRUE)
Sat_Work <-sample(c("Play", "Work"), 20, replace=TRUE)
Sun_Work <-sample(c("Play", "Work"), 20, replace=TRUE)
df1<-data.frame(Saturday_Money, Sat_Work, Sunday_Money, Sun_Work)
df1_fact <- mut_bin(df1, vec = c(1, 2,3,4))
df1_fact
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.