Learn R Programming

toaster (version 0.2.5)

computePercentiles: Compute percentiles of column values.

Description

Compute percentiles including boxplot quartiles across values of column columnName. Multiple sets of percentiles achieved with the parameter by. Vector by may contain arbitrary number of column names: the percentiles are computed for each combination of values from these columns. Remember that when using computed quartiles with function createBoxplot it can utilize up to 3 columns by displaying them along the x-axis and inside facets.

Usage

computePercentiles(channel, tableName, columnName,
    percentiles = c(0, 5, 10, 25, 50, 75, 90, 95, 100),
    by = NULL, where = NULL, stringsAsFactors = FALSE,
    test = FALSE)

Arguments

channel
connection object as returned by odbcConnect
tableName
Aster table name
columnName
name of the column to compute percentiles on
percentiles
integer vector with percentiles to compute. Values 0, 25, 50, 75, 100 will always be added if omitted.
by
for optional grouping by one or more values for faceting or alike. If used with createBoxplot then use first name for x-axis and the rest for wrap or grid faceting.
where
specifies criteria to satisfy by the table rows before applying computation. The creteria are expressed in the form of SQL predicates (inside WHERE clause).
stringsAsFactors
logical: should columns returned as character and not excluded by as.is and not converted to anything else be converted to factors?
test
logical: if TRUE show what would be done, only (similar to parameter test in RODBC functions like sqlQuery and sqlSave).

Examples

Run this code
# ipouts percentiles for pitching ipouts for AL in 2000s
ipop = computePercentiles(conn, "pitching", "ipouts",
                          where = "lgid = 'AL' and yearid >= 2000")

# ipouts percentiles by league
ipopLg = computePercentiles(conn, "pitching", "ipouts", by="lgid")

Run the code above in your browser using DataLab