```r
top_sentiment_words <- words_by_newsgroup %>%
  inner_join(get_sentiments("afinn"), by = "word") %>%
  mutate(contribution = score * n / sum(n))

top_sentiment_words
```

```
## # A tibble: 13,063 x 5
##    newsgroup              word       n score contribution
##    <chr>                  <chr>  <int> <int>        <dbl>
##  1 soc.religion.christian god      917     1      0.0144 
##  2 soc.religion.christian jesus    440     1      0.00692
##  3 talk.politics.guns     gun      425    -1     -0.00668
##  4 talk.religion.misc     god      296     1      0.00465
##  5 alt.atheism            god      268     1      0.00421
##  6 soc.religion.christian faith    257     1      0.00404
##  7 talk.religion.misc     jesus    256     1      0.00403
##  8 talk.politics.mideast  killed   202    -3     -0.00953
##  9 talk.politics.mideast  war      187    -2     -0.00588
## 10 soc.religion.christian true     179     2      0.00563
## # … with 13,053 more rows
```