Tallying Data and Creating Pie Charts
setwd("/Users/Greg/Documents/Grad School/LAIS 609C/Assignment 1")
load("friends.RData")
t = table(friends$Friends);t
##
## No difference Opposite sex Same sex
## 602 434 164
prop = prop.table(t);prop
##
## No difference Opposite sex Same sex
## 0.5016667 0.3616667 0.1366667
percent=prop.table(t)*100;percent
##
## No difference Opposite sex Same sex
## 50.16667 36.16667 13.66667
pie(t)

pf = round(percent,1);pf
##
## No difference Opposite sex Same sex
## 50.2 36.2 13.7
lbl = paste(c("No difference","Opposite sex","Same sex"),pf,"%",sep="");lbl
## [1] "No difference50.2%" "Opposite sex36.2%" "Same sex13.7%"
pie(t,label=lbl)
Creating and Describing Histograms
load("actor_2013.RData")
hist(actor_age$Age)

hist(actor_age$Age, xlab="Age of Best Actor Oscar Winners (1970-2013)", main="")

hist(actor_age$Age, xlab="Age of Best Actor Oscar Winners (1970-2013)", ylab="Number of Actors", main="Best Actor Oscar Winners Ages")

hist(actor_age$Age, breaks=8, xlab="Age of Best Actor Oscar Winners (1970-2013)", main="")
Interpreting the Five Number Summary
summary(actor_age$Age)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 29.00 38.00 43.50 44.98 50.25 76.00
mean(actor_age$Age)
## [1] 44.97727
sd(actor_age$Age)
## [1] 9.749153
var(actor_age$Age)
## [1] 95.04598
median(actor_age$Age)
## [1] 43.5
IQR(actor_age$Age)
## [1] 12.25
min(actor_age$Age)
## [1] 29
max(actor_age$Age)
## [1] 76
length(actor_age$Age)
## [1] 44
quantile(actor_age$Age, 0.25)
## 25%
## 38
quantile(actor_age$Age, 0.75)
## 75%
## 50.25
Creating Side-by-Side Boxplots
load("graduation.RData")
grad_data
## College.A College.B College.C College.D College.E College.F
## 1 57.6 70.1 54.5 80.1 71.3 68.8
## 2 43.2 69.6 55.6 77.3 62.6 61.0
## 3 49.6 67.3 56.9 74.7 54.5 57.7
## 4 51.4 76.7 71.0 79.2 57.5 66.4
## 5 69.9 69.4 73.3 84.6 55.0 75.2
## 6 69.9 72.6 74.8 78.8 67.0 87.4
## 7 73.8 70.2 68.3 84.1 60.0 86.0
## 8 72.3 74.4 67.0 74.1 58.3 79.7
summary(grad_data)
## College.A College.B College.C College.D
## Min. :43.20 Min. :67.30 Min. :54.50 Min. :74.10
## 1st Qu.:50.95 1st Qu.:69.55 1st Qu.:56.58 1st Qu.:76.65
## Median :63.75 Median :70.15 Median :67.65 Median :79.00
## Mean :60.96 Mean :71.29 Mean :65.17 Mean :79.11
## 3rd Qu.:70.50 3rd Qu.:73.05 3rd Qu.:71.58 3rd Qu.:81.10
## Max. :73.80 Max. :76.70 Max. :74.80 Max. :84.60
## College.E College.F
## Min. :54.50 Min. :57.70
## 1st Qu.:56.88 1st Qu.:65.05
## Median :59.15 Median :72.00
## Mean :60.77 Mean :72.78
## 3rd Qu.:63.70 3rd Qu.:81.28
## Max. :71.30 Max. :87.40
boxplot(grad_data)

boxplot(grad_data, xlab="Colleges",ylab ="Graduation Rates", main="Comparison of Graduation Rates")

boxplot(grad_data, horizontal=TRUE, ylab="Colleges",xlab ="Graduation Rates", main="Comparison of Graduation Rates")
Calculating the Standard Deviation
load("sdintuition.RData")
sapply(ratings, sd)
## Class.I Class.II Class.III
## 1.568929 4.000000 2.631174