Guest User

Untitled

a guest
Dec 13th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. data <- as.data.frame(as.matrix(c("A","B","C","B","C","C","A","B"),8,1))
  2. data
  3. V1
  4. 1 A
  5. 2 B
  6. 3 C
  7. 4 B
  8. 5 C
  9. 6 C
  10. 7 A
  11. 8 B
  12. library(dummies)
  13. data <- cbind(data, dummy(data$V1, sep = "_"))
  14. > data
  15. V1 data_A data_B data_C
  16. 1 A 1 0 0
  17. 2 B 0 1 0
  18. 3 C 0 0 1
  19. 4 B 0 1 0
  20. 5 C 0 0 1
  21. 6 C 0 0 1
  22. 7 A 1 0 0
  23. 8 B 0 1 0
Add Comment
Please, Sign In to add comment