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>")
pitchingInfo = getTableSummary(channel=conn, 'pitching_enh')
# list all table columns
pitchingInfo$COLUMN_NAME
# compute statistics on subset of baseball data after 1999
battingInfo = getTableSummary(channel=conn, 'batting_enh',
where='yearid between 2000 and 2013')
# compute statistics for certain columns including each percentile from 1 to 99
pitchingInfo = getTableSummary(channel=conn, 'pitching_enh',
include=c('h', 'er', 'hr', 'bb', 'so'),
percentiles=seq(1,99))
# list data frame column names to see all computed statistics
names(pitchingInfo)
# compute statitics on all numeric columns except certain columns
teamInfo = getTableSummary(channel=conn, 'teams_enh',
include=getNumericColumns(sqlColumns(conn, 'teams_enh')),
except=c('lgid', 'teamid', 'playerid', 'yearid', 'decadeid'))
}
Run the code above in your browser using DataLab