has_multiple_levels | R Documentation |
Variable has multiple levels?
has_multiple_levels(x, ...)
## S3 method for class 'character'
has_multiple_levels(x, .xname = get_name_in_parent(x), ...)
## S3 method for class 'factor'
has_multiple_levels(x, .xname = get_name_in_parent(x), ...)
## S3 method for class 'numeric'
has_multiple_levels(x, .xname = get_name_in_parent(x), ...)
## S3 method for class 'data.table'
has_multiple_levels(
x,
y,
.xname = get_name_in_parent(x),
.yname = get_name_in_parent(y),
...
)
## S3 method for class 'SummarizedExperiment'
has_multiple_levels(
x,
y,
.xname = get_name_in_parent(x),
.yname = get_name_in_parent(y),
...
)
x |
vector, data.table or SummarizedExperiment |
... |
required for s3 dispatch |
.xname |
string |
y |
string |
.yname |
string |
TRUE or false
# numeric
a <- numeric(); has_multiple_levels(a)
a <- c(1, 1); has_multiple_levels(a)
a <- c(1, 2); has_multiple_levels(a)
# character
a <- character(); has_multiple_levels(a)
a <- c('A', 'A'); has_multiple_levels(a)
a <- c('A', 'B'); has_multiple_levels(a)
# factor
a <- factor(); has_multiple_levels(a)
a <- factor(c('A', 'A')); has_multiple_levels(a)
a <- factor(c('A', 'B')); has_multiple_levels(a)
# data.table
dt <- data.table(a = factor()); has_multiple_levels(dt, 'b')
dt <- data.table(a = factor()); has_multiple_levels(dt, 'a')
dt <- data.table(a = factor()); has_multiple_levels(dt, 'a')
dt <- data.table(a = factor(c('A', 'A'))); has_multiple_levels(dt, 'a')
dt <- data.table(a = factor(c('A', 'B'))); has_multiple_levels(dt, 'a')
# sumexp
object <- matrix(1:9, nrow = 3)
rownames(object) <- sprintf('f%d', 1:3)
colnames(object) <- sprintf('s%d', 1:3)
object <- list(exprs = object)
object %<>% SummarizedExperiment::SummarizedExperiment()
object$subgroup <- c('A', 'A', 'A'); has_multiple_levels(object, 'group')
object$subgroup <- c('A', 'A', 'A'); has_multiple_levels(object, 'subgroup')
object$subgroup <- c('A', 'B', 'A'); has_multiple_levels(object, 'subgroup')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.