Function to create positions for a figure based on the combination of grouping factors in a data frame.

specify_positions(dtf, spacing = c(0.25, 0.25), as_list = FALSE)

Arguments

dtf

A data frame with separate columns for each grouping variable.

spacing

A numeric vector of two values, the gap to add between groups and at the beginning and end for plotting limits (given as a proportion).

as_list

Logical; if TRUE returns a list with both the positions and the suggested lower and upper x-axis limits; otherwise, returns the positions as a vector.

Value

A numeric vector of values. If as_list is TRUE, a list with two vectors, one for the positions and one with the lower and upper limits for the plotting boundaries.

Examples

# Example data set
data("mtcars")
dtf <- stats_by_group( mtcars, 'mpg', c( 'vs', 'am' ) )
specify_positions( dtf[, 1:2] )
#> [1] 1.0 2.5 4.0 5.5