splitByLevel: Split by factor level

splitByLevelR Documentation

Split by factor level

Description

Split by factor level

Usage

splitByLevel(x, f, ref = FALSE, ...)

## S4 method for signature 'DFrame'
splitByLevel(x, f, ref = FALSE)

Arguments

x

Object.

f

character(1). Factor column name.

ref

logical(1). Include the reference factor level (i.e. first defined) in each split. Useful for pairwise contrasts.

...

Additional arguments.

Value

list List of data frames split by factors.

Note

Updated 2020-09-14.

See Also

  • split()

  • dplyr::group_split()

Examples

df <- S4Vectors::DataFrame(
    "compound" = relevel(
        factor(
            c(
                rep(x = "dmso", each = 3L),
                rep(x = c("ts_0001", "ts_0002"), each = 9L)
            )
        ),
        ref = "dmso"
    ),
    "concentration" = factor(
        c(
            rep(x = 0, each = 3L),
            rep(x = c(0.1, 1, 10), each = 3L, times = 2L)
        )
    ),
    "replicate" = factor(
        rep(
            seq(from = 1L, to = 3L),
            times = 7L
        )
    )
)
lapply(df, levels)
splitByLevel(df, f = "compound", ref = FALSE)
splitByLevel(df, f = "compound", ref = TRUE)
splitByLevel(df, f = "concentration", ref = FALSE)
splitByLevel(df, f = "concentration", ref = TRUE)

acidgenomics/r-acidplyr documentation built on July 4, 2025, 5:55 a.m.