Skip to content

Instantly share code, notes, and snippets.

@ryanbateman
Created January 20, 2022 09:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanbateman/2fdcff5f9bdd13b26edd1fbc3647ff9f to your computer and use it in GitHub Desktop.
Save ryanbateman/2fdcff5f9bdd13b26edd1fbc3647ff9f to your computer and use it in GitHub Desktop.
R script for visualising play store review keywords over time
library(jsonlite)
library(dplyr)
require(ggplot2)
library(data.table)
library(lubridate)
library(dplyr)
library(tidyr)
library(reshape2)
library(data.table)
result <- read_json("reviews.txt")
df <- rbindlist(result)
df$at <- as.Date(df$at)
df %>%
group_by(at = lubridate::floor_date(at, "month")) %>%
filter (at > as.Date("2018-01-01") && at < as.Date("2022-01-01")) %>%
summarise(
voice_requests = sum(grepl("voice", content)),
bookmark_requests = sum(grepl("bookmark", content)),
sync_requests = sum(grepl("sync", content))) %>%
melt(id.vars=c("at")) %>%
ggplot() +
geom_line(aes(x = at, y = value, color = variable)) +
scale_color_manual(name = "Keyword", values = c("red", "green", "blue"), labels = c("\"voice\"", "\"bookmark\"", "\"sync\"")) +
ylab("Number of times word is featured in a review per month") +
xlab("Time") +
labs(color = "Keyword") +
theme(
panel.grid.major.x = element_line(size = 0.2, colour = "lightgray"),
panel.grid.major.y = element_line(size = 0.2, colour = "lightgray"),
panel.grid.minor.y = element_line(size = 0.2, colour = "lightgray"),
panel.background = element_rect(
fill = "white", colour = "grey50"),
legend.position="bottom",
plot.margin = unit(c(0.5, 1, 0.5, 0.5), "cm")
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment