statebin htmlwidget with hclust cutree
rcstatebin from @ramnathv with hclust examples
# devtools::install_github( "ramnathv/rcstatebin" )
### use example from ?hclust and ?cutree
library( rcstatebin )
library( tidyr )
library( dplyr )
hclust(dist(USArrests)) %>%
cutree( k = 2:5 ) %>%
{
data.frame(
state = state.abb
,.
)
} %>%
gather( cutree_k, membership, -state ) %>%
statebin(
membership ~ state | cutree_k
, control = 'dropdown'
, heading = '<h3>Statebin of hclust cutree k</h3>'
, footer = '
<small style = "font-style:italic;text-align:right;display:block;">
code from R ?cutree
</small>
'
, height = 300
, width = 500
)