Ifelse and datawrangling

You might want to look at CategoricalArrays.jl, and the recode!() function. I think that interface is really nice and intuitive, and designed for exactly this kind of situation.

Another approach that doesn’t use another package would be to use a dictionary.

d = Dict(k => v for (k, v) in zip(1:3, ("USA", "MEX", "CAN")))

a1.label = [d[n] for n in a1.A]
3 Likes