Hey guys,
I have a question regarding arrays and matrices:
I would like to create a 2D matrix where the first column contains arrays and the second column contains integer values, e.g.
Column 1 ----- Column 2
[“a” “b” “c”] -------- 1
[“d” “e” “f”] -------- 2
[“g” “h”] ------------ 4
[“i” “j” “k” “lm”] ---- 9
…
Unfortunately, when I try do this my array elements are “unpacked” and instead of storing the array as a whole, the individual elements are stored in the matrix.
For example:
a = [["a" "b" "c"] 2]
gives
1×4 Array{Any,2}:
"a" "b" "c" 2
instead of
1×2 Array{Any,2}:
["a" "b" "c"] 2
Now, I have found a workaround for this by saying
a = Any[0 2]
a[1] = ["a" "b" "c"]
But surely that cannot be the correct/clean way of doing that. So, how do I do this correctly?
PS: This is my first question ever, if I posted in the wrong category or something else please tell me how do it correctly. Thanks.