Learn R Programming

swfscMisc (version 1.6.5)

plotAssignments: Plot assignment distributions

Description

Plot individual assignment probability distributions.

Usage

plotAssignments(
  probs,
  orig,
  type = NULL,
  ylab = NULL,
  freq.sep.line = TRUE,
  plot = TRUE
)

Value

the ggplot object is invisibly returned.

Arguments

probs

matrix or data.frame of individual assignment probabilities. Each column represents probability of assignment to that group and rows sum to one.

orig

vector of original group assignments

type

either area for stacked continuous area plot or bar for discrete stacked bar chart. The latter is prefered for small numbers of cases. If not specified, a bar chart will be used if all classes have <= 30 cases.

ylab

label for y-axis

freq.sep.line

put frequency of original group on second line in facet label? If FALSE, labels are single line. If NULL frequencies will not be included in labels.

plot

display the plot?

Author

Eric Archer eric.archer@noaa.gov

Examples

Run this code
n <- 40
probs <- abs(c(rnorm(n, 80, 10), rnorm(n, 20, 10)))
probs <- (probs - min(probs)) / max(probs)
probs <- cbind(probs, 1 - probs)
colnames(probs) <- NULL
orig <- rep(c("Group.1", "Group.2"), each = n)

plotAssignments(probs, orig)

n <- 15
probs <- abs(c(rnorm(n, 80, 10), rnorm(n, 20, 10)))
probs <- (probs - min(probs)) / max(probs)
probs <- cbind(probs, 1 - probs)
colnames(probs) <- NULL
orig <- rep(c("Group.1", "Group.2"), each = n)

plotAssignments(probs, orig)

Run the code above in your browser using DataLab