Skip to content

Instantly share code, notes, and snippets.

@sebastiansauer
Created June 28, 2016 12:00
Show Gist options
  • Save sebastiansauer/f555d57dfc91c1de0be04ac256928b58 to your computer and use it in GitHub Desktop.
Save sebastiansauer/f555d57dfc91c1de0be04ac256928b58 to your computer and use it in GitHub Desktop.
Barplot with exact numbers printed in plot
#Barplots with exact numbers
data(tips, package = "reshape2") # load some data
library(dplyr)
library(tidyr)
library(ggplot2)
tips %>%
group_by(sex, smoker) %>%
summarise(mean_group = mean(tip)) %>%
ggplot(aes(x = smoker, y = mean_group,
color = sex, shape = smoker,
group = sex,
label = round(mean_group, 2))) +
geom_point() +
geom_line() +
geom_text(aes(x = smoker, y = mean_group + 0.03))
# see figure online here http://rpubs.com/sebastiansauer/192499
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment