Given a Julia list of lists:
data = [[1,2],[4,5]]
which has type Vector{Int64}, how can I convert this to a 2D data type (e.g. 2×2 Matrix{Int64}) so that I can index it like data[:,2]? I tried hcat or vcat but couldn't get the result that I wanted. Thanks in advance!
You can do:
julia> reduce(hcat, data)
2×2 Matrix{Int64}:
1 4
2 5
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With