Minor remark: use the </>
button to format your code, the "
button makes a quotation and it looks a bit funky.
Interestingly enough GroupedErrors already does the correct thing and you can use CategoricalArrays:
using Plots
using StatPlots
using GroupedErrors
using DataFrames
using CategoricalArrays
gr()
v = CategoricalArray(["A","B","A","B","A","B","C","C","C"])
levels!(v, ["B", "C", "A"])
df = DataFrame([v, [1,2,3,2,3,4,6,6,8]], [:Observation, :Count])
@> df begin
@across :all
@x _.Observation :discrete
@y _.Count
@plot groupedbar(ylabel="Fraction of proteome", legend=true)
end
See the CategoricalArrays docs for more details. I think you should also be able to make a column categorical from the DataFrame directly, something like:
df = DataFrame([["A","B","A","B","A","B","C","C","C"], [1,2,3,2,3,4,6,6,8]], [:Observation, :Count])
categorical!(df, :Observation)
levels!(df[:Observation], ["B", "C", "A"])