1 min read

Chart Types in R

Histogram

ggplot(data = faithful) +
  aes(x = waiting) + 
  geom_histogram(binwidth = 5, color = 'white') +
  labs(x = 'Minutes Until Next Eruption', y = 'Number of Observations')

histogram

Frequency Polygon

faithful$size = ifelse(faithful$eruptions > 4, 'large', 'small')

ggplot(data = faithful) +
  aes(x = waiting, color = size) + 
  geom_freqpoly(binwidth = 5) +
  labs(x = 'Minutes Until Next Eruption', y = 'Number of Observations', color = 'Eruption Size')

frequency polygon

Box Plot

https://en.wikipedia.org/wiki/Box_plot

faithful$size = ifelse(faithful$eruptions > 4, 'large', 'small')

ggplot(data = faithful) +
  aes(x = size, y = waiting) +
  geom_errorbar(stat='boxplot', width = 0.25) +
  geom_boxplot(stat='boxplot', outlier.color = NA) +
  labs(x = 'Eruption Size', y = 'Minutes Until Next Eruption' )

box plot