Learn R Programming

TCGAretriever (version 1.9.1)

make_groups: Split Numeric Vectors in Groups.

Description

Assign each element of a numeric vector to a group. Grouping is based on ranks: numeric values are sorted and then split in 2 or more groups. Values may be sorted in an increasing or decreasing fashion. The vector is returned in the original order. Labels may be assigned to each group.

Usage

make_groups(num_vector, groups, group_labels = NULL, desc = FALSE)

Value

data.frame including the vector provided as argument in the original order ("value") and the grouping vector ("rank"). If labels are provided as an argument, group labels are also included in the data.frame ("labels").

Arguments

num_vector

numeric vector. It includes the values to be assigned to the different groups

groups

integer. The number of groups that will be generated

group_labels

character vector. Labels for each group. Note that the length of group_labels has to be equal to the number of groups

desc

logical. If TRUE, the sorting is applied in a decreasing fashion

Author

Damiano Fantini, damiano.fantini@gmail.com

References

https://www.data-pulse.com/dev_site/TCGAretriever/

Examples

Run this code
exprs_geneX <- c(19.1,18.4,22.4,15.5,20.2,17.4,9.4,12.4,31.2,33.2,18.4,22.1)
groups_num <- 3
groups_labels <- c("high", "med", "low")
make_groups(exprs_geneX, groups_num, groups_labels, desc = TRUE)

Run the code above in your browser using DataLab