I have a column of int’s like this:
idNums
2
101
34
25
8
...
I need to convert them to 3 factor columns like this:
digit1 digit2 digit3
0 0 2
1 0 1
0 3 4
0 2 5
0 0 8
... ... ...
Any suggestions?
Here’s a fun solution using the modular arithmetic operators
%%and%/%:Note that it has the minor — but nice — side benefit of returning numeric values for each of the columns. If you do, however, want factor columns instead, just follow up with this command: