Unlike R, Julia's DataFrame constructor expects the values in each column to be passed as a vector rather than as a tuple: so DataFrame(b = ["Hi", "Med", "Hi", "Low"],
&tc.
Also, DataFrames does not expect explicit levels to be given in the way R does it. Instead, the optional keyword argument categorical
is available and should be set to "a vector of Bool indicating which columns should be converted to CategoricalVector".
(after adding the DataFrames and the CategoricalArrays packages)
julia> using DataFrames, CategoricalArrays
julia> xyorz = categorical(rand(("x","y","z"), 5))
5-element CategoricalArray{String,1,UInt32}:
"z"
"y"
"x"
"x"
"z"
julia> smallints = rand(1:4, 5)
5-element Array{Int64,1}:
2
3
2
1
1
julia> df = DataFrame(A = 1:5, B = xyorz, C = smallints)
5×3 DataFrame
│ Row │ A │ B │ C │
│ │ Int64 │ Categorical… │ Int64 │
├─────┼───────┼──────────────┼───────┤
│ 1 │ 1 │ z │ 2 │
│ 2 │ 2 │ y │ 3 │
│ 3 │ 3 │ x │ 2 │
│ 4 │ 4 │ x │ 1 │
│ 5 │ 5 │ z │ 1 │
now, what do you want to sort? A on (B then C)? [4, 3, 2, 5, 1]
julia> sort(df, (:B, :C))
5×3 DataFrame
│ Row │ A │ B │ C │
│ │ Int64 │ Categorical… │ Int64 │
├─────┼───────┼──────────────┼───────┤
│ 1 │ 4 │ x │ 1 │
│ 2 │ 3 │ x │ 2 │
│ 3 │ 2 │ y │ 3 │
│ 4 │ 5 │ z │ 1 │
│ 5 │ 1 │ z │ 2 │
julia> sort(df, (:B, :C)).A
5-element Array{Int64,1}:
4
3
2
5
1
This is a good place to start http://juliadata.github.io/DataFrames.jl/stable/