I have trouble generating the following dummy-variables in R:
I\'m analyzing yearly time series data (time period 1948-2009). I have two questions:
Another way is to use mtabulate from qdapTools package, i.e.
mtabulate
qdapTools
df <- data.frame(var = sample(c("A", "B", "C"), 5, replace = TRUE)) var #1 C #2 A #3 C #4 B #5 B library(qdapTools) mtabulate(df$var)
which gives,
A B C 1 0 0 1 2 1 0 0 3 0 0 1 4 0 1 0 5 0 1 0