我正在研究一个项目,并试图制作一些图形。我对编码还很陌生,因此任何帮助将不胜感激。我创建了一个图形,但底部的标签重叠,因此我尝试在代码的不同位置单独添加geom_text_repel()和geom_label_repel(),但我不断收到错误消息:“ FUN(X [[ i]],...):找不到对象“ prop””。我还尝试将ggrepel添加到aes层,但出现错误:“错误:stat_count需要以下缺少的美观性:x”。有没有人对如何使ggrepel与我的代码一起使用有任何想法,或者有其他方法使标签不重叠?这是我的代码:
df %>%
filter(!is.na(`Self Reported Race (roll up)_Cleaned`)) %>%
ggplot() +
aes(
x = C19_Employment,
y = ..prop..,
group = `Self Reported Race (roll up)_Cleaned`,
fill = `Self Reported Race (roll up)_Cleaned`,
na.rm = TRUE
) +
labs(
title = "Employment Status by Self-Reported Race",
x = "Employment Status",
y = "Proportion of Race",
fill = "Self-Reported Race"
) +
geom_bar(position = "dodge", na.rm = TRUE) +
theme(legend.position = "bottom")
以及原始图形的图像:(Original Graph