perf.plot: perf.plot

Description Usage Arguments Value Examples

Description

Creates my most common univariate plot - the target variable averaged at different levels of x and superimposed over a histogram showing the population distribution across the different values of x. The returned plot is a ggplot2 object.

Usage

1
2
3
4
5
perf.plot(y, x, xlab = deparse(substitute(x)),
  ylab = deparse(substitute(y)), main = paste(ylab, xlab, sep =
  " vs. "), num.switch = class(x) %in% c("numeric", "integer",
  "float"), col = "black", lwd = 450/length(.buckets(x,
  num.switch)$groups))

Arguments

y

- The target variable

x

- The independent variable.

xlab

- x-axis label, straight from qplot.

ylab

- y-axis label, straight from qplot.

main

- Main title, straight from qplot.

num.switch

- Binary. True if we should treat x as numeric, false if categorical.

col

- Color of the univariate line, straight from qplot.

lwd

- Histogram width control. Should default to something sensible.

Value

Returns a ggplot object with the mean value of y plotted over x, and a histogram overlayed in the background.

Examples

1
2
3
4
5
perf.plot(as.integer(iris$Species == "virginica"),iris[,1])
perf.plot(as.integer(iris$Species == "virginica"),iris[,2])
perf.plot(as.integer(iris$Species == "virginica"),iris[,3])
perf.plot(as.integer(iris$Species == "virginica"),iris[,1], num.switch=FALSE)
perf.plot(as.integer(iris$Species == "virginica"),iris[,3], num.switch=FALSE)

christiantillich/AnaliTools documentation built on May 13, 2019, 6:59 p.m.