determineGrid: Determine Grid

View source: R/determineGrid.R

determineGridR Documentation

Determine Grid

Description

Determine rows and columns for a data.table for facet or a list for ggarrange (or anything that takes rows and cols arguments)

Usage

determineGrid(
  obj,
  col_v = NULL,
  method_v = "grid",
  by_v = "column",
  verbose_v = F
)

Arguments

obj

either a data.table or a list

col_v

if object is class "data.table" optional column to grab unique values from to determine grid.

method_v

either "grid" (default) for a compact grid (ggplot's facet_wrap default behavior), or a number indicating how intensely to skew the grid (e.g. 1, 2, etc.)

by_v

either "row" or "column". Determines which gets added first as grid size increases.

verbose_v

logical. will provide comments on what's happening to make sure you chose right params.

Details

Given an object of arbitrary dimension that needs to be output in a grid format, create desired row/column combinations based on two main methods - grid or long. Grid follows ggplot2:facet_wrap's behavior using ceiling(length/nrow(obj)) or celing(length/nrow(unique(obj[[col_v]]))) Using the default by of "column" will match facet_wrap exactly, by = "row" will add rows first instead.

The long method is denoted by method = <integer>. In this case the ncol/nrow is determined the same as above, except the integer value provided will be added to the result, exaggerating either the row or column dimension accordingly ceiling(length(nrow(obj))). This method maxes out at the number of unique entries in obj


weshorton/wrh.rUtils documentation built on Oct. 28, 2024, 7:24 a.m.