makeFlow {makeFlow}R Documentation

makeFlow()

Description

Uses the selected dataset and specified order of columns to produce a left-to-right flow diagram. This function assumes the use of a single dataset and categorical variables resembling observations' movement from one state to another, such that at every state, every observation can be mapped. Colors bridging states assume the color of the gate from which they originate.

Usage

makeFlow(data, classFields, rotate = F, gatecolors = NA, minVerticalBtwnGates = 0.1, 
connectingAlpha = 0.5, bg = "white", plotTitle = "", titleAdj = 0.5, txtColor = "black", 
distanceBtwnGates = 50, gateWidth = 7, gateBorder = NA, labels = T, fieldLabels = NA, 
showPercentages = T, showConnectPercentages = F, percentTextColor = "black", 
showCounts = T, countTextColor = "black")

Arguments

data

An object of class data.frame in which all specified classFields (column names) can be found.

classFields

A vector of the column names intended to be represented in a makeFlow() diagram. Each element in this vector must be a string.

rotate

Set to TRUE to rotate all text. This is a work-around to allow for a vertical (top-down) flow. Manual manipulation after exporting a diagram is needed to adjust the orientation of the output.

gatecolors

A vector of colors to apply to gates. For greater control, the alphabetized order of categories from all selected classFields will match the corresponding color in this list. If the length of this vector is shorter than the number of unique categories in the full diagram, a predefined palette "Set3" is substituted in its place, and a warning message will alert the user of how many colors are required for manual input. If more colors are supplied than necessary, only the required number will be taken from the beginning of the vector. (default is NA, which will assign colors from palette "Set3")

minVerticalBtwnGates

A single value (likely between 0 and 1) used to determine the minumum plotted gap between categories (gates) within the same classField. For reference, the default plot height is 1. (default is 0.1)

connectingAlpha

A single decimal value [0,1] setting the opacity of the "flows" connecting gates. (default is 0.5)

bg

A single color from colors() specifying the diagram's background color. (default is "white")

plotTitle

The title of the diagram. (default is "")

titleAdj

A single value [0,1] adjusting the title's horizontal placement. 0 implies left-align; 1 impllies right-align. (default is 0.5)

txtColor

A single color from colors() specifying the text color in the diagram. (default is "black")

distanceBtwnGates

A single numeric value representing the horizontal distance between classFields. (default is 50)

gateWidth

A single numeric value representing the horizontal width of gates. (default is 7)

gateBorder

A single color from colors() specifying the color of all gates' borders. (default is NA)

labels

Set to FALSE to not see the category labels above each gate.

fieldLabels

A character vector of names to identify each classField in the diagram. These labels will be placed below each set of gates. If labels is FALSE, fieldLabels will not be displayed. (default is NA)

showPercentages

Set to FALSE to hide the percentage values within gates.

showConnectPercentages

Set to FALSE to hide the percentage values within flows.

percentTextColor

A single color from colors() for the gate percentage and flow percentage texts. (default is "black")

showCounts

Set to FALSE to hide the counts of observations within each gate.

countTextColor

A single color from colors() for the gate count text. (default is "black")

Note

Relies on Hadley Wickham's dplyr package to generate summaries. Gates within each field are ordered alphabetically, numerically, or (if applicable) in the order of a factor's levels.

Author(s)

Alex J. Krebs

Examples

## makeFlow(data = shelters, classFields = c("loc","Jan","Feb","Mar"),
##          fieldLabels = c("","Jan","Feb","Mar"), gateWidth = 20)

[Package makeFlow version 1.0.2 Index]