Created
September 14, 2016 17:39
-
-
Save dirtyhenry/5c0cdb46c383e5911d7d0ee548e2df68 to your computer and use it in GitHub Desktop.
R Script to get a plot of weekly/monthly downloads aggregations from App Annie files.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# appannie_histogram.R | |
# | |
# Create weekly and monthly aggregations bar plots of your downloads | |
# from AppAnnie CSV files. | |
# | |
# Improvements: | |
# | |
# * First and last week of years can have much less than 7 days and create false | |
# decreases of downloads. | |
# * The design of the graph could be improved a lot. Exporting the aggregation | |
# and letting D3.js take over for the bar plot could be a good idea. | |
# | |
# Created by Mickaël Floc'hlay, from Bootstragram (bootstragram.com) | |
# Get in touch via @dirtyhenry or @bootstragram. | |
# | |
appannie_dataset = read.csv("appannie-data.csv") | |
# Reformat Date from String to Date | |
appannie_dataset$Date = as.Date(appannie_dataset$Date, "%m/%d/%Y") | |
summary(appannie_dataset) | |
# Add date information | |
appannie_dataset$Week = format(appannie_dataset$Date, format = "%W") | |
appannie_dataset$Month = format(appannie_dataset$Date, format = "%m") | |
appannie_dataset$Year = format(appannie_dataset$Date, format = "%Y") | |
appannie_dataset$YearWeek = paste(appannie_dataset$Year, appannie_dataset$Week, sep='') | |
appannie_dataset$YearMonth = paste(appannie_dataset$Year, appannie_dataset$Month, sep='') | |
# Group downloads by month | |
by_month <- aggregate(Downloads ~ YearMonth, appannie_dataset, FUN = sum) | |
# I'm no expert in creating plots with R so I got inspired by: | |
# http://flowingdata.com/2016/03/22/comparing-ggplot2-and-r-base-graphics/ | |
par(las=1) | |
barplot(by_month$Downloads, | |
names.arg=by_month$YearMonth, | |
col="#AFC0CB", | |
border=FALSE, | |
main="Monthly Downloads") | |
# Group downloads by weeks | |
by_week <- aggregate(Downloads ~ YearWeek, appannie_dataset, FUN = sum) | |
barplot(by_week$Downloads, | |
names.arg=by_week$YearWeek, | |
col="#AFC0CB", | |
border=FALSE, | |
main="Weekly Downloads") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment