I need to populate a column of a data frame with unique factors. I have been using sequential integers, but I don't want to consumer of my function to be confused and think that they can do arithmetic on these values. These values are categorical with no definition for order, distance, and scale. In R, I would have solved this problem with as.factor. I see that there is a CategoricalArrays.jl project, which I have never used, that might offer similar functionality.
Mathematica has a useful Unique function that can create a (as the name implies) unique symbol.
In[1]:= Unique[]
Out[1]= $10
Julia has a similar Symbol that generates a lightweight value that I think makes sense to treat as a factor, but I haven't found a built-in technique to automatically generate unique symbols. You cannot invoke Symbol() without a parameter. I suppose I could call Symbol(UUIDs.uuid1()), but these are very long.
julia> using UUIDs
julia> Symbol(UUIDs.uuid1())
Symbol("8a9452d0-2451-11ec-08b4-3bb7f56a346a")
Is there an idiomatic way to generate short and unique symbols in Julia?