Analysing Movie Rating By Critics & Audience as well as Movie Budget
Q <- read.csv("Movie-Ratings.csv")
head(Q)
## Film Genre Rotten.Tomatoes.Ratings..
## 1 (500) Days of Summer Comedy 87
## 2 10,000 B.C. Adventure 9
## 3 12 Rounds Action 30
## 4 127 Hours Adventure 93
## 5 17 Again Comedy 55
## 6 2012 Action 39
## Audience.Ratings.. Budget..million... Year.of.release
## 1 81 8 2009
## 2 44 105 2008
## 3 52 20 2009
## 4 84 18 2010
## 5 70 20 2009
## 6 63 200 2009
colnames(Q)
## [1] "Film" "Genre"
## [3] "Rotten.Tomatoes.Ratings.." "Audience.Ratings.."
## [5] "Budget..million..." "Year.of.release"
colnames(Q) <- c("Film","Genre","Critic_Ratings","Audience_Ratings","Budget","Year_Of_Release")
head(Q)
## Film Genre Critic_Ratings Audience_Ratings Budget
## 1 (500) Days of Summer Comedy 87 81 8
## 2 10,000 B.C. Adventure 9 44 105
## 3 12 Rounds Action 30 52 20
## 4 127 Hours Adventure 93 84 18
## 5 17 Again Comedy 55 70 20
## 6 2012 Action 39 63 200
## Year_Of_Release
## 1 2009
## 2 2008
## 3 2009
## 4 2010
## 5 2009
## 6 2009
library(ggplot2)
#-----> Asethetics
ggplot(Q,aes(x=Critic_Ratings,y=Audience_Ratings))

#-----> Geometry
ggplot(Q,aes(x=Critic_Ratings,y=Audience_Ratings))+geom_point()

#-------> Color
ggplot(Q,aes(x=Critic_Ratings,y=Audience_Ratings,colour=Genre))+geom_point()

#----> Size
ggplot(Q,aes(x=Critic_Ratings,y=Audience_Ratings,
colour=Genre,size=Budget))+geom_point()

p <- ggplot(Q,aes(x=Critic_Ratings,y=Audience_Ratings,
colour=Genre,size=Budget))
p+geom_point()

# ----> Line
p+geom_line()

#------> Multiple Layers
p+geom_point()+geom_line()

q <- ggplot(Q,aes(x=Critic_Ratings,y=Audience_Ratings,color=Genre,
size=Budget))
q + geom_point()

#--------> Overriding asethetics
q+ geom_point(aes(size=Critic_Ratings))

#------> Overriding colour
q+geom_point(aes(colour=Budget))

#-----> Overriding (X labs)
q+ geom_point(aes(x=Budget))+ xlab("Budget")

q+ geom_line()+geom_point()

#----> geom Line
q+ geom_line(size=1)+geom_point()

#------> Mapping
r <- ggplot(Q,aes(x=Critic_Ratings,y=Audience_Ratings))
r+geom_point(aes(colour=Genre))

r+geom_point(aes(size=Budget))

#Settings----> Do Not Use aes()
r+geom_point(colour="Green")

r+geom_point(size=10)

#-------> Histogram & Density Graph
s <- ggplot(Q,aes(x=Budget))
s+geom_histogram(binwidth = 10)

#------> Histogram fillings
s+geom_histogram(binwidth = 10,fill="Green")

#-----> fill in aes() along with border
s+geom_histogram(binwidth = 10,aes(fill=Genre),colour="Black")

#------> Density charts
s +geom_density(aes(fill= Genre))

s +geom_density(aes(fill= Genre),position="stack")

#-----> Histogram
t <- ggplot(Q,aes(x= Budget))
t+geom_histogram(binwidth = 10,fill="White",colour="Blue")

#------> geom_smooth()
u <- ggplot(Q,aes(x=Critic_Ratings,y=Audience_Ratings))
u+geom_point()

u+geom_point()+geom_smooth(fill=NA)
## `geom_smooth()` using method = 'loess'

geom_smooth()
## geom_smooth: na.rm = FALSE
## stat_smooth: na.rm = FALSE, method = auto, formula = y ~ x, se = TRUE
## position_identity
#------> geom_boxplot()
t <- ggplot(Q,aes(x=Genre,y=Audience_Ratings,colour=Genre))
t+geom_point()+ geom_boxplot(size=1,alpha=0.6) +geom_jitter()

#----->Facet
v <- ggplot(Q,aes(x=Budget))
v+geom_histogram(binwidth = 10,aes(fill= Genre),
colour="Black")+
facet_grid(Genre~.,scales = "free")

#------>More of Facet
y <- ggplot(Q,aes(x=Critic_Ratings,y=Audience_Ratings,
colour=Genre))
y+geom_point()

y+geom_point()+facet_grid(Genre~.)

y+geom_point()+geom_smooth()+facet_grid(Genre~Year_Of_Release)
## `geom_smooth()` using method = 'loess'
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : span too small. fewer data values than degrees of freedom.
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : at 75.99
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : radius 0.0001
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : all data on boundary of neighborhood. make span bigger
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : pseudoinverse used at 75.99
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : neighborhood radius 0.01
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : reciprocal condition number 1
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : at 78.01
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : radius 0.0001
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : all data on boundary of neighborhood. make span bigger
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : There are other near singularities as well. 0.0001
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : zero-width neighborhood. make span bigger
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : zero-width neighborhood. make span bigger
## Warning: Computation failed in `stat_smooth()`:
## NA/NaN/Inf in foreign function call (arg 5)
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : pseudoinverse used at 64
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : neighborhood radius 15
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : reciprocal condition number 0
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : Chernobyl! trL>n 6
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : Chernobyl! trL>n 6
## Warning in sqrt(sum.squares/one.delta): NaNs produced
## Warning in predLoess(object$y, object$x, newx = if
## (is.null(newdata)) object$x else if (is.data.frame(newdata))
## as.matrix(model.frame(delete.response(terms(object)), : pseudoinverse used
## at 64
## Warning in predLoess(object$y, object$x, newx = if
## (is.null(newdata)) object$x else if (is.data.frame(newdata))
## as.matrix(model.frame(delete.response(terms(object)), : neighborhood radius
## 15
## Warning in predLoess(object$y, object$x, newx = if
## (is.null(newdata)) object$x else if (is.data.frame(newdata))
## as.matrix(model.frame(delete.response(terms(object)), : reciprocal
## condition number 0
## Warning in stats::qt(level/2 + 0.5, pred$df): NaNs produced
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : span too small. fewer data values than degrees of freedom.
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : at 73.905
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : radius 0.009025
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : all data on boundary of neighborhood. make span bigger
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : pseudoinverse used at 73.905
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : neighborhood radius 0.095
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : reciprocal condition number 1
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : at 93.095
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : radius 0.009025
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : all data on boundary of neighborhood. make span bigger
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : There are other near singularities as well. 0.009025
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : zero-width neighborhood. make span bigger
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : zero-width neighborhood. make span bigger
## Warning: Computation failed in `stat_smooth()`:
## NA/NaN/Inf in foreign function call (arg 5)
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : span too small. fewer data values than degrees of freedom.
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : pseudoinverse used at 20.66
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : neighborhood radius 33.34
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : reciprocal condition number 0
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : There are other near singularities as well. 1248.9
## Warning in predLoess(object$y, object$x, newx = if
## (is.null(newdata)) object$x else if (is.data.frame(newdata))
## as.matrix(model.frame(delete.response(terms(object)), : span too small.
## fewer data values than degrees of freedom.
## Warning in predLoess(object$y, object$x, newx = if
## (is.null(newdata)) object$x else if (is.data.frame(newdata))
## as.matrix(model.frame(delete.response(terms(object)), : pseudoinverse used
## at 20.66
## Warning in predLoess(object$y, object$x, newx = if
## (is.null(newdata)) object$x else if (is.data.frame(newdata))
## as.matrix(model.frame(delete.response(terms(object)), : neighborhood radius
## 33.34
## Warning in predLoess(object$y, object$x, newx = if
## (is.null(newdata)) object$x else if (is.data.frame(newdata))
## as.matrix(model.frame(delete.response(terms(object)), : reciprocal
## condition number 0
## Warning in predLoess(object$y, object$x, newx = if
## (is.null(newdata)) object$x else if (is.data.frame(newdata))
## as.matrix(model.frame(delete.response(terms(object)), : There are other
## near singularities as well. 1248.9
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : span too small. fewer data values than degrees of freedom.
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : pseudoinverse used at 48.835
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : neighborhood radius 15.165
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : reciprocal condition number 0
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : There are other near singularities as well. 329.97
## Warning in predLoess(object$y, object$x, newx = if
## (is.null(newdata)) object$x else if (is.data.frame(newdata))
## as.matrix(model.frame(delete.response(terms(object)), : span too small.
## fewer data values than degrees of freedom.
## Warning in predLoess(object$y, object$x, newx = if
## (is.null(newdata)) object$x else if (is.data.frame(newdata))
## as.matrix(model.frame(delete.response(terms(object)), : pseudoinverse used
## at 48.835
## Warning in predLoess(object$y, object$x, newx = if
## (is.null(newdata)) object$x else if (is.data.frame(newdata))
## as.matrix(model.frame(delete.response(terms(object)), : neighborhood radius
## 15.165
## Warning in predLoess(object$y, object$x, newx = if
## (is.null(newdata)) object$x else if (is.data.frame(newdata))
## as.matrix(model.frame(delete.response(terms(object)), : reciprocal
## condition number 0
## Warning in predLoess(object$y, object$x, newx = if
## (is.null(newdata)) object$x else if (is.data.frame(newdata))
## as.matrix(model.frame(delete.response(terms(object)), : There are other
## near singularities as well. 329.97
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : span too small. fewer data values than degrees of freedom.
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : at 19.72
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : radius 0.0784
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : all data on boundary of neighborhood. make span bigger
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : pseudoinverse used at 19.72
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : neighborhood radius 0.28
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : reciprocal condition number 1
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : at 76.28
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : radius 0.0784
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : all data on boundary of neighborhood. make span bigger
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : There are other near singularities as well. 0.0784
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : zero-width neighborhood. make span bigger
## Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
## parametric, : zero-width neighborhood. make span bigger
## Warning: Computation failed in `stat_smooth()`:
## NA/NaN/Inf in foreign function call (arg 5)

#coordinates
z <- ggplot(Q,aes(x=Critic_Ratings,y=Audience_Ratings))
z+geom_point(aes(colour=Genre))

D <- ggplot(Q,aes(x=Budget))
D+geom_histogram(binwidth = 10,aes(fill=Genre),colour="Black")+xlim(0,100)
## Warning: Removed 66 rows containing non-finite values (stat_bin).

D+geom_histogram(binwidth = 10,aes(fill=Genre),
colour="Black")+coord_cartesian(xlim =c(0,100))

#------> theme
l <- ggplot(Q,aes(x=Budget))
p<- l+geom_histogram(binwidth = 10,aes(fill=Genre),colour="Black")
p+xlab("Money Axis")+ylab("NO.of Movies")+
ggtitle("Movies Distribution")+
theme(axis.text.x = element_text(colour="Blue"
,size=10),
axis.title.x=element_text(size=20),
axis.title.y=element_text(size=10),
legend.title=element_text(size=30),
legend.text =element_text(size=20),
legend.position = c(1,1),
legend.justification = c(1,1),
plot.title =element_text(colour = "Blue"))
