tree2color: Cut a "colored" tree

Description Usage Arguments Examples

View source: R/tree2color.R

Description

This function is used for getting hard clusters by cutting a tree. Use function plot_colours on the result of this function to get a plot.

Usage

1
tree2color(tree_model, k = 3, fun = "mean")

Arguments

tree_model

model produced by pick_palette_jk function.

k

number of clusters.

fun

function used on grouped data. Perhaps it makes sense to use different functions than mean. Median might be a good choice. Input should be character.

Examples

1
2
3
4
5
6
7
8
9
path <- "./man/figures/duck.jpg"
tree <- pick_palette_jk(path)
colours <- tree2color(tree, k = 10)
plot_colours(colours)

## or use something like this
# it is commented in order not to fail when pals is unable to install
# color_list <- purrr::map(1:10,~tree2color(tree,.x))
#do.call(pals::pal.bands,color_list)

jakubkovac/Lori documentation built on Jan. 9, 2020, 9:49 p.m.