I am looking on how to write a function that convert a dataframe in long format, like dim1|dim2|dim3|value, to an Array of values or a NamedArray, using missing for when a given combination is not present, and without knowing a priori the number of columns e.g.:
using DataFrames, CSV
df = CSV.read(IOBuffer("""
reg prod var value
us banana production 10
us banana transfCoef 0.6
us banana trValues 2
us apples production 7
us apples transfCoef 0.7
us apples trValues 5
us juice production missing
us juice transfCoef missing
us juice trValues missing
eu banana production 5
eu banana transfCoef 0.7
eu apples production 8
eu apples transfCoef 0.8
eu apples trValues 4
eu juice production missing
eu juice transfCoef missing
eu juice trValues missing
"""), DataFrame, delim=" ", ignorerepeated=true, copycols=true, missingstring="missing")
Note that the df above is missing the row (eu, banana, trValues).
I did found a solution for NamedArray here, but as it uses reshape() it doesn't work in situations like this.
Alternatively I can create an Array with all missing values by querying the unique values of the dimension columns and then creating the array with Array{Union{Missing,valueType},length(size)}(missing,size...) but then I don't know on how to populate it (again, I don't know a priori that the dimensions are 3 like in the example)