I have a set of orders with items and where they are sourced from. I need to add a unique counter per order for the item and for the supplier. Note that this unique counter is a unique counter to each order.
library('tidyverse')
library('partitions')
df <- read_table('Order Item Source
1     100 Supplier1
1     101 Supplier1
1     102 Supplier2
1     106 Supplier3
2     107 Supplier4
2     108 Supplier4
3     104 Supplier5
3     103 Supplier6')
The output should look something like this table:
Order Item ItemNum Source SourceNum
    1     100 1 Supplier1 1
    1     101 2 Supplier1 1
    1     102 3 Supplier2 2
    1     106 4 Supplier3 3
    2     107 1 Supplier4 1
    2     108 2 Supplier4 1
    3     104 1 Supplier5 1
    3     103 2 Supplier6 2
 
     
     
     
    