A geospatial and sentiment analysis of how European consumers discuss sustainable coffee on X (formerly Twitter), using R.
Overview
Across 15 European countries, discussions about sustainable coffee are overwhelmingly positive — driven by appreciation for ethical sourcing, fair trade certification, and eco-friendly packaging. Scepticism surfaces mainly around carbon neutrality claims and consumer pricing.
Sentiment analysis
Sentiment scored using the Bing lexicon (tidytext package), with compound scores normalised to –1 (very negative) through 0 (neutral) to +1 (very positive). All charts generated in R with ggplot2.
Country breakdown
All 15 countries with at least 10 tweets, ranked by mean sentiment score. All countries are net positive — Austria leads, Ireland records the lowest score.
| Country | Tweets | Score | % Positive | Volume |
|---|---|---|---|---|
| Austria AT | 14 | 0.786 | 78.6% | |
| Belgium BE | 22 | 0.742 | 77.3% | |
| Spain ES | 78 | 0.692 | 71.8% | |
| United Kingdom GB | 198 | 0.673 | 70.7% | |
| Finland FI | 29 | 0.667 | 69.0% | |
| Germany DE | 137 | 0.659 | 69.3% | |
| Portugal PT | 36 | 0.657 | 69.4% | |
| Denmark DK | 42 | 0.651 | 66.7% | |
| Sweden SE | 47 | 0.645 | 66.0% | |
| Italy IT | 113 | 0.637 | 70.8% | |
| France FR | 122 | 0.628 | 67.2% | |
| Netherlands NL | 59 | 0.599 | 64.4% | |
| Norway NO | 39 | 0.598 | 61.5% | |
| Poland PL | 39 | 0.590 | 64.1% | |
| Ireland IE | 25 | 0.560 | 56.0% |
Theme analysis
Tweets automatically tagged by sustainability theme using keyword matching in R. A single tweet may belong to multiple themes.
Bar length = mean sentiment score (0–1 scale). Corporate and packaging themes dominate positive discussion; consumer and carbon themes show more ambivalence.
Geospatial analysis
Tweet locations mapped using R's sf package with Natural Earth boundaries. Switch between map views below.
UK, Germany, and France account for the highest tweet volumes, reflecting both population size and English-language social media presence.
Sentiment is broadly positive across all countries. Central European countries (Austria, Belgium) score slightly higher than Nordic and Eastern European markets.
Bubble size encodes tweet volume; colour encodes mean sentiment score (green = positive). The UK dominates volume while maintaining strong positive sentiment.
Reproduce this analysis
The full pipeline is open source. You need R ≥ 4.2 and a free X Developer account.
Download the project from GitHub to your machine.
git clone https://github.com/Anesu-Chimbi/Sustainable-coffee-perceptions-europe
Create a free X Developer account at developer.twitter.com, create an App, and copy your Bearer Token from Keys & Tokens.
Create a .env file from the template and paste in your token.
cp .env.example .env
Open R or RStudio in the project folder and run the master script.
source("Sustainable-coffee/scripts/run_all.R")
Charts and maps appear in Sustainable-coffee/outputs/. Open this page locally or push to GitHub Pages.
X API v2 recent search. Keywords: "sustainable coffee", "eco coffee", "fair trade coffee". Auth: Bearer Token via httr2. Falls back to mock data if no token is set.
Bing lexicon via tidytext. Word scores aggregated per tweet into a normalised compound score. Threshold: positive > 0.05, negative < –0.05.
Country boundaries from rnaturalearthdata (50m). Choropleth and bubble maps rendered with ggplot2 + sf + patchwork.