if(interactive()){
# initialize connection to Lahman baseball database in Aster
conn = odbcDriverConnect(connection="driver={Aster ODBC Driver};
server=<dbhost>;port=2406;database=<dbname>;uid=<user>;pwd=<pw>")
cormat = computeCorrelations(channel=conn, "pitching_enh", sqlColumns(conn, "pitching_enh"),
include = c('w','l','cg','sho','sv','ipouts','h','er','hr','bb',
'so','baopp','era','whip','ktobb','fip'),
where = "decadeid = 2000", test=FALSE)
# remove duplicate correlation values (no symmetry)
cormat = cormat[cormat$metric1 < cormat$metric2, ]
createBubblechart(cormat, "metric1", "metric2", "value", label=NULL, fill="sign")
# Grouped by columns
cormatByLg = computeCorrelations(channel=conn, "pitching_enh",
include=c('w','sv','h','er','hr','bb','so'),
by=c('lgid','decadeid'),
where = "decadeid >= 1990")
createBubblechart(cormatByLg, "metric1", "metric2", "value",
label=NULL, fill="sign", facet=c('decadeid','lgid'),
title="Correlations by Leagues and Decades",
defaultTheme = theme_wsj(), legendPosition = 'none')
}
Run the code above in your browser using DataLab