Views of Americans about robot vs. human intelligence, All adults”

Author

math4mad

load pacakge

Code
include("utils.jl")
[ Info: loading success

2. load data->dataframe

Code
    df=@pipe CSV.File("./data/views-of-americans-robot-vs-human-intelligence.csv")|>DataFrame|>coalesce.(_, 0.0)

first(df,5)
5×8 DataFrame
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

data processing

Code
 cats=names(df)
 rename!(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
 
 )

 df2=@chain df begin
    @group_by(Day)
    @summarize(none=sum(none),dtkonw=sum(dtkonw),   better=sum(better),nobetter=sum(better),future=sum(future))
    
 end
6×6 DataFrame
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
Code
axis = (width = 1000, height =500,xticklabelrotation = pi/8,title="Attitude about AI development",yticks=(range(100,1000,7),["$i %" for i in 5:5:35]))
data_layer = data(df2)
mapping_layer=mapping(:Day,[:none,:dtkonw,:better,:nobetter,:future].=> "value", color=dims(1) => renamer(cats[4:8]) => "opinion")
visual_layer = visual(ScatterLines;stroke=1,strokecolor=(:red,0.8),markersize=10,linewidth=3)
draw(data_layer * mapping_layer * visual_layer,axis=axis,
 legend=(position=:right, titleposition=:top, framevisible=true, padding=5)
)
┌ Warning: Keyword argument `bgcolor` is deprecated, use `backgroundcolor` instead.
└ @ Makie ~/.julia/packages/Makie/RgxaV/src/makielayout/blocks/legend.jl:23