1library(dplyr)
2library(plyr)
3library(tidyverse)
4library(ggplot2)
5library(readxl)
6library(xlsx)
7library(RColorBrewer)
8
9movie_data "D:\\partner111.xlsx")
10
11left_data 0, ]
12attach(left_data)
13ave_rate "mean")
14ave_rate$rate 1)
15detach(left_data)
16ave_rate 17col 9,'Blues')
18pbbPalette "#FFCCCC","#FF9999","#FF6666","#FF3333","#FF0000","#CC0000","#990033","#990000","#660000","#330000")
19cbbPalette "#000000", "#E69F00", "#56B4E9", "#009E73", "#F0E442", "#0072B2", "#D55E00", "#CC79A7", "#FF0033", "#339999")
20ggplot(data = head(ave_rate,10), aes(x = reorder(Group.1,rate,median), y = rate)) + ylim(0,10) + geom_bar(stat="identity",fill=pbbPalette) +
21 labs(title = "rating of moives", x="合作演员", y="平均评分")
22ggplot(data = tail(ave_rate,10), aes(x = reorder(Group.1,rate,median), y = rate)) + ylim(0,10) + geom_bar(stat="identity",fill=pbbPalette) +
23 labs(title = "rating of moives", x="合作演员", y="平均评分")
24
25
26attach(left_data)
27dir_rate "mean")
28dir_rate$rate 1)
29detach(left_data)
30dir_rate 31ggplot(data = head(dir_rate,15), aes(x = reorder(Group.1,x,median), y = x)) + ylim(0,10) + geom_bar(stat="identity",fill='steelblue') +
32 labs(title = "rating of director", x="导演", y="平均评分") +
33 theme(axis.text.x = element_text(size = 8, family = "myFont", face = "bold", vjust = 0.5, hjust = 0.5, angle = 45)) +
34 geom_text(aes(label = rate, vjust = -0.8, hjust = 0.5), show.legend = TRUE)
35ggplot(data = tail(dir_rate,15), aes(x = reorder(Group.1,x,median), y = x)) + ylim(0,10) + geom_bar(stat="identity",fill='steelblue') +
36 labs(title = "rating of director", x
="导演", y="平均评分") +
37 theme(axis.text.x = element_text(size = 8, family = "myFont", face = "bold", vjust = 0.5, hjust = 0.5, angle = 45)) +
38 geom_text(aes(label = rate, vjust = -0.8, hjust = 0.5), show.legend = TRUE)
39
40
41attach(left_data)
42dir_time % select(movie_name,director)
43dir_time 44dir_table 45detach(left_data)
46dir_table 47ggplot(data = dir_table[dir_table$freq>=2,], aes(x = reorder(x,freq,median), y = freq)) + geom_bar(stat="identity",fill='steelblue') +
48 labs(title = "times of director", x="导演", y="合作次数") +
49 theme(axis.text.x = element_text(size = 8, family = "myFont", face = "bold", vjust = 0.5, hjust = 0.5, angle = 45)) +
50 geom_text(aes(label = freq, vjust = -0.8, hjust = 0
.5), show.legend = TRUE)
51
52
53attach(left_data)
54top_movie "mean")
55detach(left_data)
56rank_moive 57ggplot(data = tail(rank_moive,10), aes(x = reorder(Group.1,x,median), y = x)) + ylim(0,10) + geom_bar(stat="identity",fill=pbbPalette) +
58 labs(title = "top10 moives", x="电影", y="评分") +
59 theme(axis.text.x = element_text(size = 8, family = "myFont", face = "bold",vjust = 0.7, hjust = 0.7, angle = 45))
60
61
62jiong "人在囧途","人再囧途之泰囧","港囧"),]
63jiong$collection 64cbbPalette "#E69F00", "#56B4E9", "#009E73")
65ggplot(data = jiong, aes(x = movie_name, y = collection)) + geom_boxplot(fill=cbbPalette) +
66 labs(title = "collection in the movie of jiong IP", x="演员", y="人气")
67
68
69attach(left_data)
70agg_data % select(movie_name,types,rating)
71agg_data 72View(agg_data)
73detach(left_data)
74li = list("喜剧","真人秀","爱情","剧情","悬疑","脱口秀","犯罪","动作","惊悚","古装","奇幻","动画")
75type = c()
76ave_rating =c()
77for (i in li){
78 type_moive 79 ave = mean(as.double(type_moive$rating))
80 type = c(type, i)
81 ave_rating = c(ave_rating, ave)
82}
83type_rating 84pbbPalette "#FFCCCC","#FF9999","#FF6666","#FF3333","#FF0033","#FF0000","#CC3333","#CC0000","#990033","#990000","#660000","#330000")
85ggplot(data = type_rating, aes(x = reorder(type,ave_rating,median), y = ave_rating)) + ylim(0,10) + geom_bar(stat="identity",fill=pbbPalette) +
86 labs(title = "rating of types", x="类型", y=
"平均评分") +
87 theme(axis.text.x = element_text(size = 8, family = "myFont", face = "bold", vjust = 0.5, hjust = 0.5, angle = 45)) +
88 geom_text(aes(label = round(ave_rating,1), vjust = -0.8, hjust = 0.5, color = 'red'), show.legend = TRUE)
89
90
91library(igraph)
92
93attach(movie_data)
94agg_data % select(par_name, time)
95detach(movie_data)
96agg_data 97nrow(agg_data)
98centre "徐峥",time=148)
99graph_data 100write.xlsx(graph_data,"D:\\mydata.xlsx")
101all_data "D:\\mydata.xlsx")
102g 103
104
105jpeg(filename='D:\\GRAPH1.jpg',width=800,height=800,units='px')
106plot(g,
107 vertex.size=2,
108 layout=layout.kamada.kawai,
109 vertex.shape='none',
110 vertex.label.cex=1,
111 vertex.label.color="#CC79A7",
112 edge.arrow.size=0.2)
113
114dev.off()
115
116
117
118library(RColorBrewer)
119col 9,'Blues')
120V(g)$label.color "#FF0033"
121attach(all_data)
122all_data time),]
123n3 time>6,])
124n2 time>=3&time<=6,])
125n1 time<3,])
126detach(all_data)
127edge_col 3],n1),rep(col[6],n2),rep(col[9],n3))
128V(g)$size=degree(g)/12
129jpeg(filename='D:\\GRAPH2.jpg',width=1000,height=1000,units='px')
130plot(g, layout = layout.fruchterman.reingold,vertex.label.cex=1,edge.color=edge_col,edge.arrow.mode='-')
131dev.off()