Skip to content

Instantly share code, notes, and snippets.

@madilk
Last active February 27, 2021 19:44
Show Gist options
  • Save madilk/6ab60fb7694526fca4a7ba19d352c193 to your computer and use it in GitHub Desktop.
Save madilk/6ab60fb7694526fca4a7ba19d352c193 to your computer and use it in GitHub Desktop.
GGplot R - Make geom_historgram bin start at zero
##geom_histogram_v2 with center
ggplot(data=diamonds)+
geom_histogram(mapping=aes(x = carat),
binwidth = 0.5,center=0.25)
##geom_histogram_v3 with boundary
ggplot(data=diamonds)+
geom_histogram(mapping=aes(x = carat),
binwidth = 0.5,boundary=0)
##geom_histogram
ggplot(data=diamonds)+
geom_histogram(mapping=aes(x = carat),
binwidth = 0.5)
#check summary of data
summary(diamonds)
##dplyr to get count of cut
diamonds %>%
count(cut_width(carat,0.5))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment