-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ordering clusters in plotClusterTrajectories() #144
Comments
Hi @hichew22, thanks for the suggestion. It's a useful feature to have, especially when comparing similar cluster solutions. I'll start with adding an argument to plotClusterTrajectories for specifying which clusters to plot, and the ordering. |
|
Awesome, thanks, Niek! Do you have an example, and does this also allow ordering clusters from most to least frequent? |
You're welcome! data(latrendData)
method <- lcMethodLMKM(Y ~ Time, id = "Id", time = "Time")
model <- latrend(method, latrendData, nClusters = 3)
# change cluster order
plotClusterTrajectories(model, clusterOrder = c('B', 'C', 'A'))
# show only specific clusters
plotClusterTrajectories(model, clusterOrder = c('B', 'C')) It's intended as a quick way to set a custom order, but to dynamically order by cluster size, you can use: plotClusterTrajectories(model, clusterOrder = order(-clusterSizes(model))) In the future I intend to add some |
Did you install the latest commit (not release)?
|
Yes, I just did but seems like the function does not work. ─ preparing ‘latrend’: (555ms) |
I can't spot any issues in the source code. Could you let me know what the output is of: latrend:::make.orderedClusterNames(clusterNames(dtw_model_4), order(-clusterSizes(dtw_model_4))) |
I just tried re-running it and it works now! Perhaps I had to restart my R session. Thank you so much! |
Hello Niek,
I am using the dtw method in latrend to plot some clusters like so:
plotClusterTrajectories(dtw_model_2)
or
plot(dtw_model_2)
Is there a way within plotClusterTrajectories() where I can specify that the cluster with more values is always listed as cluster "A" (highest frequency to lowest frequency)?
Or would I need to reorder them manually, something like:
?
Thank you!
The text was updated successfully, but these errors were encountered: