# Transform Categorical Variables into Numerical

I'm very new to machine learning approaches. I'm reading a tutorial for build a predictive model using random forests. One of the transformations implemented was transform categorical variables to binary. Imagine (short sample):

Field_Desc  Field_Value
A               32
A               100
B               1


And then the developer pass this dataset into:

Field_A1    Field_B1    Field_Value
1               0                32
1               0                100
0               1                 1


What is the advantage to make this transformation for Random Forest Prediction? And for K-Means there will have any advantage?

Thanks!

Suppose that you want to have k-means algorithm, in the formulation of average, you have to take the average of each cluster, and then reassign the centers. If you have categorical data, how do you want to take mean? Changing categorical data to numeric data is for translating situations which don't have numerical features to be suited to be used for such algorithms.
That being said, some algorithms have constraints on the cardinality of categorical variables - e.g. randomForest in R only accepts categorical variables with less than 53 levels.