Chapter 72 Term Frequency of Words (TF)

Here we examine the Term Frequency of the words. The commonly occuring Terms are not considered in the bar plot. The commonly occurring terms would be present in the Tail of the plot.

FoodInspectionResultsWords <- FoodInspectionWords

TotalWordsPerResult <- FoodInspectionResultsWords %>% 
  group_by(Results) %>% 
  dplyr::summarize(total = sum(n))

FoodInspectionResultsWords <- left_join(FoodInspectionResultsWords, TotalWordsPerResult)

FoodInspectionResultsWords = FoodInspectionResultsWords %>% filter (!is.na(Results))

ggplot(FoodInspectionResultsWords, aes(n/total, fill = Results)) +
  geom_histogram(bins = 30, show.legend = FALSE) +
  xlim(NA, 0.0009) +
  facet_wrap(~Results, ncol = 2, scales = "free_y") + theme_bw()