library(ggplot2)
library(dplyr)
library(gridExtra)
library(zoo)
library(RColorBrewer)

Introduction

Data

df<-read.csv('TopGameCompanies_2012.csv',sep=',',header=TRUE)
colnames(df)<-c('image','rank','Company','Q1_2012','Q2_2012','Q3_2012','Q4_2012','YEAR_2012','CHANGE_2012')
df$CHANGE_2012<-as.numeric(gsub("[[:punct:]]","",as.character(df$CHANGE_2012)))

df0<-read.csv('TopGameCompanies_2013.csv',sep=',',header=TRUE)
colnames(df0)<-c('image','rank','Company','Q1_2013','Q2_2013','Q3_2013','Q4_2013','YEAR_2013','CHANGE_2013')
df0$CHANGE_2013<-as.numeric(gsub("[[:punct:]]","",as.character(df0$CHANGE_2013)))

df1<-read.csv('TopGameCompanies_2014.csv',sep=',',header=TRUE)
colnames(df1)<-c('image','rank','Company','Q1_2014','Q2_2014','Q3_2014','Q4_2014','YEAR_2014','CHANGE_2014')
df1$CHANGE_2014<-as.numeric(gsub("[[:punct:]]","",as.character(df1$CHANGE_2014)))

df2<-read.csv('TopGameCompanies_2015.csv',sep=',',header=TRUE)
colnames(df2)<-c('image','rank','Company','Q1_2015','Q2_2015','Q3_2015','Q4_2015','YEAR_2015','CHANGE_2015')
df2$CHANGE_2015<-as.numeric(gsub("[[:punct:]]","",as.character(df2$CHANGE_2015)))

df3<-read.csv('TopGameCompanies_2016.csv',sep=',',header=TRUE)
colnames(df3)<-c('image','rank','Company','Q1_2016','Q2_2016','Q3_2016','Q4_2016','YEAR_2016','CHANGE_2016')
df3$CHANGE_2016<-as.numeric(gsub("[[:punct:]]","",as.character(df3$CHANGE_2016)))

head(df1)
##                     image rank             Company Q1_2014 Q2_2014 Q3_2014
## 1             Tencent.jpg    1             Tencent    1673    1785    1824
## 2                Sony.jpg    2               Sony*    1392    1200    1046
## 3           microsoft.jpg    3          Microsoft*    1228     970    1017
## 4                  ea.jpg    4                  EA    1123    1214     990
## 5 Activision-Blizzard.jpg    5 Activision Blizzard    1111     970     753
## 6               Apple.jpg    6              Apple*     769     859     897
##   Q4_2014 YEAR_2014 CHANGE_2014
## 1    1928      7211          37
## 2    1484      5121           8
## 3    1428      4643           5
## 4    1126      4453          22
## 5    1575      4409           4
## 6     947      3472          46
head(df2)
##                     image rank             Company Q1_2015 Q2_2015 Q3_2015
## 1             Tencent.jpg    1             Tencent    2053    2000    2210
## 2           microsoft.jpg    2          Microsoft*    1416    1463    1517
## 3                Sony.jpg    3               Sony*    1341    1134    1435
## 4 Activision-Blizzard.jpg    4 Activision Blizzard    1278    1044     990
## 5               Apple.jpg    5              Apple*     993    1096    1150
## 6                  ea.jpg    6                  EA    1185    1203     815
##   Q4_2015 YEAR_2015 CHANGE_2015
## 1    2463      8725          21
## 2    2013      6409          38
## 3    1983      5892          15
## 4    1353      4665           6
## 5    1193      4432          28
## 6    1070      4273           4
str(df1)
## 'data.frame':    25 obs. of  9 variables:
##  $ image      : Factor w/ 25 levels "Activision-Blizzard.jpg",..: 23 20 14 7 1 2 9 12 18 24 ...
##  $ rank       : int  1 2 3 4 5 6 7 8 9 10 ...
##  $ Company    : Factor w/ 25 levels "Activision Blizzard",..: 23 20 14 7 1 2 9 12 18 24 ...
##  $ Q1_2014    : int  1673 1392 1228 1123 1111 769 516 607 361 235 ...
##  $ Q2_2014    : int  1785 1200 970 1214 970 859 556 594 333 437 ...
##  $ Q3_2014    : int  1824 1046 1017 990 753 897 629 514 430 151 ...
##  $ Q4_2014    : int  1928 1484 1428 1126 1575 947 661 546 969 983 ...
##  $ YEAR_2014  : int  7211 5121 4643 4453 4409 3472 2362 2260 2092 1806 ...
##  $ CHANGE_2014: num  37 8 5 22 4 46 71 20 13 33 ...
#merge datasets for years 2014, 2015, and 2016
merge1<-merge(df,df0,by="Company")
merge2<-merge(df1,df2,by="Company")
merge3<-merge(merge1,merge2,by='Company')
mergedData<-merge(df3,merge3,by='Company')

#select EA and Tencent companies
#selectedData<-filter(mergedData,Company=='EA' | Company=='Tencent') %>% #select(Company,Q1_2014,Q2_2014,Q3_2014,Q4_2014,Q1_2015,Q2_2015,Q3_2015,Q4_2015,Q1_2016,Q2_2016,Q3_2016,Q4_2016,YEAR_2014,YEAR_2015,YEAR_2016)
#selectedData<- mergedData %>% select(-c(rank,image,rank.x.x,image.x.x,rank.y.x,image.y.x,rank.x.y,image.x.y,rank.y.y,image.y.y))
selectedData<- mergedData %>% select(-c(CHANGE_2012,CHANGE_2013,CHANGE_2014,CHANGE_2015,CHANGE_2016,YEAR_2012,YEAR_2013,YEAR_2014,YEAR_2015,YEAR_2016,rank,image,rank.x.x,image.x.x,rank.y.x,image.y.x,rank.x.y,image.x.y,rank.y.y,image.y.y,Q3_2016,Q4_2016))

#transpose the dataset and rename column names
selectedDataT<-as.data.frame(t(selectedData))
names <- rownames(selectedDataT)
rownames(selectedDataT) <- NULL
summary <- cbind(names,selectedDataT)
companies<-selectedData$Company
t<-c("date")
t<-append(t,as.character(companies),1)
colnames(summary)<-t
summary<-summary[-c(1),]
#colnames(summary)<-c("date","EA","Tencent")
#summary<-summary[-c(1,14:15),]
#define a function to convert the quaterly data as Date format (a bit brute-force)
changeDate<-function(x){
    if(x=="Q1_2012") {return(as.Date("2012-02-01"))}
  else if (x=="Q2_2012") {return(as.Date("2012-05-01"))}
    else if (x=="Q3_2012") {return(as.Date("2012-08-01"))}
    else if (x=="Q4_2012") {return(as.Date("2012-11-01"))}
  else if (x=="Q1_2013") {return(as.Date("2013-02-01"))}
    else if (x=="Q2_2013") {return(as.Date("2013-05-01"))}
    else if (x=="Q3_2013") {return(as.Date("2013-08-01"))}
    else if (x=="Q4_2013") {return(as.Date("2013-11-01"))}
  else if (x=="Q1_2014") {return(as.Date("2014-02-01"))}
    else if (x=="Q2_2014") {return(as.Date("2014-05-01"))}
    else if (x=="Q3_2014") {return(as.Date("2014-08-01"))}
    else if (x=="Q4_2014") {return(as.Date("2014-11-01"))}
  else if (x=="Q1_2015") {return(as.Date("2015-02-01"))}
    else if (x=="Q2_2015") {return(as.Date("2015-05-01"))}
    else if (x=="Q3_2015") {return(as.Date("2015-08-01"))}
    else if (x=="Q4_2015") {return(as.Date("2015-11-01"))}
  else if (x=="Q1_2016") {return(as.Date("2016-02-01"))}
    else if (x=="Q2_2016") {return(as.Date("2016-05-01"))}
    else if (x=="Q3_2016") {return(as.Date("2016-08-01"))}
    else if (x=="Q4_2016") {return(as.Date("2016-11-01"))}
}
summary$newDate<-sapply(summary$date,changeDate)
summary$newDate<-as.Date(summary$newDate)
summary<-summary[,-1]
#summary$Tencent<-as.numeric(as.character(summary$Tencent))
#summary$EA<-as.numeric(as.character(summary$EA))

for(i in 2:ncol(summary)-1){
  summary[,i]<-as.numeric(as.character(summary[,i]))
}

colnames(summary)[1]<-"ActivisionBlizzard"
colnames(summary)[2]<-"Apple"
colnames(summary)[3]<-"BandaiNamco"
colnames(summary)[4]<-"DeNA"
colnames(summary)[9]<-"Microsoft"
colnames(summary)[14]<-"Squenix"
colnames(summary)[15]<-"TakeTwo"
print(summary)
##    ActivisionBlizzard Apple BandaiNamco DeNA Disney   EA Facebook Konami
## 2                1455  1254         484  236    230 1308      181    350
## 3                1570  1349         575  233    218 1271      197    224
## 4                1172   366         464  312    179 1368      186    473
## 5                1075   350         329  476    196  955      192    264
## 6                 841   390         398  506    191  711      176    345
## 7                1768   472         397  547    291  922      256    322
## 8                1324   522         440  450    194 1209      213    341
## 9                1050   565         321  429    183  949      214    191
## 10                691   603         354  383    396  695      218    235
## 11               1518   683         379  347    403  808      241    257
## 12               1111   769         357  287    268 1123      237    273
## 13                970   859         336  238    266 1214      234    171
## 14                753   897         288  225    362  990      246    202
## 15               1575   947         323  237    384 1126      257    195
## 16               1278   993         461  248    235 1185      226    241
## 17               1044  1096         426  235    208 1203      215    198
## 18                990  1150         334  229    347  815      202    232
## 19               1353  1193         446  227    390 1070      204    346
##    Microsoft NetEase Nexon Nintendo Sega Squenix TakeTwo Tencent Ubisoft
## 2       1595     933   512      393  249     435     378    2646     696
## 3       1427     969   339      325  202     334     312    2652     155
## 4        809     289   351      498  201     210     148     851     212
## 5        890     316   264      491  136     131     226     890     173
## 6        973     325   281      613  180     225     273     927     196
## 7       1885     317   357     1172  224     312     416     958    1059
## 8       1583     326   423      385  195     302     300    1225     241
## 9       1039     337   349      439  151     110     143    1253     105
## 10       989     344   380      555  172     182     148    1390     300
## 11      1265     427   328     1013  218     247    1864    1398     717
## 12      1228     347   397      361  186     318     195    1673     235
## 13       970     377   308      333  166     196     125    1785     437
## 14      1017     401   381      430  199     170     126    1824     151
## 15      1428     462   359      969  272     265     531    1928     983
## 16      1416     501   432      400  219     303     300    2053     185
## 17      1463     621   355      377  169     252     275    2000     105
## 18      1517     820   414      458  167     248     347    2210     121
## 19      2013     849   381      706  231     415     414    2463     612
##       newDate
## 2  2016-02-01
## 3  2016-05-01
## 4  2012-02-01
## 5  2012-05-01
## 6  2012-08-01
## 7  2012-11-01
## 8  2013-02-01
## 9  2013-05-01
## 10 2013-08-01
## 11 2013-11-01
## 12 2014-02-01
## 13 2014-05-01
## 14 2014-08-01
## 15 2014-11-01
## 16 2015-02-01
## 17 2015-05-01
## 18 2015-08-01
## 19 2015-11-01
str(summary)
## 'data.frame':    18 obs. of  18 variables:
##  $ ActivisionBlizzard: num  1455 1570 1172 1075 841 ...
##  $ Apple             : num  1254 1349 366 350 390 ...
##  $ BandaiNamco       : num  484 575 464 329 398 397 440 321 354 379 ...
##  $ DeNA              : num  236 233 312 476 506 547 450 429 383 347 ...
##  $ Disney            : num  230 218 179 196 191 291 194 183 396 403 ...
##  $ EA                : num  1308 1271 1368 955 711 ...
##  $ Facebook          : num  181 197 186 192 176 256 213 214 218 241 ...
##  $ Konami            : num  350 224 473 264 345 322 341 191 235 257 ...
##  $ Microsoft         : num  1595 1427 809 890 973 ...
##  $ NetEase           : num  933 969 289 316 325 317 326 337 344 427 ...
##  $ Nexon             : num  512 339 351 264 281 357 423 349 380 328 ...
##  $ Nintendo          : num  393 325 498 491 613 ...
##  $ Sega              : num  249 202 201 136 180 224 195 151 172 218 ...
##  $ Squenix           : num  435 334 210 131 225 312 302 110 182 247 ...
##  $ TakeTwo           : num  378 312 148 226 273 ...
##  $ Tencent           : num  2646 2652 851 890 927 ...
##  $ Ubisoft           : num  696 155 212 173 196 ...
##  $ newDate           : Date, format: "2016-02-01" "2016-05-01" ...
colnames(summary)
##  [1] "ActivisionBlizzard" "Apple"              "BandaiNamco"       
##  [4] "DeNA"               "Disney"             "EA"                
##  [7] "Facebook"           "Konami"             "Microsoft"         
## [10] "NetEase"            "Nexon"              "Nintendo"          
## [13] "Sega"               "Squenix"            "TakeTwo"           
## [16] "Tencent"            "Ubisoft"            "newDate"

Plots

#v<-colnames(summary)
#v<-v[-length(v)]
#print(v)
#colourCount = length(unique(v))
#getPalette = colorRampPalette(brewer.pal(9, "Set1"))

g1<-ggplot(data=summary,aes(newDate))+geom_point(aes(y=EA,color="EA"),size=4)+geom_point(aes(y=Tencent,color="Tencent"),size=4)+ labs(colour='Companies') + xlab("Date") + ylab("Revenues (M $US)") + theme(legend.position='top') +ylim(0,3000)
print(g1)

g11<-ggplot(data=summary,aes(newDate))+
geom_point(aes(y=EA,color="EA"),size=2)+geom_point(aes(y=Microsoft,color="Microsoft"),size=2)+
geom_point(aes(y=Tencent,color="Tencent"),size=2)+geom_point(aes(y=Konami,color="Konami"),size=2)+
geom_point(aes(y=Squenix,color="Squenix"),size=2)+geom_point(aes(y=TakeTwo,color="TakeTwo"),size=2)+
geom_point(aes(y=NetEase,color="NetEase"),size=2)+geom_point(aes(y=Nexon,color="Nexon"),size=2)+
geom_point(aes(y=DeNA,color="DeNA"),size=2)+geom_point(aes(y=Nintendo,color="Nintendo"),size=2)+
geom_point(aes(y=Disney,color="Disney"),size=2)+geom_point(aes(y=Sega,color="Sega"),size=2)+
geom_point(aes(y=Facebook,color="Facebook"),size=2)+geom_point(aes(y=Ubisoft,color="Ubisoft"),size=2)+
geom_point(aes(y=Apple,color="Apple"),size=2)+geom_point(aes(y=BandaiNamco,color="BandaiNamco"),size=2)+
geom_point(aes(y=ActivisionBlizzard,color="ActivisionBlizzard"),size=2)+
labs(colour='Companies') + xlab("Date") + ylab("Revenues (M $US)") + theme(legend.position='top') +ylim(0,3000)
print(g11)

g2<-ggplot(data=summary,aes(x=newDate,y=Tencent))+ geom_point(size=4) + labs(colour='Companies') + xlab("Date") + ylab("Revenues (M $US)") + theme(legend.position='top') +ylim(0,3000) +geom_smooth(method="lm")

g3<-ggplot(data=summary,aes(x=newDate,y=EA))+ geom_point(size=4) + labs(colour='Companies') + xlab("Date") + ylab("Revenues (M $US)") + theme(legend.position='top') +ylim(0,3000) +geom_smooth(method="lm")
grid.arrange(g2,g3,ncol=2)


Acknoledgment Data available for free use from NEWZOO


History :