How R creates levels of a character variable?

r

#1

I have seen that whenever there is a character variable in the data, R divides that variable into levels and called a factor variable.I want to know how R creates that variable into different levels.

for example I have a variable employee size, It can take three values large,medium,small and R give them as level 1,2,3. I want to know how R give these variable as 1,2,3.


#2

hello @harry,

It seems this is done in alphabetical order.