Hello all,
I'm trying to make a graph to highlight the differences in proportions on several factors, between two conditions. Originally I made a side-by-side column chart, but then I found the graphs on this page and thought they would be more easily digestible. But I'm having trouble making the geom_linerange() part.
My data is here:
tribble(
~Factor, ~Perc_struc, ~Perc_unstruc, ~diff,
Influencer, 26, 52, 26,
Friends_relatives, 33, 10, 23,
Young age, 85, 66, 19,
Organized crime, 67, 86, 19,
Actual distribution, 89, 72, 17,
Special skills, 22, 38, 16,
Special zone, 22, 38, 16,
Destroy evidence or hinder, 78, 66, 12,
Influenced by another, 22, 34, 12
My failed graph code, which works if you delete the linerange() part, is here:
considered_rankings_bigDiff |>
pivot_longer(cols = c("Perc_struc", "Perc_unstruc"), names_to = "Group", values_to = "Percent") |>
ggplot() +
geom_point(aes(x=Factor, y=Percent, color=Group)) +
geom_linerange(aes(ymin= Percent, ymax= Percent)) +
#geom_linerange(data=considered_rankings_bigDiff, aes(ymin= Perc_struc, ymax= Perc_unstruc)) +
theme_classic() +
#scale_fill_manual(values=c("#FFC107", "#E91E63"), labels=c("Semi-structured", "Unstructured")) +
labs(title = "Differences in Consideration of Factors Across Conditions") +
scale_x_discrete(labels=function(x) stringr::str_wrap(x, width = 10)) +
theme(legend.title=element_blank())