I met a weird problem when I am using R, I'm using data.table:
Here, when I tried to convert those Province has count under 500 to "Other", the output changes the top count Provinces into index number
df <- fact_data[,.N,Province][N >= 500]$Province
df
fact_data[,Province := ifelse(Province %in% df, fact_data$Province, "Other")]
fact_data[,.N,Province][order(-N)]
But, this method worked well on those factor variables which values are in numeric format. For example, instead of using Province, if I use BranchNumber, the values look like "1", "3", I got the input like this, which is good:
Do you know, why this happened and how to resolve the problem?