[R] Help in Recursive Function for steps reconstruction in Clusters Analysis - HCA: Single Link
Duncan Murdoch
murdoch@dunc@n @end|ng |rom gm@||@com
Sat Oct 26 22:03:44 CEST 2024
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
More information about the R-help
mailing list