scorex: scorex

Description Usage Arguments Details Value Examples

View source: R/scorex.R

Description

A dual score matrix function that allows for multiple performance, and cross variables.

Usage

1
2
scorex(formula, data, cut_method = c("bins", "breaks", "percentiles"),
  method_args = NULL, exceptions = NA, custom_cut_fnc = NULL, ...)

Arguments

formula

A formula of the form LHS ~ RHS to use to specify which fields to use as the scores and performance measures in the tables, see Details.

data

A data.frame, that has the fields specified in the formula.

cut_method

The method to use to format the score in the final table. The method may be a single charcter specifying the cut method, or a list with two elements, specifing the method for the left, and right side of the formula respectively. Currently the available methods are:

  • bins: Break the scores into a set number of even bins.

  • breaks: Set the score values to break the score at.

  • percentiles: Set the percentiles to use to break the scores at.

method_args

Arguments to use for the method specified in cut_method each method uses the following argument. If cut_method is a list of two methods, method_args must also be a list of two elements, specifying the method arguments for the left and right side of the formula respectively.

  • bins: Provide a integer specifying the even number of breaks to create.

  • breaks: Provide an integer vector that specifies the cuts to use.

  • percentiles: Provide a vector of percentiles between the values of 0 and 1.

exceptions

A vector of exception values to exclude from the cross table. The default is set to NA.

custom_cut_fnc

A custom function to use to cut the scores.

...

Other arguments to pass to the custom_cut_fnc

Details

Formula...

The formula interface of scorex provides an API for intuatively creating dual score matrices. The formula takes the following form:

LHS ~ RHS | extra vars

Each portion of the formula allows for the following funtionality.

LHS

This portion of the formula can be used to identify one or several score like variables, each seperated with a +, that will be displayed along the right most column of the scorex table.

RHS

This portion of the formula can be used to identify one or several score like variables, each seperated with a +, that will be displayed along the first row of the scorex table.

extra vars

Optional variables to distribute along the score variables. By default these variables will be treated as binary performance fields, and the rate and total will be displayed. A ! symbol (exclaimation mark) may be used to signify that the variable should be treated like a continuous numeric field such as a dollar value.

If more than one variable is placed in the 'LHS' or 'RHS' of the formula dual score tables will be created of all possible combinations of the cross variables.

Value

An object of class scorex.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Formula Examples
mc_tabs <- scorex(disp ~ hp, data = mtcars)
mc_tabs$tables

mc_tabs <- scorex(disp ~ hp | vs, data = mtcars)
mc_tabs$tables

mc_tabs <- scorex(disp ~ hp + mpg | vs, data = mtcars)
mc_tabs$tables

mc_tabs <- scorex(disp ~ hp + mpg | vs + !wt, data = mtcars)
mc_tabs$tables

# Examples of cut method
mc_tabs <- scorex(disp ~ hp | vs, data = mtcars,
                  cut_method = "bins", method_args = 4)
mc_tabs$tables

mc_tabs <- scorex(disp ~ hp | vs, data = mtcars,
                  cut_method = list("bins", "percentiles"),
                  method_args = list(2, c(1, 25, 75, 100)))
mc_tabs$tables

jinlow/scorex documentation built on Dec. 18, 2019, 4:39 a.m.