On 2024-10-26 3:14 p.m., Cleber Borges via R-help wrote:
Hello everybody,

I'm trying to build a function to illustrate, in 2D, the sequence of the
"Single Link" algorithm (the purpose is merely didactic).

The idea is to have the scatter of points on a graph.
Iteratively, build the segments (with the "segments()" function, for
each step).

I simulated a data set "d", and created an object "r" using the command:

r <- hclust( dist( d ), met='single' )

My problem:

I created a recursive function, "f()", to find the shortest distances.
It is defined below.
But the return has only one column, while I thought there would be two
columns.


I suspect you used rbind() where you should have used cbind() in your f, here:

      return( rbind( rs, rbind( xmd1, xmd2 ) ) )

which should have been


  return( rbind( rs, cbind( xmd1, xmd2 ) ) )

There may be other places where this change is needed; I haven't tried running your code.

Duncan Murdoch

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide https://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to