R 需要绘制ggplot的帮助吗

R 需要绘制ggplot的帮助吗,r,ggplot2,bar-chart,R,Ggplot2,Bar Chart,我有两列-一列有数字(部分),另一列在r中显示其good或bad。 下面是一个示例数据 df如果您先计算数据,您尝试的方法将起作用: library(dplyr) df_count = count(df, G_or_B, Section) ggplot(df_count, aes(x = Section, y = n, fill = G_or_B) )+ geom_col() + geom_text(aes(label = n), size = 3, position = positi

我有两列-一列有数字(部分),另一列在
r
中显示其
good
bad
。 下面是一个示例数据


df如果您先计算数据,您尝试的方法将起作用:

library(dplyr)
df_count = count(df, G_or_B, Section)
ggplot(df_count, aes(x = Section, y = n, fill = G_or_B) )+ 
  geom_col() +
  geom_text(aes(label = n), size = 3, position = position_stack(vjust = 0.5))