Directly creating dummy variable set in a sparse matrix in R
Thanks for having clarified your question, try this. Here is sample data with two columns that have three and two levels respectively: set.seed(123) n <- 6 df <- data.frame(x = sample(c(“A”, “B”, “C”), n, TRUE), y = sample(c(“D”, “E”), n, TRUE)) # x y # 1 A E # 2 C E # 3 B … Read more