Multi-indicators / "Bag o Words"
This creates an indicator matrix from several columns.
bag(..., prefix = ".", levels = NULL)
... |
the columns to bag |
prefix |
a prefix for the column names |
levels |
levels shared among all columns |
a n*p indicator matrix
df2 <- structure(list(Dx1 = c("231", "231", "001", "245", "231", "001", "231", "001", "231", "001", "001", "245", "001", "231", "245", "245", "001", "231", "245", "001"), Dx2 = c("001", "001", "001", "001", "001", "001", "001", "234", "001", "234", "001", "001", "001", "001", "001", "777", "777", "234", "001", "234"), Dx3 = c("456", "001", "444", "444", "001", "001", "444", "001", "001", "001", "444", "001", "444", "456", "456", "444", "444", "456", "001", "456")), class = "data.frame", row.names = c(NA, -20L)) Y <- 1:nrow(df2) m <- lm(Y~bag(Dx1, Dx2, Dx3), df2) summary(m)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.