Separating a column into a variable number of possible columns

Thanks! I see…the transpose ’ operator is what I knew too. I will have a better look at permutedims(). This is what I love about julia. You can do the same thing in different ways…the down side of this, of course, is that you need to invest time to be able to find and learn the existing alternatives…

This is a different way to record values that would be useful if no ordering were relevant. In my case, though, b,d signifies that the person has a better skill at b than d and there is no commutative relation between b,d and d,b. The ordering info is lost in that case.
However, it is equally useful to have this method of split_uniformly() whose output you have here, since it applies to many other cases with questionnaires where people are sloppy in their answer and the ordering of the answer is also irrelevant. That would make life easier in those cases, since splitting a column that has values that do not respect any rule of ordering (i.e., b,d === d,b and let === be semantic equality) would be difficult especially for further processing, such as counting tokens of the values. The table that you output is clean and would make counting and further analysis a breeze. Do you think you could add the code for your split_uniformly()?

1 Like

function split_uniformly(v)
    s = split.(v, ',')
    nts=[(Symbol.(ss).=>ss) for ss in s]
    su=union(s...)
    n = length(su)
    nt0=(;zip(Symbol.(su),fill(missing,n))...)
    [merge(nt0,nt)  for nt in nts]

end
1 Like