Description Usage Arguments Value See Also Examples

View source: R/cutree.dendrogram.R

Takes a numeric vector and sort its values so that they
would be increasing from left to right.
It is different from `sort`

in that the function
will only "sort" the values levels, and not the vector itself.

This function is useful for cutree - making the sort_cluster_numbers parameter possible. Using that parameter with TRUE makes the clusters id's from cutree to be ordered from left to right. e.g: the left most cluster in the tree will be numbered "1", the one after it will be "2" etc...).

1 2 3 4 5 6 7 8 | ```
sort_levels_values(
x,
MARGIN = 2,
decreasing = FALSE,
force_integer = FALSE,
warn = dendextend_options("warn"),
...
)
``` |

`x` |
a numeric vector. |

`MARGIN` |
passed to apply. It is a vector giving the subscripts which the function will be applied over. E.g., for a matrix 1 indicates rows, 2 indicates columns, c(1, 2) indicates rows and columns. Where X has named dimnames, it can be a character vector selecting dimension names. |

`decreasing` |
logical (FALSE). Should the sort be increasing or decreasing? |

`force_integer` |
logical (FALSE). Should the values returned be integers? |

`warn` |
logical (default from dendextend_options("warn") is FALSE). Set if warning are to be issued, it is safer to keep this at TRUE, but for keeping the noise down, the default is FALSE. (for example when x had NA values in it) |

`...` |
ignored. |

if x is an object - it returns logical - is the object of class dendrogram.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | ```
x <- 1:4
sort_levels_values(x) # 1 2 3 4
x <- c(4:1)
names(x) <- letters[x]
attr(x, "keep_me") <- "a cat"
sort_levels_values(x) # 1 2 3 4
x <- c(4:1, 4, 2)
sort_levels_values(x) # 1 2 3 4 1 3
x <- c(2, 2, 3, 2, 1)
sort_levels_values(x) # 1 1 2 1 3
x <- matrix(16:1, 4, 4)
rownames(x) <- letters[1:4]
x
apply(x, 2, sort_levels_values)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.