R scripts for a data-driven analysis of trust signals in online reviews to inform collaborative consumer protection

BackgroundOnline consumer protection is a relatively underdeveloped and debated area, as Online Service Providers (OSPs) collect, monetise and utilise large amounts of consumer data, often without full consumer awareness or consent. Despite the widespread availability of consumer review data, research on how to systematically leverage it to improve collaborative consumer protection efforts remains limited. We investigated this gap by conducting a longitudinal analysis of trust signals and consumer perceptions of OSPs' ability, integrity, and benevolence, as reflected in online reviews. We provide the R scripts used to process and analyse the data in this repository.The analysis was undertaken at two time points, 2021 and 2026. There are separate R scripts for each time of analysis.2021Data acquisitionAmazon customer review data for the period of May 1996 to October 2018 was downloaded by product category (29 categories) from http://deepyeti.ucsd.edu/jianmo/amazon, a site curated by Jianmo Ni and colleagues[1]. In total, across all product categories, the dataset contains 233.1 million reviews. Within each product category, the downloaded data were converted from JSON format to a compressed binary format (to reduce file size and speed up data read and write time), were filtered for verified reviews only (reviews by customers who had bought the product from Amazon), and then a random sample of 10% and 1% of the reviews was taken from each product category. Each of the 10% samples and each of the 1% samples were then collated into a 10% and 1% analysis set. After this preliminary filtering, the 10% sample consisted of 19 167 694 (~19 million) reviews and the 1% sample of 1 916 770 (~2 million) reviews. The 1% dataset was used as a toy dataset to develop the analysis code for the larger 10% sample and to explore the data. The remainder of this report only deals with the processing, analysis and results for the 10% sample.Data processingData pre-processing of the analysis set involved the following steps: i) converting all text to lowercase, ii) removing punctuation, iii) removing numbers, iv) removing stopwords using the snowballC library, v) removing extra white space, vi) unnesting the reviews into single-term tokens (unigrams), vii) lemmatising the words, and viii) filtering for tokens of at least four characters in length. The 10% sample yielded 312 686 638 (~310 million) unigrams for analysis from ~19 million individual reviews. Finally, to enrich the dataset for the tokens manually tagged during the protocol development stage (Table 1), similar word forms were converted to match the manually tagged tokens. The changes were as follows: fair to fairness, expert to expertise, discrete to discreteness, fulfil to fulfilment, credible to credibility, loyal to loyalty, honest to honesty, reliable to reliability, dependable to dependability, receptive to receptivity, empathy to empathetic, and benevolent to benevolence. Table 1. Topics and tokens identified in a manual corpus-tagging processTopicTokenAbilityBusiness sense, Judgement, Functional competence, Inter-personal competence, Expertise, Information, Overall abilityIntegrityFairness in transactions, fairness in data usage, fairness in service, Fairness, discreteness, integrity, loyalty, promise fulfilment, credibility, honesty, reliability, dependabilityBenevolenceReceptivity, Concern, Empathy, BenevolenceTerm frequency analysisOnly term frequency analysis and not term frequency-inverse document frequency (tf-idf) was performed because with ~19 million documents, the tf-idf outputs were uninterpretable. To calculate term frequency, the total number of times a word appeared was calculated, and then this value was divided by the total number of words under analysis. Words were then ranked from most frequent to least frequent. Lastly, the words from the manually tagged list (Table 1) were categorised according to the identified topics, namely, ability, integrity, and benevolence. The most frequent 20 terms overall were extracted and plotted. In addition, the manually tagged terms were also extracted and plotted.Sentiment analysisThe positive and negative sentiment, and the balance between the two, were assessed by extracting positive and negative words from the complete list of tokenised words. The Bing sentiment lexicon, which contains 4781 negative words and 2005 positive words, was used as the reference lexicon. Once the positive and negative words matching the Bing lexicon had been extracted, the frequency of each term was calculated, and the 10 most frequent terms were extracted and plotted.Topic modellingTokenised data were converted to a document-term matrix (DTM), and subject to Latent Dirichlet Allocation (LDA) analysis using collapsed Gibbs sampling (seed = 2021, burn-in = 1000 iterations, total iterations = 3000). The number of topics was restricted to 20. Only an unsupervised LDA was performed, with no seeded terms. Once the LDA analyses had been run, beta values (per-topic-per-word probabilities) were calculated for each model, and the 20 terms with the greatest beta values within each model were extracted and plotted. SoftwareAll analysis was performed in the R Statistical Environment (v4.04). General data cleaning packages included: dplyr, forcats, ndjson, purrr, readr, stringr, and tidyr. Text modelling packages included: quanteda, stopwords, textstem, tidytext, tm, and topicmodel. Plotting was done using the ggplot2 package and wordcloud2 package. [1] Jianmo Ni, Jiacheng Li, Julian McAuley. Justifying recommendations using distantly-labelled reviews and fine-grained aspects. Empirical Methods in Natural Language Processing (EMNLP), 20192026Data acquisitionAmazon customer review data for the period of May 1996 to September 2023 was downloaded by product category (34 categories) from https://amazon-reviews-2023.github.io, a site curated by the Julian McAuley laboratory at University of California San Diego[1]. In total, across all product categories, the dataset contains ~ 572 million reviews. Within each product category, the downloaded data were converted from JSON format to comma-separated values (CSV) file format, and filtered for verified reviews only (reviews by customers who had bought the product from Amazon). The timestamp variable was then used to filter the sample so that it extended from the end of the previous analysis period (October 2018) to the most recent records (September 2023), and then a random sample of 10% of the reviews was taken from each product category. Each of the 10% samples was then collated into a single analysis dataset. After this preliminary filtering, the dataset consisted of 28 792 888 (~29 million) reviews.Data processingData pre-processing of the analysis set involved the following steps: i) converting all text to lowercase, ii) removing punctuation, iii) removing numbers, iv) removing stopwords using the snowballC library, v) removing extra white space, vi) unnesting the reviews into single-term tokens (unigrams), vii) lemmatising the words, and viii) filtering for tokens of at least four characters in length. The dataset yielded 372 198 908 (~372 million) unigrams for analysis from ~29 million individual reviews. Finally, to enrich the dataset for the tokens manually tagged during the protocol development stage (Table 1), similar word forms were converted to match the manually tagged tokens. The changes were as follows: fair to fairness, expert to expertise, discrete to discreteness, fulfil to fulfilment, credible to credibility, loyal to loyalty, honest to honesty, reliable to reliability, dependable to dependability, receptive to receptivity, empathy to empathetic, and benevolent to benevolence. Table 1. Topics and tokens identified in a manual corpus-tagging processTopicTokenAbilityBusiness sense, Judgement, Functional competence, Inter-personal competence, Expertise, Information, Overall abilityIntegrityFairness in transactions, fairness in data usage, fairness in service, Fairness, discreteness, integrity, loyalty, promise fulfilment, credibility, honesty, reliability, dependabilityBenevolenceReceptivity, Concern, Empathy, BenevolenceTerm frequency analysisOnly term frequency analysis and not term frequency-inverse document frequency (tf-idf) was performed because with ~29 million documents, the tf-idf outputs were uninterpretable. To calculate term frequency, the total number of times a word appeared was calculated, and then this value was divided by the total number of words under analysis. Words were then ranked from most frequent to least frequent. Lastly, the words from the manually tagged list (Table 1) were categorised according to the identified topics, namely, ability, integrity, and benevolence. The most frequent 20 terms overall were extracted and plotted. In addition, the manually tagged terms were also extracted and plotted.Sentiment analysisThe positive and negative sentiment, and the balance between the two, were assessed by extracting positive and negative words from the complete list of tokenised words. The Bing sentiment lexicon, which contains 4781 negative words and 2005 positive words, was used as the reference lexicon. Once the positive and negative words matching the Bing lexicon had been extracted, the frequency of each term was calculated, and the 10 most frequent terms were extracted and plotted.Topic modellingTokenised data were converted to a document-term matrix (DTM), and subjected to Latent Dirichlet Allocation (LDA) analysis using collapsed Gibbs sampling (seed = 2026, burn-in = 1000 iterations, total iterations = 3000). The number of topics was restricted to 20. Only an unsupervised LDA was performed, with no seeded terms. Once the LDA analyses had been

Authors

Publication Details

Journal
Figshare
Published
2026-10-31
DOI
https://doi.org/10.6084/m9.figshare.34867170
Primary Topic
Digital Marketing and Social Media
Type
article
Field-Weighted Citation Impact
0.00
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
article

R scripts for a data-driven analysis of trust signals in online reviews to inform collaborative consumer protection

Peter R. Kamerman, Raymond Chinembiri
Figshare
Digital Marketing and Social Media
article

R scripts for a data-driven analysis of trust signals in online reviews to inform collaborative consumer protection

Peter R. Kamerman, Raymond Chinembiri
article en

Abstract

BackgroundOnline consumer protection is a relatively underdeveloped and debated area, as Online Service Providers (OSPs) collect, monetise and utilise large amounts of consumer data, often without full consumer awareness or consent. Despite the widespread availability of consumer review data, research on how to systematically leverage it to improve collaborative consumer protection efforts remains limited. We investigated this gap by conducting a longitudinal analysis of trust signals and consumer perceptions of OSPs' ability, integrity, and benevolence, as reflected in online reviews. We provide the R scripts used to process and analyse the data in this repository.The analysis was undertaken at two time points, 2021 and 2026. There are separate R scripts for each time of analysis.2021Data acquisitionAmazon customer review data for the period of May 1996 to October 2018 was downloaded by product category (29 categories) from http://deepyeti.ucsd.edu/jianmo/amazon, a site curated by Jianmo Ni and colleagues[1]. In total, across all product categories, the dataset contains 233.1 million reviews. Within each product category, the downloaded data were converted from JSON format to a compressed binary format (to reduce file size and speed up data read and write time), were filtered for verified reviews only (reviews by customers who had bought the product from Amazon), and then a random sample of 10% and 1% of the reviews was taken from each product category. Each of the 10% samples and each of the 1% samples were then collated into a 10% and 1% analysis set. After this preliminary filtering, the 10% sample consisted of 19 167 694 (~19 million) reviews and the 1% sample of 1 916 770 (~2 million) reviews. The 1% dataset was used as a toy dataset to develop the analysis code for the larger 10% sample and to explore the data. The remainder of this report only deals with the processing, analysis and results for the 10% sample.Data processingData pre-processing of the analysis set involved the following steps: i) converting all text to lowercase, ii) removing punctuation, iii) removing numbers, iv) removing stopwords using the snowballC library, v) removing extra white space, vi) unnesting the reviews into single-term tokens (unigrams), vii) lemmatising the words, and viii) filtering for tokens of at least four characters in length. The 10% sample yielded 312 686 638 (~310 million) unigrams for analysis from ~19 million individual reviews. Finally, to enrich the dataset for the tokens manually tagged during the protocol development stage (Table 1), similar word forms were converted to match the manually tagged tokens. The changes were as follows: fair to fairness, expert to expertise, discrete to discreteness, fulfil to fulfilment, credible to credibility, loyal to loyalty, honest to honesty, reliable to reliability, dependable to dependability, receptive to receptivity, empathy to empathetic, and benevolent to benevolence. Table 1. Topics and tokens identified in a manual corpus-tagging processTopicTokenAbilityBusiness sense, Judgement, Functional competence, Inter-personal competence, Expertise, Information, Overall abilityIntegrityFairness in transactions, fairness in data usage, fairness in service, Fairness, discreteness, integrity, loyalty, promise fulfilment, credibility, honesty, reliability, dependabilityBenevolenceReceptivity, Concern, Empathy, BenevolenceTerm frequency analysisOnly term frequency analysis and not term frequency-inverse document frequency (tf-idf) was performed because with ~19 million documents, the tf-idf outputs were uninterpretable. To calculate term frequency, the total number of times a word appeared was calculated, and then this value was divided by the total number of words under analysis. Words were then ranked from most frequent to least frequent. Lastly, the words from the manually tagged list (Table 1) were categorised according to the identified topics, namely, ability, integrity, and benevolence. The most frequent 20 terms overall were extracted and plotted. In addition, the manually tagged terms were also extracted and plotted.Sentiment analysisThe positive and negative sentiment, and the balance between the two, were assessed by extracting positive and negative words from the complete list of tokenised words. The Bing sentiment lexicon, which contains 4781 negative words and 2005 positive words, was used as the reference lexicon. Once the positive and negative words matching the Bing lexicon had been extracted, the frequency of each term was calculated, and the 10 most frequent terms were extracted and plotted.Topic modellingTokenised data were converted to a document-term matrix (DTM), and subject to Latent Dirichlet Allocation (LDA) analysis using collapsed Gibbs sampling (seed = 2021, burn-in = 1000 iterations, total iterations = 3000). The number of topics was restricted to 20. Only an unsupervised LDA was performed, with no seeded terms. Once the LDA analyses had been run, beta values (per-topic-per-word probabilities) were calculated for each model, and the 20 terms with the greatest beta values within each model were extracted and plotted. SoftwareAll analysis was performed in the R Statistical Environment (v4.04). General data cleaning packages included: dplyr, forcats, ndjson, purrr, readr, stringr, and tidyr. Text modelling packages included: quanteda, stopwords, textstem, tidytext, tm, and topicmodel. Plotting was done using the ggplot2 package and wordcloud2 package. [1] Jianmo Ni, Jiacheng Li, Julian McAuley. Justifying recommendations using distantly-labelled reviews and fine-grained aspects. Empirical Methods in Natural Language Processing (EMNLP), 20192026Data acquisitionAmazon customer review data for the period of May 1996 to September 2023 was downloaded by product category (34 categories) from https://amazon-reviews-2023.github.io, a site curated by the Julian McAuley laboratory at University of California San Diego[1]. In total, across all product categories, the dataset contains ~ 572 million reviews. Within each product category, the downloaded data were converted from JSON format to comma-separated values (CSV) file format, and filtered for verified reviews only (reviews by customers who had bought the product from Amazon). The timestamp variable was then used to filter the sample so that it extended from the end of the previous analysis period (October 2018) to the most recent records (September 2023), and then a random sample of 10% of the reviews was taken from each product category. Each of the 10% samples was then collated into a single analysis dataset. After this preliminary filtering, the dataset consisted of 28 792 888 (~29 million) reviews.Data processingData pre-processing of the analysis set involved the following steps: i) converting all text to lowercase, ii) removing punctuation, iii) removing numbers, iv) removing stopwords using the snowballC library, v) removing extra white space, vi) unnesting the reviews into single-term tokens (unigrams), vii) lemmatising the words, and viii) filtering for tokens of at least four characters in length. The dataset yielded 372 198 908 (~372 million) unigrams for analysis from ~29 million individual reviews. Finally, to enrich the dataset for the tokens manually tagged during the protocol development stage (Table 1), similar word forms were converted to match the manually tagged tokens. The changes were as follows: fair to fairness, expert to expertise, discrete to discreteness, fulfil to fulfilment, credible to credibility, loyal to loyalty, honest to honesty, reliable to reliability, dependable to dependability, receptive to receptivity, empathy to empathetic, and benevolent to benevolence. Table 1. Topics and tokens identified in a manual corpus-tagging processTopicTokenAbilityBusiness sense, Judgement, Functional competence, Inter-personal competence, Expertise, Information, Overall abilityIntegrityFairness in transactions, fairness in data usage, fairness in service, Fairness, discreteness, integrity, loyalty, promise fulfilment, credibility, honesty, reliability, dependabilityBenevolenceReceptivity, Concern, Empathy, BenevolenceTerm frequency analysisOnly term frequency analysis and not term frequency-inverse document frequency (tf-idf) was performed because with ~29 million documents, the tf-idf outputs were uninterpretable. To calculate term frequency, the total number of times a word appeared was calculated, and then this value was divided by the total number of words under analysis. Words were then ranked from most frequent to least frequent. Lastly, the words from the manually tagged list (Table 1) were categorised according to the identified topics, namely, ability, integrity, and benevolence. The most frequent 20 terms overall were extracted and plotted. In addition, the manually tagged terms were also extracted and plotted.Sentiment analysisThe positive and negative sentiment, and the balance between the two, were assessed by extracting positive and negative words from the complete list of tokenised words. The Bing sentiment lexicon, which contains 4781 negative words and 2005 positive words, was used as the reference lexicon. Once the positive and negative words matching the Bing lexicon had been extracted, the frequency of each term was calculated, and the 10 most frequent terms were extracted and plotted.Topic modellingTokenised data were converted to a document-term matrix (DTM), and subjected to Latent Dirichlet Allocation (LDA) analysis using collapsed Gibbs sampling (seed = 2026, burn-in = 1000 iterations, total iterations = 3000). The number of topics was restricted to 20. Only an unsupervised LDA was performed, with no seeded terms. Once the LDA analyses had been

Figshare
Openalex Percentile: Top 5%
Digital Marketing and Social Media
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.

Laika access coming soon