Julia: Export results to table: example code

Viewed 2561

Please point to example code and documentation on approaches to export some data and simulation results to a tidy, readable table that could easily be copy-pasted or imported into documents, particularly for post-processing with LaTeX.

My current practice is along the lines of:

using DataFrames
function show_table(mp::ModelParameters, ms::ModelSolution)
    α = mp.α; δ = ms.δ;
    d = DataFrame(Name = @data(["α"]),
                  Description = @data(["alpha"]),
                  Value = @data([α])
    )
    push!(d, @data(["δ", "delta", δ]))
    return(d)
end

    2×3 DataFrames.DataFrame
    │ Row │ Name │ Description │ Value │
    ├─────┼──────┼─────────────┼───────┤
    │ 1   │ "α"  │ "alpha"     │ 1.01  │
    │ 2   │ "δ"  │ "delta"     │ 2.02  │

Turning the above into a LaTeX table will require some work. Any step in the right direction will be appreciated.

I have found a promising package named LaTeX.jl that does not seem to be maintained and/or has been superseded. The dream would be to have something like stargazer for R.

I have used unicode Greeks in my code, e.g. α, which can be compiled with XeLaTeX, but a solution where α were converted to \alpha would be welcome too. An alternative would be to manually replace the names in my convenience function show_table, which is not so bad.

3 Answers
Related