Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- data <- as.data.frame(as.matrix(c("A","B","C","B","C","C","A","B"),8,1))
- data
- V1
- 1 A
- 2 B
- 3 C
- 4 B
- 5 C
- 6 C
- 7 A
- 8 B
- library(dummies)
- data <- cbind(data, dummy(data$V1, sep = "_"))
- > data
- V1 data_A data_B data_C
- 1 A 1 0 0
- 2 B 0 1 0
- 3 C 0 0 1
- 4 B 0 1 0
- 5 C 0 0 1
- 6 C 0 0 1
- 7 A 1 0 0
- 8 B 0 1 0
Add Comment
Please, Sign In to add comment