Learn R Programming

biogram (version 1.1)

fast_crosstable: Very fast 2d cross-tabulation

Description

Quickly cross-tabulates two binary vectors.

Usage

fast_crosstable(target_b, len_target, pos_target, feature)

Arguments

target_b
target in bits (as per as.bit).
len_target
length of target vector.
pos_target
number of positive cases in target vector.
feature
feature vector.

Value

  • a vector of length four:
    1. target +, feature+
    2. target +, feature-
    3. target -, feature+
    4. target -, feature-

Details

Input looks odd, but the function was build to be as fast as possible subroutine of calc_ig, which works on many features but only one target.

Examples

Run this code
tar <- sample(0L:1, 100, replace = TRUE)
feat <- sample(0L:1, 100, replace = TRUE)
library(bit) #used to code vector as bit
fast_crosstable(as.bit(tar), length(tar), sum(tar),  feat)

Run the code above in your browser using DataLab