Learn R Programming

LSTbook (version 0.6)

zero_one: Zero-one transformation for categorical variable

Description

A convenience function for handling categorical response variables. Ordinarily, ggplot2 maps categorical levels to numerical values 1, 2, .... Such numerical mapping is inappropriate for logistic modeling, where we want the levels to be on a probability scale.

Usage

zero_one(x, one)

label_zero_one(P)

Value

A numerical vector of 0s and 1s.

Arguments

x

a categorical variable

one

character string specifying the level that gets mapped to 1.

P

A ggplot2 object made by model_plot() or point_plot()

Examples

Run this code
Birdkeepers |>
  point_plot(zero_one(LC, one="LungCancer") ~ AG + BK, annot = "model")

Birdkeepers |>
  mutate(Condition = zero_one(LC, one = "LungCancer")) |>
  point_plot(Condition ~ AG + BK, annot = "model") |>
  label_zero_one() |>
  add_plot_labels(x="age", color = "Birdkeeper?")

Run the code above in your browser using DataLab