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 | ```
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)
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.