setwd("C:/Users/Brett/Desktop/APCS")
#library(googleVis)
#library(dplyr)
suppressPackageStartupMessages(library(googleVis))
suppressPackageStartupMessages(library(dplyr))
suppressPackageStartupMessages(library(knitr))
opts_chunk$set(warning=FALSE, message=FALSE)
op <- options(gvis.plot.tag='chart')
#Sys.getlocale
#Sys.setlocale(category="LC_ALL", locale="English_United States.1252")
#
# Sys.getlocale(category="LC_ALL")
discrepancyhispanics=read.csv("3c.csv")
discrepancyfemales=read.csv("3a.csv")
discrepancyblacks=read.csv("3b.csv")
femalepassrate=read.csv("femalepassrate.csv")
blackpassrate=read.csv("blackpassrate.csv")
hispanicpassrate=read.csv("hispanicpassrate.csv")
fembh=read.csv("totalfembh.csv")
#Question 1
#Percent of Females taking AP Test
names(fembh)[1]="states"
fembh=fembh[order(as.character(fembh$states)),]
mychart=gvisBarChart(fembh,xvar="states",yvar="percent.female.students.in.total",
options=list(title="Percent female students taking APCS test", vAxes="[{title:'States'}]", hAxes="[{title:'Percent females in total'}]", width=900,height=1150))
plot(mychart)
#Question 1
#Percent of Hispanics taking AP Test
fembh=fembh[order(as.character(fembh$states)),]
mychart2=gvisBarChart(fembh,xvar="states",yvar="percent.hispanic.students.in.total",
options=list(title="Percent hispanic students taking APCS", vAxes="[{title:'States'}]", hAxes="[{title:'Percent hispanics in total'}]",width=900,height=1150))
plot(mychart2)
#Question 1
#Percent of Blacks taking AP Test
fembh=fembh[order(as.character(fembh$states)),]
mychart3=gvisBarChart(fembh,xvar="states",yvar="percent.black.students.in.total",
options=list(title="Percent black students taking APCS", vAxes="[{title:'States'}]", hAxes="[{title:'Percent blacks in total'}]",width=900,height=1150))
plot(mychart3)
#Question 2
#Female Pass Rate
names(femalepassrate)
[1] “X2013.data”
[2] “Number.of.females”
[3] “Number.female.passed”
[4] “Percent.of.female.passed”
[5] “Percent.of.females.out.of.the.whole”
females=femalepassrate[,c(1,4)]
names(females)[1]="State"
GeoStates=(gvisGeoChart(females, "State", "Percent.of.female.passed",options=list(title="Percent of Females Passed", region="US", displayMode="regions", resolution="provinces",width=600, height=400, colorAxis="{colors:['#4daf4a', '#fc8d62']}")))
print(GeoStates,file="FemaleGeoStates.html")
#plot(GeoStates)
#Black Pass Rate
names(blackpassrate)
[1] “X2013.data”
[2] “Total.Number”
[3] “Number.of.Black”
[4] “Number.of.Black.Passed”
[5] “Percent.of.Black.passed”
[6] “Percent.of.black.taking.exam”
[7] “Percent.black.in.state”
[8] “Percent.taking…Percent.state.X.100”
black=blackpassrate[,c(1,5)]
names(black)[1]="State"
GeoStates=(gvisGeoChart(black, "State", "Percent.of.Black.passed",options=list(title="Percent of Blacks passed", region="US", displayMode="regions", resolution="provinces",width=600, height=400, colorAxis="{colors:['#7fff00', '#0000cd']}")))
print(GeoStates,file="BlackGeoStates.html")
#plot(GeoStates)
#Hispanic Pass Rate
names(hispanicpassrate)
[1] “X2013.data”
[2] “Total.number”
[3] “Number.of.Hispanic”
[4] “Number.of.Hispanic.passed”
[5] “Percent.of.Hispanic.passed”
[6] “Percent.of.hispanic.taking.exam”
[7] “Percent.of.Hispanic.in.state”
[8] “Percent.taking…Percent.state.X.100”
hispanic=hispanicpassrate[,c(1,5)]
names(hispanic)[1]="State"
GeoStates=gvisGeoChart(hispanic, "State", "Percent.of.Hispanic.passed",options=list(title="Percent of Hispanics passed", region="US", displayMode="regions", resolution="provinces",width=600, height=400, colorAxis="{colors:['#fff8dc', '#9a32cd']}"))
print(GeoStates,file="HispanicGeoStates.html")
plot(GeoStates)
#Question 3a
#Discrepancy for Females
names(discrepancyfemales)[1]="States"
discrepancyfemales=discrepancyfemales %>% arrange(desc(Discrepancy)) %>% head(10)
mychart4=gvisBarChart(discrepancyfemales,xvar="States",yvar="Discrepancy",
options=list(title="10 best states for Females", vAxes="[{title:'States'}]", hAxes="[{title:'Discrepancy'}]",width=900,height=1150))
plot(mychart4)
#Question 3b
#Discrepancy for Blacks
names(discrepancyblacks)[1]="States"
discrepancyblacks=discrepancyblacks %>% arrange(desc(Discrepancy)) %>% head(10)
mychart5=gvisBarChart(discrepancyblacks,xvar="States",yvar="Discrepancy",
options=list(title="10 best states for Blacks", vAxes="[{title:'States'}]", hAxes="[{title:'Discrepancy'}]",width=900,height=1150))
plot(mychart5)
#Question 3c
#Discrepancy for Hispanics
names(discrepancyhispanics)
[1] “X2013.data” “Percent.of.Hispanic.passed” [3] “Total.percent.passed” “Discrepancy”
names(discrepancyhispanics)[1]="States"
discrepancyhispanics=discrepancyhispanics %>% arrange(desc(Discrepancy)) %>% head(10)
mychart6=gvisBarChart(discrepancyhispanics,xvar="States",yvar="Discrepancy",
options=list(title="10 best states for Hispanics", vAxes="[{title:'States'}]", hAxes="[{title:'Discrepancy'}]",width=900,height=1150))
plot(mychart6)