运行以下代码后,我收到错误消息:
逗号(计数)错误:找不到函数“逗号”
ggplot(mydata, aes(xvar, fill=yvar)) +
geom_bar(alpha = 0.7) +
scale_y_continuous(breaks = seq(0, 14000, by=1000), label = comma) +
labs(title="title", x="xlab", y="ylab") +
scale_fill_manual(values=c("gold2", "forestgreen", "dimgrey")) +
theme(panel.background = element_rect(fill = 'gray95'),
title = element_text(face = "bold.italic", color = "black"),
plot.title = element_text(hjust = 0.5)) +
geom_text(stat = "count",
aes(label = comma(..count..)),
size = 4,
position = position_stack(vjust = 0.50))
一旦我从comma()
中删除了geom_text()
函数,代码运行正常并生成了我想要的图形,除了数据标签不是逗号格式。我已经加载了“ scales”包,甚至在label = comma
行中使用了scale_y_continuous()
。我在这里做什么错了?