Understand the factor function in 'R' which is like Categorical in 'Pandas'