I'm working with R studio. I'm having issues with how to divide this up I have:
ID | COLOR | NUMBER |
---|---|---|
321 | RED | 3 |
321 | GREEN | 10 |
321 | BLUE | 4 |
067 | RED | 50 |
067 | BLUE | 2 |
067 | YELLOW | 3 |
111 | PURPLE | 10 |
111 | YELLOW | 2 |
I want:
ID | red | green | blue | yellow | PURPLE |
---|---|---|---|---|---|
321 | 3 | 10 | 4 | 0 | 0 |
067 | 50 | 0 | 2 | 3 | 0 |
111 | 0 | 0 | 0 | 2 | 10 |
I got the advice on here to use:
Data <- as.data.frame.matrix(table(cbind(file_name[1], unlist(file_name[-1]))))
and I got a good start, but I had to change my data around and I can't incorporate the extra number column I added.