roc_plot: roc_plot

View source: R/roc_plot.R

roc_plotR Documentation

roc_plot

Description

roc_plot

Usage

roc_plot(
  data,
  fitted,
  actual,
  group = NULL,
  facet_x = NULL,
  facet_y = NULL,
  palette = ez_col,
  size_line = 1,
  size = 11,
  env = parent.frame()
)

Arguments

data

A data.frame.

fitted

Vector of fitted values

actual

Vector of actual values

group

A character value. Evaluates to a column.

facet_x

A character value. Evaluates to a column.

facet_y

A character. Evaluates to a column.

palette

Colour function.

size_line

width of line for geom_line(). Default is 1.

size

theme size for use_theme(). Default is 14.

env

environment for evaluating expressions.

Examples

library(ggplot2)
n = 1000
df = data.frame(actual = sample(c(FALSE, TRUE), n, replace = TRUE),
                runif = runif(n))
df[["fitted"]] = runif(n) ^ ifelse(df[["actual"]] == 1, 0.5, 2)

ggplot(df) +
  geom_density(aes(fitted, fill = actual), alpha = 0.5)

roc_plot(df, "actual", "actual")
roc_plot(df, "fitted", "actual")
roc_plot(df, "runif", "actual", size_line = 0.5)


library(dplyr, warn.conflicts = FALSE)
roc_plot(df, "fitted", "actual", "sample(c(1, 2), n(), TRUE)")

roc_plot(df, "fitted", "actual",
         "sample(c(1, 2), n(), TRUE)",
         "sample(c(3, 4), n(), TRUE)")

roc_plot(df, "fitted", "actual",
         "sample(c(1, 2), n(), TRUE)",
         "sample(c(3, 4), n(), TRUE)",
         "sample(c(5, 6), n(), TRUE)")


ezplot documentation built on Aug. 12, 2022, 1:07 a.m.