Rows: 122 Columns: 3
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (2): qname, label
dbl (1): level
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Rows: 24 Columns: 2
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (2): qname, question
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Rows: 65437 Columns: 28
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (2): country, currency
dbl (26): response_id, main_branch, age, remote_work, ed_level, years_code, ...
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
qfilter <-function(q) { qname_levels_single_response_crosswalk %>%filter(qname == q) %>%select(level, label) %>%rename_with(~q, level) %>%rename_with(~paste0(q, "_label"), label)}age_levels <-c("Under 18 years old","18-24 years old","25-34 years old","35-44 years old","45-54 years old","55-64 years old","65 years or older","Prefer not to say" ) %>%str_remove(., " years( old)*")ai_sent_levels <-c("Very unfavorable","Unfavorable","Indifferent/Unsure","Favorable","Very favorable")stack_overflow_ai <- stackoverflow_survey_single_response %>%left_join(qfilter("age")) %>%left_join(qfilter("main_branch")) %>%left_join(qfilter("ai_sent")) %>%mutate(age_label =str_remove(age_label, " years( old)*")) %>%# filter(ai_sent_label != "Unsure") %>%mutate(ai_sent_label =case_when( ai_sent_label =="Indifferent"| ai_sent_label =="Unsure"~"Indifferent/Unsure",TRUE~ ai_sent_label )) %>%mutate(age_label =fct_relevel(age_label, age_levels),ai_sent_label =fct_relevel(ai_sent_label, ai_sent_levels) )
Joining with `by = join_by(age)`
Joining with `by = join_by(main_branch)`
Joining with `by = join_by(ai_sent)`
P1
A fill-position bar ggplot
library(ggplot2)stack_overflow_ai |>ggplot() +aes(y = age_label) +aes(fill = ai_sent_label) +geom_bar(position ="fill") +NULL+NULL+theme(legend.position ="none") +labs(y =NULL, fill =NULL, x =NULL)
P2
A likert plot with ggstats
library(ggplot2)library(ggstats)stack_overflow_ai |>ggplot() +aes(y = age_label) +aes(fill = ai_sent_label) +geom_likert() +geom_likert_text(hide_below =0.03) +scale_fill_likert() +theme(legend.position ="none") +labs(y =NULL, fill =NULL, x =NULL)