Skip to content
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

clustergram.plot.matlines requires plyr - use do.call instead of plyr::ldply #2

Open
SaintRod opened this issue Oct 23, 2023 · 0 comments

Comments

@SaintRod
Copy link

I use a modified version of this function and thought I'd share w/ others in case it's ever helpful. Originally, the code within the if block that checks if add.center.points is true, requires the plyr library. I don't usually have that library installed so I've modified the snipped to use do.call instead.

clustergram.plot.matlines <- function(X, Y, k.range,
                                      x.range, y.range, COL,
                                      add.center.points, centers.points) {
  plot(
    0,
    0,
    col = "white",
    xlim = x.range,
    ylim = y.range,
    axes = F,
    xlab = "Number of clusters (k)",
    ylab = "PCA weighted Mean of the clusters",
    main = c("Clustergram of the PCA-weighted Mean of", "the clusters k-mean clusters vs number of clusters (k)")
  )
  axis(side = 1, at = k.range)
  axis(side = 2)
  abline(v = k.range, col = "grey")

  matlines(t(X), t(Y), pch = 19, col = COL, lty = 1, lwd = 1.5)

  if (add.center.points) {
    xx <- do.call(rbind, centers.points)
    points(xx$y ~ xx$x, pch = 19, col = "red", cex = 1.3)

  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant