Code
include("utils.jl")
[ Info: loading success
load pacakge
include("utils.jl")
[ Info: loading success
=@pipe CSV.File("./data/views-of-americans-robot-vs-human-intelligence.csv")|>DataFrame|>coalesce.(_, 0.0)
df
first(df,5)
Row | Entity | Code | Day | None of these | Don't know | Most robots have already developed higher levels of intelligence than humans | Robots will never be able to develop higher levels of intelligence than humans | Robots will be able to develop higher levels of intelligence than humans in the future |
---|---|---|---|---|---|---|---|---|
String31 | Float64 | Date | Int64 | Int64 | Int64 | Int64 | Int64 | |
1 | 18-29 years | 0.0 | 2021-01-07 | 6 | 18 | 14 | 14 | 47 |
2 | 18-29 years | 0.0 | 2021-07-01 | 8 | 22 | 19 | 12 | 39 |
3 | 18-29 years | 0.0 | 2022-01-06 | 3 | 20 | 11 | 17 | 49 |
4 | 18-29 years | 0.0 | 2022-06-30 | 9 | 18 | 20 | 18 | 35 |
5 | 18-29 years | 0.0 | 2023-01-05 | 9 | 14 | 16 | 15 | 46 |
=names(df)
catsrename!(df,"None of these"=>:none,"Don't know"=>:dtkonw,
"Most robots have already developed higher levels of intelligence than humans"=>:better,
"Robots will never be able to develop higher levels of intelligence than humans"=>:nobetter,
"Robots will be able to develop higher levels of intelligence than humans in the future"=>:future
)
=@chain df begin
df2@group_by(Day)
@summarize(none=sum(none),dtkonw=sum(dtkonw), better=sum(better),nobetter=sum(better),future=sum(future))
end
Row | Day | none | dtkonw | better | nobetter | future |
---|---|---|---|---|---|---|
Date | Int64 | Int64 | Int64 | Int64 | Int64 | |
1 | 2021-01-07 | 136 | 482 | 263 | 263 | 958 |
2 | 2021-07-01 | 139 | 560 | 345 | 345 | 793 |
3 | 2022-01-06 | 146 | 538 | 277 | 277 | 933 |
4 | 2022-06-30 | 243 | 441 | 346 | 346 | 883 |
5 | 2023-01-05 | 240 | 494 | 303 | 303 | 906 |
6 | 2023-06-29 | 181 | 478 | 410 | 410 | 832 |
= (width = 1000, height =500,xticklabelrotation = pi/8,title="Attitude about AI development",yticks=(range(100,1000,7),["$i %" for i in 5:5:35]))
axis = data(df2)
data_layer =mapping(:Day,[:none,:dtkonw,:better,:nobetter,:future].=> "value", color=dims(1) => renamer(cats[4:8]) => "opinion")
mapping_layer= visual(ScatterLines;stroke=1,strokecolor=(:red,0.8),markersize=10,linewidth=3)
visual_layer draw(data_layer * mapping_layer * visual_layer,axis=axis,
=(position=:right, titleposition=:top, framevisible=true, padding=5)
legend )
┌ Warning: Keyword argument `bgcolor` is deprecated, use `backgroundcolor` instead.
└ @ Makie ~/.julia/packages/Makie/RgxaV/src/makielayout/blocks/legend.jl:23