facetSpacing: Generate plotting locations for subgrouping data

View source: R/np_utility.R

facetSpacingR Documentation

Generate plotting locations for subgrouping data

Description

facetSpacing generates a vector for the at= specification in functions for data sub-grouping

Usage

facetSpacing(subgroup, labels)

Arguments

subgroup

positive integer; number of levels in the subgrouping factor

labels

positive integer; number of levels in the primary factor

Details

facetSpacing takes the number factor levels from the primary and secodary grouping factors to generate a vector of positions for plotting subgrouped data for the nicePlots package. The spacing assumes that each primary factor levels is plot on positive integers 1, 2, 3 etc. For a primary factor at position i with f subgroup levels, the subgrouping comes from generating equally spaced intervals starting at i-\frac{1}{2}+\frac{1}{f+1} and ending at i+\frac{1}{2}-\frac{1}{f+1}. Simply put:

Spacing = \frac{1}{NSubGroups-1}

Value

a numeric vector of where to plot the subgrouped data. Can be supplied to that at= option in plotting functions

See Also

prepCategoryWindow

Examples

#\donttest{boxplot(CNA$BM~ CNA$Status,border="white")}
#\donttest{stripchart(CNA$BM~factor(paste0(CNA$Status,CNA$Sex)),add=T,at=facetSpacing(2,2))}

ZachHunter/NicePlots.R documentation built on Sept. 23, 2023, 4:04 a.m.