Description Usage Arguments Examples
Plot clustered series
1 2 |
x |
object obtained from |
k |
number of clusters to plot |
centroid |
should centroids be overlaid? |
xlab |
x-axis label |
ylab |
y-axis label |
alpha |
alpha to use for lines |
use_median |
should median be used instead of mean to compute the centroid? |
... |
additional parameters passed on to |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | ## Not run:
library(dplyr)
# scale the monthly median close price so that we are clustering on general shape
d <- nasd16 %>%
group_by(symbol) %>%
mutate(close_scl = as.numeric(scale(med_close))) %>%
select(-company, -med_close) %>%
ungroup()
set.seed(1234)
# k-means clustering with 2, 5, and 9 clusters
km <- get_kmeans(d, x = "month", y = "close_scl", k = c(2, 5, 9, 25))
plot_scree(km)
plot_heat(km, 9, col = "sector")
plot_heat(km, 9, col = "sector", interactive = FALSE,
display_numbers = TRUE, cutree_cols = 3, cutree_rows = 3)
plot_heat(km, 9, col = "industry", cutoff = 20)
heat <- plot_heat(km, 9, col = "sector", interactive = FALSE,
display_numbers = TRUE, cutree_cols = 3, cutree_rows = 3,
annotation_labs = c("A", "B", "C"))
heat
cents <- get_centroid_data(km, 9)
plot_centroid_groups(cents, heat)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.