Creates dummy-coded variables.
This function adds dummy-coded variables to a data frame based on a vector of column names.
dummyCode(df, vars)
df |
A data frame. |
vars |
The variables in the data frame for which you want to create new dummy coded variables. |
A a dataframe with new dummy-coded variables added.
# Create an example data frame: df <- data.frame( animal = c("dog", "goldfish", "bird", "dog", "goldfish"), numLegs = c(4, 0, 2, 4, 0), lifeSpan = c(10, 10, 5, 10, 10)) # Create dummy coded variables for the variables "animal" and "numLegs": df_dummy <- dummyCode(df, vars = c("animal", "numLegs")) df_dummy
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.