get_levels | R Documentation |
Maps the values in a numeric vector as quantiles, default is low, intermediate, and high,
get_levels(v, n_quantiles = 3, add = NA, return_num = F)
v |
A numeric vector |
n_quantiles |
Number of quantiles/levels to separate v by. Default 3. Minimum 2. |
add |
A string to add to the beginning of each levels in the result, e.g If add is "gene", the result will be "gene.low", "gene.int", gene.high" |
return_num |
Logical indicating whether to return the number of quantile or not |
levels |
A list of 3 elements (l, i, h) representing quantiles, default is 1 = low, 2 = intermediate, 3 = high. If n_quantiles > 3, the "middle" levels will be "int", "int.plus", "int.plus.plus" and so on. Note: If "LEVELS" is defined in global environment, this variable will be used. |
A vector with the same length as v, where each element represents the quantile, either in numeric form (if return_num is TRUE) or characters with the legend represented by the levels parameter
get_levels(1:9)
# [1] "low" "low" "low" "intermed" "intermed" "intermed" "high" "high" "high"
get_levels(1:9, return_num = T)
# [1] 1 1 1 2 2 2 3 3 3
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.