And how to do it if the "J" is an array rather than a vector? So that was also Jcodes array of the same size as J?
julia> J
1557211x2 Array{Int64,2}:
      930070       930070
     1475172      1475172
...                        .....
 21474836496  21474836496
  4296445417   4296445417

Paul

W dniu 2014-12-04 o 19:03, Steven G. Johnson pisze:
It sounds like you have an array J and you want to map each element of J to a unique integer in 1:N for N as small as possible? This will do it:

    d = (Int=>eltype(J))[j => i for (i,j) in enumerate(unique(J))]

    Jcodes = [d[j] for j in J]

Here, d is a dictionary mapping integers in 1:N to the corresponding values in J, and Jcodes is the "re-coded" array.


Reply via email to