I am using dtwclust
package to cluster a data frame contains multivariate time series data. After clustering these data, I would like to produce a plot presenting observation in $k$ groups according tot the cluster, not the time series data!
dtw_cluster2 = tsclust(sample_data, type="partitional",k=6,preproc = zscore,distance="dtw_basic",centroid = "pam",trace=T)
then to plot,
plot(dtw_cluster2)
I don't want these plots! I want the cluster of observations. I tried to extract the clusters from tsclust()
as dtw_cluster2$cluster
but I got an error "$ operator not defined for this S4 class"
.
My data set looks like
V1 V2 V3 V4 V5 V6 V7
1 0 0.1182197 0.09057301 0.08089888 0.003350084 0.00000000 0.00000000
2 0 0.1276078 0.09242144 0.01348315 0.060301508 0.02245599 0.02298152
3 0 0.1369958 0.12569316 0.03595506 0.159128978 0.04491198 0.04596305
4 0 0.1029207 0.10166359 0.08089888 0.201005025 0.06736798 0.06894457
5 0 0.1585535 0.14510166 0.08089888 0.112227806 0.08982397 0.09192609
6 0 0.1488178 0.00000000 0.07415730 0.212730318 0.11227996 0.11490761
edit
I want to plot the observations according to the clusters in something like this "knowing that I am using dtw
distance":