Skip to contents

The as.data.table function converts an S3 object generated by evalmod() to a data.table. It is the counterpart of as.data.frame(), for callers who would rather have the data.table that precrec builds internally than a copy of it as a plain data frame.

Usage

# S3 method for class 'sscurves'
as.data.table(x, keep.rownames = FALSE, raw_curves = NULL, ...)

# S3 method for class 'mscurves'
as.data.table(x, keep.rownames = FALSE, raw_curves = NULL, ...)

# S3 method for class 'smcurves'
as.data.table(x, keep.rownames = FALSE, raw_curves = NULL, ...)

# S3 method for class 'mmcurves'
as.data.table(x, keep.rownames = FALSE, raw_curves = NULL, ...)

# S3 method for class 'sspoints'
as.data.table(x, keep.rownames = FALSE, raw_curves = NULL, ...)

# S3 method for class 'mspoints'
as.data.table(x, keep.rownames = FALSE, raw_curves = NULL, ...)

# S3 method for class 'smpoints'
as.data.table(x, keep.rownames = FALSE, raw_curves = NULL, ...)

# S3 method for class 'mmpoints'
as.data.table(x, keep.rownames = FALSE, raw_curves = NULL, ...)

# S3 method for class 'aucroc'
as.data.table(x, keep.rownames = FALSE, ...)

Arguments

x

An S3 object generated by evalmod(). The as.data.table function accepts the same objects as as.data.frame().

keep.rownames

Ignored. Present because data.table::as.data.table has it in its signature; the objects this method converts carry no row names.

raw_curves

A Boolean value to specify whether raw curves are shown instead of the average curve. It is effective only when raw_curves is set to TRUE of the evalmod() function.

...

Not used by this method.

Value

The as.data.table function returns a data.table with the same columns as as.data.frame() returns for the same object.

See also

evalmod() for generating S3 objects with performance evaluation measures. as.data.frame() for the plain data frame equivalent. fortify() for converting the same objects for ggplot2.

Examples


## Load a dataset with 10 positives and 10 negatives
data(P10N10)

## Generate an sscurve object that contains ROC and Precision-Recall curves
sscurves <- evalmod(scores = P10N10$scores, labels = P10N10$labels)

## Convert sscurves to a data.table
if (requireNamespace("data.table", quietly = TRUE)) {
  head(data.table::as.data.table(sscurves))
}
#>        x     y modname   dsid   type
#>    <num> <num>  <fctr> <fctr> <fctr>
#> 1: 0.000   0.0      m1      1    ROC
#> 2: 0.000   0.1      m1      1    ROC
#> 3: 0.000   0.2      m1      1    ROC
#> 4: 0.001   0.2      m1      1    ROC
#> 5: 0.002   0.2      m1      1    ROC
#> 6: 0.003   0.2      m1      1    ROC