-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathR-Program for Tredning Youtube Video Statistics Notebook.Rmd
826 lines (316 loc) · 18.7 KB
/
R-Program for Tredning Youtube Video Statistics Notebook.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
---
title: "Youtube new Trending Statistics"
author: "Donyoe"
output:
html_document:
fig_height: 6
fig_width: 9
highlight: tango
theme: cosmo
toc: yes
code_folding: hide
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(
echo = TRUE,
message = FALSE,
warning = FALSE
)
```
![](https://www.seoclerk.com/pics/443105-1Cdpmj1460287445.png)
* **YouTube** is an American video-sharing website headquartered in San Bruno, California. The service was created by three former PayPal employees—Chad Hurley, Steve Chen, and Jawed Karim—in February 2005. Google bought the site in November 2006 for US$1.65 billion; YouTube now operates as one of Google's subsidiaries.
# Loading libraries
```{r}
set.seed(123)
# Data manipulation
library(data.table)
library(dplyr)
library(DT)
# Time manipulation
library(lubridate)
# Visualization
library(ggplot2)
library(plotrix)
library(corrplot)
library(ggdendro)
library(ggrepel)
# Wordcloud
library(wordcloud)
# Text manipulation
library(tidytext)
library(stringr)
library(tm)
library(sentimentr)
library(wordcloud)
library(RSentiment)
```
# Reading and preparing data
```{r}
gb <- tail(fread("../input/GBvideos.csv",encoding = "UTF-8"),20000)
gb[,"Location":="GB"]
fr <- tail(fread("../input/FRvideos.csv",encoding = "UTF-8"),20000)
fr[,"Location":="FR"]
ca <- tail(fread("../input/CAvideos.csv",encoding = "UTF-8"),20000)
ca[,"Location":="CA"]
us <- tail(fread("../input/USvideos.csv",encoding = "UTF-8"),20000)
us[,"Location":="US"]
de <- tail(fread("../input/DEvideos.csv",encoding = "UTF-8"),20000)
de[,"Location":="DE"]
videos <- as.data.table(rbind(gb,fr,ca,us,de))
videos$trending_date <- ydm(videos$trending_date)
videos$publish_time <- ymd(substr(videos$publish_time,start = 1,stop = 10))
videos$dif_days <- videos$trending_date-videos$publish_time
```
> First thing we are going to do is an analysis of the complete dataset, after that we will analyse every region
# First lets see the correlation
```{r}
corrplot.mixed(corr = cor(videos[,c("category_id","views","likes","dislikes","comment_count"),with=F]))
```
* We can see that between views and likes we have a high correlation, I thought that we will have a similar correlation between views and dislikes, but is almost half of the like correlation.
# Most...{.tabset .tabset-pills}
## Viewed videos
```{r}
mvideo <- videos[,.("Total_Views"=round(max(views,na.rm = T),digits = 2)),by=.(title,thumbnail_link)][order(-Total_Views)]
mvideo %>%
mutate(image = paste0('<img width="80%" height="80%" src="', thumbnail_link , '"></img>')) %>%
arrange(-Total_Views) %>%
top_n(10,wt = Total_Views) %>%
select(image, title, Total_Views) %>%
datatable(class = "nowrap hover row-border", escape = FALSE, options = list(dom = 't',scrollX = TRUE, autoWidth = TRUE))
```
## Liked videos (Absolute)
```{r}
mvideo <- videos[,.("Total_Likes"=round(max(likes,na.rm = T),digits = 2)),by=.(title,thumbnail_link)][order(-Total_Likes)]
mvideo %>%
mutate(image = paste0('<img width="80%" height="80%" src="', thumbnail_link , '"></img>')) %>%
arrange(-Total_Likes) %>%
top_n(10,wt = Total_Likes) %>%
select(image, title, Total_Likes) %>%
datatable(class = "nowrap hover row-border", escape = FALSE, options = list(dom = 't',scrollX = TRUE, autoWidth = TRUE))
```
## Disliked videos (Absolute)
```{r}
mvideo <- videos[,.("Total_Dislikes"=round(max(dislikes,na.rm = T),digits = 2)),by=.(title,thumbnail_link)][order(-Total_Dislikes)]
mvideo %>%
mutate(image = paste0('<img width="80%" height="80%" src="', thumbnail_link , '"></img>')) %>%
arrange(-Total_Dislikes) %>%
top_n(10,wt = Total_Dislikes) %>%
select(image, title, Total_Dislikes) %>%
datatable(class = "nowrap hover row-border", escape = FALSE, options = list(dom = 't',scrollX = TRUE, autoWidth = TRUE))
```
## Commented videos (Absolute)
```{r}
mvideo <- videos[,.("Total_comments"=round(max(comment_count,na.rm = T),digits = 2)),by=.(title,thumbnail_link)][order(-Total_comments)]
mvideo %>%
mutate(image = paste0('<img width="80%" height="80%" src="', thumbnail_link , '"></img>')) %>%
arrange(-Total_comments) %>%
top_n(10,wt = Total_comments) %>%
select(image, title, Total_comments) %>%
datatable(class = "nowrap hover row-border", escape = FALSE, options = list(dom = 't',scrollX = TRUE, autoWidth = TRUE))
```
# Top 10 in percentage{.tabset .tabset-pills}
* Because the absolute number of likes, dislikes and comments didnt show all the information to really know if the video had an impact or not we will see their percentages.
## % Liked videos
```{r}
mvideo <- videos[,.("Percentage_Likes"=round(100*max(likes,na.rm = T)/max(views,na.rm = T),digits = 2)),by=.(title,thumbnail_link)][order(-Percentage_Likes)]
mvideo %>%
mutate(image = paste0('<img width="80%" height="80%" src="', thumbnail_link , '"></img>')) %>%
arrange(-Percentage_Likes) %>%
top_n(10,wt = Percentage_Likes) %>%
select(image, title, Percentage_Likes) %>%
datatable(class = "nowrap hover row-border", escape = FALSE, options = list(dom = 't',scrollX = TRUE, autoWidth = TRUE))
```
## % Disliked videos
```{r}
mvideo <- videos[,.("Percentage_Dislikes"=round(100*max(dislikes,na.rm = T)/max(views,na.rm = T),digits = 2)),by=.(title,thumbnail_link)][order(-Percentage_Dislikes)]
mvideo %>%
mutate(image = paste0('<img width="80%" height="80%" src="', thumbnail_link , '"></img>')) %>%
arrange(-Percentage_Dislikes) %>%
top_n(10,wt = Percentage_Dislikes) %>%
select(image, title, Percentage_Dislikes) %>%
datatable(class = "nowrap hover row-border", escape = FALSE, options = list(dom = 't',scrollX = TRUE, autoWidth = TRUE))
```
## % Commented videos
```{r}
mvideo <- videos[,.("Percentage_comments"=round(100*max(comment_count,na.rm = T)/max(views,na.rm = T),digits = 2)),by=.(title,thumbnail_link)][order(-Percentage_comments)]
mvideo %>%
mutate(image = paste0('<img width="80%" height="80%" src="', thumbnail_link , '"></img>')) %>%
arrange(-Percentage_comments) %>%
top_n(10,wt = Percentage_comments) %>%
select(image, title, Percentage_comments) %>%
datatable(class = "nowrap hover row-border", escape = FALSE, options = list(dom = 't',scrollX = TRUE, autoWidth = TRUE))
```
* It looks that the French and German people comments more often than other nationalities
# Top trending Channels in all countries
```{r}
ggplot(videos[,.N,by=channel_title][order(-N)][1:10],aes(reorder(channel_title,-N),N,fill=channel_title))+geom_bar(stat="identity")+geom_label(aes(label=N))+guides(fill="none")+theme(axis.text.x = element_text(angle = 45,hjust = 1))+ labs(caption="Donyoe",title=" Top trending channel titles in all countries")+
xlab(NULL)+ylab(NULL)+coord_flip()
```
# Title Bigrams
```{r}
biga <- unnest_tokens(videos,bigram, title, token = "ngrams", n = 2)
biga <- as.data.table(biga)
ggplot(biga[,.N,by=bigram][order(-N)][1:19],aes(reorder(bigram,-N),N,fill=bigram))+geom_bar(stat="identity")+geom_label(aes(label=N))+guides(fill="none")+theme(axis.text.x = element_text(angle = 45,hjust = 1))+ labs(caption="Donyoe",title="Top Title bigrams")+xlab(NULL)+ylab(NULL)
```
* There are mainly bigrams relationed to *music*.
# Title wordcloud
```{r include=FALSE}
#Testing a bug
corpus = Corpus(VectorSource(list(sample(videos$title,size=2000))))
corpus = tm_map(corpus, removePunctuation)
corpus = tm_map(corpus, content_transformer(tolower))
corpus = tm_map(corpus, removeNumbers)
corpus = tm_map(corpus, stripWhitespace)
corpus = tm_map(corpus, removeWords, stopwords('english'))
dtm_eap = DocumentTermMatrix(VCorpus(VectorSource(corpus[[1]]$content)))
freq_eap <- colSums(as.matrix(dtm_eap))
sentiments_eap = calculate_sentiment(names(freq_eap))
sent_video = cbind(sentiments_eap, as.data.frame(freq_eap))
sent_video[contains(match = "uu",vars = sent_video$text),"freq_eap"] <- 0L
```
```{r}
wordcloud(sent_video$text,sent_video$freq, min.freq=5,colors=brewer.pal(6,"Dark2"),random.order = F)
```
* We can see that a lot of the trending videos are music videos.
# Top Category ID
```{r}
ggplot(videos[,.N,by=category_id][order(-N)],aes(reorder(category_id,-N),N,fill=as.factor(category_id)))+geom_bar(stat="identity")+guides(fill="none")+labs(caption="Donyoe",title=" Top Category ID")+
xlab(NULL)+ylab(NULL)
```
# How much time passes between published and trending?
```{r}
ggplot(videos[dif_days<30],aes(as.factor(dif_days),fill=as.factor(dif_days)))+geom_bar()+guides(fill="none")+labs(caption="Donyoe",title=" Time between published and trending",subtitle="In days")+xlab(NULL)+ylab(NULL)
```
* It seems that the videos never trend in the same day it is published.
# Tags wordcloud
```{r include=FALSE}
corpus = Corpus(VectorSource(list(sample(videos$tags,size=2000))))
corpus = tm_map(corpus, removePunctuation)
corpus = tm_map(corpus, content_transformer(tolower))
corpus = tm_map(corpus, removeNumbers)
corpus = tm_map(corpus, stripWhitespace)
corpus = tm_map(corpus, removeWords, stopwords('english'))
dtm_eap = DocumentTermMatrix(VCorpus(VectorSource(corpus[[1]]$content)))
freq_eap <- colSums(as.matrix(dtm_eap))
sentiments_eap = calculate_sentiment(names(freq_eap))
sent_video = cbind(sentiments_eap, as.data.frame(freq_eap))
sent_video[contains(match = "u067",vars = sent_video$text),"freq_eap"] <- 0L
sent_video[contains(match = "uuu",vars = sent_video$text),"freq_eap"] <- 0L
```
```{r}
wordcloud(sent_video$text,sent_video$freq, min.freq=10,colors=brewer.pal(6,"Dark2"),random.order = F)
```
* [none] is displayed if there are no tags, after none we can see tags as *new*, *iphone*, *episode* and tags related to *music*.
# Views Vs Likes
```{r}
ggplot(videos[,.("views"=max(views),"likes"=max(likes)),by=title],aes(views,likes,colour=likes,size=likes))+geom_jitter()+geom_smooth()+guides(fill="none")+labs(caption="Donyoe",title="Views Vs Likes",subtitle="In days")+theme(legend.position = "none")+geom_text_repel(data=subset(videos[,.("views"=max(views),"likes"=max(likes)),by=title], views > 5e+07),
aes(views,likes,label=title),check_overlap=T)
```
# Likes Vs Comment
```{r}
ggplot(videos[,.("comment_count"=max(comment_count),"likes"=max(likes)),by=title],aes(comment_count,likes,colour=likes,size=likes))+geom_jitter()+geom_smooth()+guides(fill="none")+labs(caption="Donyoe",title="Views Vs Comment",subtitle="In days")+
theme(legend.position = "none")+geom_text_repel(data=subset(videos[,.("comment_count"=max(comment_count),"likes"=max(likes)),by=title], likes > 1e+06),
aes(comment_count,likes,label=title),check_overlap=T)
```
# Sentiment Analysis Description field (Sample)
```{r include=FALSE}
corpus = Corpus(VectorSource(list(sample(videos$description,size=2000))))
corpus = tm_map(corpus, removePunctuation)
corpus = tm_map(corpus, content_transformer(tolower))
corpus = tm_map(corpus, removeNumbers)
corpus = tm_map(corpus, stripWhitespace)
corpus = tm_map(corpus, removeWords, stopwords('english'))
dtm_eap = DocumentTermMatrix(VCorpus(VectorSource(corpus[[1]]$content)))
freq_eap <- colSums(as.matrix(dtm_eap))
sentiments <- as.data.table(sentiments_eap)
sentiments1 <- sentiments[,.N,by=.(sentiment)]
sentiments1[,"Total":=sum(N)]
sentiments1 <- sentiments1[,.("Percentage"=100*N/Total),by=.(sentiment)]
```
```{r}
ggplot(sentiments1,aes(x = sentiment,y = Percentage ,fill=sentiment ))+
geom_bar(stat = "identity") +
ggtitle("Description Sentiments (Sample)")+xlab("Sentiment")+ylab("% Sentiment")+
theme(axis.text.x = element_text(angle = 45, size=8,hjust = 1))
```
* Here we can see that the sentiments in the description field are basically neutral.
# Sentimentr Analysis
```{r}
sents_eap <- sentiment(videos$description)
sents_eap <- sents_eap[,.("word_count"=sum(word_count),"sentiment"=sum(sentiment)),by=element_id]
ggplot(data=sents_eap)+
geom_histogram(mapping = aes(x=sentiment),binwidth = .1)+
theme_bw()+scale_fill_brewer(palette = "Set1")+
geom_vline(xintercept = 0, color = "coral", size = 1.5, alpha = 0.6, linetype = "longdash") +
labs(title="Description Score",caption="Donyoe")+coord_cartesian(xlim = c(-4, 4))
```
* We can see that the video description is clearly more posite than negative
# Description Bigrams
```{r}
biga <- unnest_tokens(videos,bigram, description, token = "ngrams", n = 2)
biga <- as.data.table(biga)
ggplot(biga[,.N,by=bigram][order(-N)][1:19],aes(reorder(bigram,-N),N,fill=bigram))+geom_bar(stat="identity")+geom_label(aes(label=N))+guides(fill="none")+theme(axis.text.x = element_text(angle = 45,hjust = 1))+ labs(caption="Donyoe",title="Top Description bigrams")+xlab(NULL)+ylab(NULL)
```
* Here in the description box we can see that they are mainly shortener links to other sites, the most used link shortener is *bit.ly* followed by *goog.gl*, after the shortener pages there are links to other *youtube* videos, link to sell in *amazon* and after that, links to their social media accounts in *twitter* and *facebook.*
# Cluster
```{r}
videos[,"Percentage_Likes":=round(100*(likes)/sum(as.numeric(views),na.rm = T),digits = 4)]
videos[,"Percentage_Disikes":=round(100*(dislikes)/sum(as.numeric(views),na.rm = T),digits = 4)]
videos[,"Percentage_comments":=round(100*(comment_count)/sum(as.numeric(views),na.rm = T),digits = 4)]
dista <- dist(x = videos)
cluster <- hclust(dista,method = "ward.D")
ggdendrogram(cluster,rotate = T)
clust_cut <- cutree(cluster,3)
videos <- videos[,"Cluster":=clust_cut]
c1 <- apply(videos[Cluster==1,.(views,likes,dislikes,comment_count,Percentage_Likes,Percentage_Disikes,Percentage_comments,as.numeric(dif_days))], 2, function(x) mean(x,na.rm=T))
c2 <- apply(videos[Cluster==2,.(views,likes,dislikes,comment_count,Percentage_Likes,Percentage_Disikes,Percentage_comments,as.numeric(dif_days))], 2, function(x) mean(x,na.rm=T))
c3 <- apply(videos[Cluster==3,.(views,likes,dislikes,comment_count,Percentage_Likes,Percentage_Disikes,Percentage_comments,as.numeric(dif_days))], 2, function(x) mean(x,na.rm=T))
clus <- as.data.table(rbind(c1,c2,c3))
knitr::kable(t(clus),digits=10)
```
* Cluster A : The second in reach the trending page , and medium in views, likes and dislikes.
* Cluster B : The cluster with most views with a significative difference, very liked, disliked and commented as in absolute as in relative units.
* Cluster C : This is a quite weird cluster, they reach the trending page the last with sifnificative difference, they have very little views, likes, dislikes and comments, and is the last in percentage of likes, dislikes and comments.
# Top Countries in Absolute numbers{.tabset .tabset-pills}
## In total number of views
```{r}
ggplot(videos[,.("Total_Views"=max(views)),by=Location],aes(reorder(Location,-Total_Views),Total_Views,fill=Location))+geom_bar(stat="identity")+geom_label(aes(label=Total_Views))+guides(fill="none")+theme(axis.text.x = element_text(angle = 45,hjust = 1))+ labs(caption="Donyoe",title=" Total Views by Countries")+xlab(NULL)+ylab(NULL)
```
* GB is the Country with most viewed videos in the trending field with significative difference with the other countries, almost doubled the second country.
## In total number of likes
```{r}
ggplot(videos[,.("Total_Likes"=max(likes)),by=Location],aes(reorder(Location,-Total_Likes),Total_Likes,fill=Location))+geom_bar(stat="identity")+geom_label(aes(label=Total_Likes))+guides(fill="none")+theme(axis.text.x = element_text(angle = 45,hjust = 1))+ labs(caption="Donyoe",title=" Total number of likes by Countries")+xlab(NULL)+ylab(NULL)
```
## In total number of dislikes
```{r}
ggplot(videos[,.("Total_Dislikes"=max(dislikes)),by=Location],aes(reorder(Location,-Total_Dislikes),Total_Dislikes,fill=Location))+geom_bar(stat="identity")+geom_label(aes(label=Total_Dislikes))+guides(fill="none")+theme(axis.text.x = element_text(angle = 45,hjust = 1))+ labs(caption="Donyoe",title=" Total Dislikes by Countries")+xlab(NULL)+ylab(NULL)
```
## In total number of comments
```{r}
ggplot(videos[,.("Total_Comments"=max(comment_count)),by=Location],aes(reorder(Location,-Total_Comments),Total_Comments,fill=Location))+geom_bar(stat="identity")+geom_label(aes(label=Total_Comments))+guides(fill="none")+theme(axis.text.x = element_text(angle = 45,hjust = 1))+ labs(caption="Donyoe",title=" Total Comments by Countries")+xlab(NULL)+ylab(NULL)
```
# Top Countries in % {.tabset .tabset-pills}
## In % of likes
```{r}
ggplot(videos[,.("MeanPercentage_Likes"=mean(Percentage_Likes,na.rm = T)),by=Location],aes(reorder(Location,-MeanPercentage_Likes),MeanPercentage_Likes,fill=Location))+geom_bar(stat="identity")+geom_label(aes(label=MeanPercentage_Likes))+guides(fill="none")+theme(axis.text.x = element_text(angle = 45,hjust = 1))+ labs(caption="Donyoe",title=" Mean Percentage of likes by Countries")+xlab(NULL)+ylab(NULL)
```
## In % of dislikes
```{r}
ggplot(videos[,.("MeanPercentage_Disikes"=mean(Percentage_Disikes,na.rm = T)),by=Location],aes(reorder(Location,-MeanPercentage_Disikes),MeanPercentage_Disikes,fill=Location))+geom_bar(stat="identity")+geom_label(aes(label=MeanPercentage_Disikes))+guides(fill="none")+theme(axis.text.x = element_text(angle = 45,hjust = 1))+ labs(caption="Donyoe",title=" Mean Percentage of dislikes by Countries")+xlab(NULL)+ylab(NULL)
```
## In % comments
```{r}
ggplot(videos[,.("MeanPercentage_Likes"=mean(Percentage_Likes,na.rm = T)),by=Location],aes(reorder(Location,-MeanPercentage_Likes),MeanPercentage_Likes,fill=Location))+geom_bar(stat="identity")+geom_label(aes(label=MeanPercentage_Likes))+guides(fill="none")+theme(axis.text.x = element_text(angle = 45,hjust = 1))+ labs(caption="Donyoe",title=" Mean Percentage of comments by Countries")+xlab(NULL)+ylab(NULL)
```
# Title length in words
```{r}
videos[,"Word_len":= str_length(title)]
ggplot(videos[,.N,keyby=Word_len],aes(Word_len,N,fill=N))+geom_bar(stat = "identity")+guides(fill="none")+labs(caption="Donyoe",title="Title length in words")+xlab(NULL)+ylab(NULL)
```
# How much time passes between published and trending by countries?
```{r}
ggplot(videos[dif_days<40],aes(as.factor(dif_days),fill=as.factor(dif_days)))+geom_bar()+guides(fill="none")+labs(caption="Donyoe",title=" Time between published and trending by countries",subtitle="In days")+xlab(NULL)+ylab(NULL)+facet_wrap(~Location)
```
* In DE and FR takes a little time to reach the trending page, 1 or 2 days usually. Similar case to CA, but here is higher the 2 day time difference, it takes a little longer to reach the trending page.
* In GB and US the time difference is clearly different, the videos takes in GB usually more than 2 days to reach the trending page, and in the US not seem to have videos that reach the trending page fast.
* Hope you like it!