this is my data
data <- data.frame("Name" = c("Mark", "Jenny", "Linn"),
"Freq" = c("5","7", "3"),
"Percent" = c("33%", "47%", "20%"))
This is my plot
ggplot(data, aes(x=Name, y=Freq)) +
geom_bar(stat="identity", color = "black", fill="dodgerblue1")+
geom_text(label=data$Freq, vjust=-1)
How can I have both my percent label next to my freq label preferably in parenthesis or separated by a comma?
Compose the text label with paste/paste0.
ggplot(data, aes(x = Name, y = as.numeric(Freq))) +
geom_bar(stat = "identity", color = "black", fill = "dodgerblue1")+
geom_text(label = with(data, paste(Freq, paste0('(', Percent, ')'))), vjust=-1) +
ylim(0, 8)

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With