I am creating a bar chart through ggplot to display survey responses. I want to add data labels, but when I add a data label it displays 14 digits after the decimal. I do not need any digits after the decimal. Where in my code can I have ggplot round the y values?
I have tried several other code suggestions that I have found online, but because this is a calculated field through the below code, the percentages are not displayed in my imported data, the imported data only has the survey responses and I am dropping them into the displayed categories.
ggplot(activeanglers, aes(factor(YearsFishing))) +
geom_bar(aes(fill = factor(..x..)), stat="count") +
scale_y_continuous(labels = scales::percent_format(accuracy = 1)) +
ylab("relative frequencies") + xlab("How many years have you fished?") + ylab("Percent of Respondents") + scale_x_discrete(breaks=c("1","2","3", "4", "5", "NA"),labels=c("First Year", "2-5", "6-9", "10+", "Missing", "NA")) + theme(legend.position = "none") + geom_text(aes(label=stat(prop)*100, group=1),stat='count',nudge_y=0.125)