Hello! I have a problem with my code, I need to round the number that are in my variable "ratio", here is the ggplot code
mydata <- (....source code)
ui <- (nothing special)
plotouput ("mydata")
server <- blablabla
output$mydata <- renderPlot ({
ggplot(mydata %>% filter(chart_name == 'AppDownloadUsage'), aes(x = chart_name, y = ratio, fill = slice_name)) +
geom_bar(colour="black",stat = "identity")+
geom_text(aes(label= ratio, position = "stack")
How can I round the number of my variable ratio?
Thank you very much for the help
pomchip
2
I would round the variable in the data before plotting it using the round or signif functions (you can read more using ?round and ?signif)
1 Like
I thought I would only work in ggplot but I needed to do it before, thank you very much, it works
mara
4
You can round right in the aesthetic, if you want:
suppressPackageStartupMessages(library(tidyverse))
ggplot(data = mtcars, aes(x = mpg, y = round(wt, digits = 0))) +
geom_point()
Created on 2018-10-18 by the reprex package (v0.2.1.9000)
6 Likes
system
Closed
5
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.