I have the following data set:
data = {{"Jakarta","Surabaya","Bandung"},{1,2,3}}
and I'd actually like to assign the numerical values to the categorical data so that Jakarta = 1, Surabaya = 2 and Bandung = 3.
If I use MapThread[Set, {ToExpression[data[[1]]], data[[2]]}]
it works fine but when I try to assign the variables individually I keep on getting error messages:
ToExpression[data[[1, 1]]] = data[[2, 1]]
Set::write: "Tag ToExpression in ToExpression[Jakarta] is Protected."
However, ToExpression[data[[1,1]]
works fine
May I know why my second approach is not working?