table: Brands_12M as data.table
Names(Brands_12M): "Major Category", "Brand", "Sales"
There are 5 major categories and 500 brands.
I am trying to add "Rank" column to based on "Sales" by "Major Category" using:
Brands_12M <- Brands_12M[,Rank := frankv(Brands_12M, "Sales", "Major Category", order=-1L)]
I am getting rank 1-500 for all brands ignoring "Major Category". I need rank by brand for each "Major Category" i.e. 1-100, 1-100 etc
Greatly appreciate any suggestion.