I have a programming doubt in R and I have no idea how to solve it after spending hours looking at potential responses on the internet and on Stack Overflow.
In case, the levels are in different order, we can convert the column to factor with levels specified as the unique elements in that column, and then coerce it to numeric/integer.