Chapter 5 Length Comparison

We examine the median length of the sentences by the different authors and plot in a flipped bar plot.

HP Lovecraft writes long sentences with the highest number of words per sentence.Edgar Allen Poe writes short sentences compared to the other Two authors.

train %>%
  group_by(author) %>%
  summarise(CountMedian = median(len,na.rm = TRUE)) %>%
  ungroup() %>%
  mutate(author = reorder(author,CountMedian)) %>%
  
  ggplot(aes(x = author,y = CountMedian)) +
  geom_bar(stat='identity',colour="white", fill = fillColor2) +
  geom_text(aes(x = author, y = 1, label = paste0("(",CountMedian,")",sep="")),
            hjust=0, vjust=.5, size = 4, colour = 'black',
            fontface = 'bold') +
  labs(x = 'author', 
       y = 'Count', 
       title = 'author and Count') +
  coord_flip() + 
  theme_bw()