Hi. I have a bar graph that shows the count of students attending or not attending online class. But I want the percentage to appear as labels. How can I do it?
library(tidyverse)
library(scales)
#>
#> Attaching package: 'scales'
#> The following object is masked from 'package:purrr':
#>
#> discard
#> The following object is masked from 'package:readr':
#>
#> col_factor
nit<-tibble::tribble(
~online_class,
"Yes",
"Yes",
"Yes",
"Yes",
"Yes",
"No",
"Yes",
"No",
"Yes",
"Yes",
"Yes",
"No"
)
ggplot(nit,aes(online_class))+
geom_bar(aes(fill=online_class))+
geom_text(stat = 'count',aes(label=..count..))
Created on 2022-03-17 by the reprex package (v2.0.1)