movie$Year<-factor(movie$Year)
head(movie)
summary(movie)
library(ggplot2)
r<- ggplot(data=movie,
aes(x=CriRating,y=AudRatining,color=Genre))
r
r + geom_point()
r + geom_point()+ geom_smooth()
r + geom_point()+ geom_smooth(fill=NA)
#boxplot
r<- ggplot(data=movie,
aes(x=Genre,y=AudRatining,color=Genre))
r + geom_boxplot()
r + geom_boxplot(size = 1.2)
r + geom_boxplot(size = 1.2) +
geom_point()
r + geom_boxplot(size = 1.2) +
geom_jitter()
#facets
r<- ggplot(data=movie,
aes(x=BMill))
r +geom_histogram(binwidth = 10,
aes(fill=Genre),
color="Black")
r +geom_histogram(binwidth = 10,
aes(fill=Genre),
color="Black")+
facet_grid(Genre~.)
r +geom_histogram(binwidth = 10,
aes(fill=Genre),
color="Black")+
facet_grid(Genre~.,scale="free")
###
z<- ggplot(data=movie,
aes(x=CriRating,y=AudRatining,color=Genre))
------------------------------------------
#Dear Student,
#
#Welcome to the world of Basketball Data!
#I'm sure you will enjoy this section of the R Programming course.
#
#Instructions for this dataset:
# Simply select ALL the lines in this script by pressing
# CTRL+A on Windows or CMND+A on a Mac and execute them
# Once you have executed the commands the following objects
# will be created:
# Matrices:
# - FieldGoalAttempts
# - FieldGoals
# - Games
# - MinutesPlayed
# - Salary
# Vectors:
# - Players
# - Seasons
#We will go understand these inside the course.
#
#Sincerely,
#Kirill Eremenko
#www.superdatascience.com
#Copyright: These datasets were prepared using publicly available data.
# However, theses scripts are subject to Copyright Laws.
# If you wish to use these R scripts outside of the R Programming Course
# by Kirill Eremenko, you may do so by referencing www.superdatascience.com in your work.
#Comments:
#Seasons are labeled based on the first year in the season
#E.g. the 2012-2013 season is preseneted as simply 2012
#Notes and Corrections to the data:
#Kevin Durant: 2006 - College Data Used
#Kevin Durant: 2005 - Proxied With 2006 Data
#Derrick Rose: 2012 - Did Not Play
#Derrick Rose: 2007 - College Data Used
#Derrick Rose: 2006 - Proxied With 2007 Data
#Derrick Rose: 2005 - Proxied With 2007 Data
-------------------------------------------
#Dear Student,
#
#Welcome to the world of Basketball Data!
#I'm sure you will enjoy this section of the R Programming course.
#
#Instructions for this dataset:
# Simply select ALL the lines in this script by pressing
# CTRL+A on Windows or CMND+A on a Mac and execute them
# Once you have executed the commands the following objects
# will be created:
# Matrices:
# - FieldGoalAttempts
# - FieldGoals
# - Games
# - MinutesPlayed
# - Salary
# Vectors:
# - Players
# - Seasons
#We will go understand these inside the course.
#
#Sincerely,
#Kirill Eremenko
#www.superdatascience.com
#Copyright: These datasets were prepared using publicly available data.
# However, theses scripts are subject to Copyright Laws.
# If you wish to use these R scripts outside of the R Programming Course
# by Kirill Eremenko, you may do so by referencing www.superdatascience.com in your work.
#Comments:
#Seasons are labeled based on the first year in the season
#E.g. the 2012-2013 season is preseneted as simply 2012
#Notes and Corrections to the data:
#Kevin Durant: 2006 - College Data Used
#Kevin Durant: 2005 - Proxied With 2006 Data
#Derrick Rose: 2012 - Did Not Play
#Derrick Rose: 2007 - College Data Used
#Derrick Rose: 2006 - Proxied With 2007 Data
#Derrick Rose: 2005 - Proxied With 2007 Data
------------------------------
a<- 1:4
a
a[3]
?names(a)
names(a)<-c('my',"r","vlr","s")
names(a)
a
a[3]
a["vlr"]
a
names(a)<- NULL
a
b<-1:12
b
bm<-matrix(b,3,4)
bm
cn<-rep(c("ramesh","vlr","training"),each=4)
mc<-matrix(cn,3,4)
mc
names(mc)<- NULL
rownames(mc)<-c("a","b","c")
colnames(mc)<-c("d","e","f","g")
mc
rownames(mc)<- NULL
colnames(mc)<- NULL
mc
rownames(mc)<-c("a","b","c")
mc["c","g"]
#Dear Student,
#
#Welcome to the world of Basketball Data!
#I'm sure you will enjoy this section of the R Programming course.
#
#Instructions for this dataset:
# Simply select ALL the lines in this script by pressing
# CTRL+A on Windows or CMND+A on a Mac and execute them
# Once you have executed the commands the following objects
# will be created:
# Matrices:
# - FieldGoalAttempts
# - FieldGoals
# - Games
# - MinutesPlayed
# - Salary
# Vectors:
# - Players
# - Seasons
#We will go understand these inside the course.
#
#Sincerely,
#Kirill Eremenko
#www.superdatascience.com
#Copyright: These datasets were prepared using publicly available data.
# However, theses scripts are subject to Copyright Laws.
# If you wish to use these R scripts outside of the R Programming Course
# by Kirill Eremenko, you may do so by referencing www.superdatascience.com in your work.
#Comments:
#Seasons are labeled based on the first year in the season
#E.g. the 2012-2013 season is preseneted as simply 2012
#Notes and Corrections to the data:
#Kevin Durant: 2006 - College Data Used
#Kevin Durant: 2005 - Proxied With 2006 Data
#Derrick Rose: 2012 - Did Not Play
#Derrick Rose: 2007 - College Data Used
#Derrick Rose: 2006 - Proxied With 2007 Data
#Derrick Rose: 2005 - Proxied With 2007 Data
# profit after tax for each month (the tax rate is 30%)
tax<-profit*0.3
tax
pat<-profit-tax
pat
# profit margin for each month - equals to profit a after tax divided by revenue
pmem<-round(pat/revenue,2)*100
?round
#pmem1<-round(pmem,2)
pmem
# good months - where the profit after tax was greater than the mean for the year
x<-mean(pat)
x
goodmonths<- pat>x
goodmonths
#bad months - where the profit after tax was less than the mean for the year
badmonths<- pat<x
badmonths
# the best month - where the profit after tax was max for the year
bestmonth<-pat==max(pat)
bestmonth
pat
# the worst month - where the profit after tax was min for the year
worstmonth<-pat==min(pat)
worstmonth
############
revenue1<-(round(revenue/1000,0))
expenses1<-(round(expenses/1000,0))
profit1<-(round(profit/1000,0))
pat1<-(round(pat/1000,0))
revenue1
expenses1
profit1
pat1
pmem
goodmonths
badmonths
bestmonth
worstmonth
m<-rbind(
revenue1,
expenses1,
profit1,
pat1,
pmem,
goodmonths,
badmonths,
bestmonth,
worstmonth
)
m