In the end I want to create a scatter plot with a specific value from columns bb:ff against their corresponding value in column gg. In my case, I have a DataFrame which I pull final simulation values out of into a new DataFrame. Is there a way to do with within a DataFrame or should I convert it to a different format? I’ll probably need a way of pulling out the specific values into a Vector or something, to be able to create a scatter plot in the end. Any help or advice is appreciated
Assuming that your dataframe has n rows and n+1 columns (note that the code you posted gives a 6x6 DataFrame, but your screenshot suggests 5x6), you can do:
using LinearAlgebra
scatter(diag(Matrix(asdf[:, 1:end-1])), asdf[!, end])
This will create a square matrix from the first n columns and take the diagonal to create the x vector and then take the last column as the y vector.
Thank you for your reply. diag is undefined for me, is it part of a package? The package LinearAlgebra needs to be added and run.
This is much simpler than what I was trying to use
target_biomass = map(x -> asdf[x, Int.(asdf[:, :gg].+1)[x]], 1:size(asdf, 1)) and was getting
InexactError: Int64(7.033957373089748)
in include_string at base\loading.jl:1088
in top-level scope at untitled:27
in map at base\abstractarray.jl:2162
in collect_similar at base\array.jl:628
in _collect at base\array.jl:699
in iterate at base\generator.jl:47
in at untitled:27
in materialize at base\broadcast.jl:837
in copy at base\broadcast.jl:862
in copyto! at base\broadcast.jl:886
in copyto! at base\broadcast.jl:931
in macro expansion at base\simdloop.jl:77
in macro expansion at base\broadcast.jl:932
in getindex at base\broadcast.jl:575
in _broadcast_getindex at base\broadcast.jl:621
in _broadcast_getindex_evalf at base\broadcast.jl:648
in Int64 at base\float.jl:710