How can we show the trajectories belonging to clusters in `kml` package?

孤街醉人 提交于 2020-05-13 22:55:10

问题


The kml package implements k-means for longitudinal data. The clustering works just fine.

Now I'm wondering how I can show the 'structure' of the clusters, for example, by coloring them.

A most simple example from the docs (help file of the clusterLongData function..):

library(kml)

traj <- matrix(c(1,2,3,1,4, 3,6,1,8,10, 1,2,1,3,2, 4,2,5,6,3, 4,3,4,4,4, 7,6,5,5,4),6)

myCld <- clusterLongData(
  traj=traj,
  idAll=as.character(c(100,102,103,109,115,123)),
  time=c(1,2,4,8,15),
  varNames="P",
  maxNA=3
)

kml(myCld, 2, toPlot = 'both')

This code sample finds two clusters and plots the clusters as well as the underlying data. But I don't see which trajectories are associated with which cluster.


  • Is there a possibility inside the kml package to color the trajectories in the same color as the clusters are plotted?
  • Are there other ideas or experiences to generate a plot showing the clusters plus the association trajectory <> cluster? (for example with ggplot2 on the myCld object?)

Thanks in advance for any hints..

来源:https://stackoverflow.com/questions/61247205/how-can-we-show-the-trajectories-belonging-to-clusters-in-kml-package

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!