factor2label: Convert factor to a factor label

factor2labelR Documentation

Convert factor to a factor label

Description

Convert factor to a factor label

Usage

factor2label(
  x,
  valuesL = NULL,
  types = c("count", "none"),
  aggFun = mean,
  digits = 3,
  big.mark = ",",
  itemName = "items",
  ...
)

Arguments

x

factor vector

valuesL

optional list of numeric values, where each vector has the same length as x. If it is not a factor, it is converted to factor, using jamba::mixedSort() to order the factor levels.

types

character value indicating the summary to use for the input factor x.

aggFun

summary function used for each vector of numeric values in valuesL when supplied.

digits, big.mark

arguments passed to base::format() to create a suitable text label.

itemName

character vector indicating the name to associate to counts.

...

additional arguments are ignored.

Details

This function is intended to take a vector of factor levels and convert to labels using summary statistics. For example by default it will add the number of items for each factor level.

This function is intended to help create useful ordered factor labels that can be used in a ggplot2 visualization.

Value

factor vector with the same length as input x but where the levels also include summary information, such as the count of each factor level.

See Also

Other jam plot functions: bgaPlotly3d(), gene2gg(), grl2df(), jitter_norm(), plotSashimi(), prepareSashimi(), stackJunctions()

Examples

x <- factor(rep(letters[1:5], c(2,4,3,2,1)));
levels(factor2label(x));
factor2label(x);


jmw86069/splicejam documentation built on Nov. 4, 2024, 10:53 a.m.