Hi, I have a dataset which looks like this:
code to get this dataset:
using InMemoryDatasets,DLMReader
import Downloads
data=Downloads.download("https://raw.githubusercontent.com/akshdfyehd/travel/main/Travel%20details%20dataset.csv")
data=filereader(data, quotechar='"', dtformat=Dict(3:4 .=> dateformat"m/d/y"))
data=data[completecases(data),:]
modify!(data, 11 => x -> parse.(Int, replace.(x, "\$" =>"","USD" =>"",","=>"")))
modify!(data, 13 => x -> parse.(Int, replace.(x, "\$" =>"","USD" =>"",","=>"")))
group=groupby(data,["Accommodation type","Traveler gender"])
ds=combine(group, 11 =>IMD.mean)
I was trying to produce a graph like this, which I saw on stackoverflow:
I want to draw a similar graph using my dataset, where JOB1,2,3 replaced by accommodation type, and each small graph have male and female with label of mean accommodation cost. This is the example code I get from stackoverflow:
using InMemoryDatasets
using StatisticalGraphics
ds=Dataset(BR=["BR1","BR2","BR3"],JOB1=[.5,.3,.6],JOB2=[.4,.2,.5],JOB3=[.5,.6,.3])
# data manipulation
ds2=transpose(gatherby(ds,:BR),r"JOB")
modify!(ds2,:_c1=>byrow(x->[x,1-x])=>:progress,:BR=>byrow(x->[x,missing])=>:cat)
flatten!(ds2,[:progress,:cat])
# plot
sgplot(
groupby(ds2,:_variables_),
Pie(category=:cat,response=:progress,group=:BR,innerradius=0.3, label=:percent,labelcolor=:white,colormodel=[:blue,:white,:orange,:green]),
layout=:row,headercolname=false,legend=false,width=200,height=200
)
This is the link to the post:
I noticed there was a step using “:BR=>byrow(x->[x,missing])=>:cat” but this just doesn’t work on mine dataset, and of course I got the wrong graph. So what should I do to get the result? Thanks for any advices.