[R] cutreeDynamic error

Peter Langfelder peter.langfelder at gmail.com
Wed Feb 27 08:21:28 CET 2013


On Tue, Feb 26, 2013 at 8:34 AM, Joanna Papakonstantinou
<joanna.papa at gmail.com> wrote:
> So I realized I had to convert my dd.daisy to a matrix and used:
> ddmatrix.daisy<-as.matrix(dd.daisy)
> and then I passed that in as the distM:
>> cutreeDynamic(as.hclust(dd.diana), cutHeight = NULL, minClusterSize = 2,
> method = "hybrid", distM = ddmatrix.daisy,deepSplit =
> (ifelse(method=="hybrid", 1, FALSE)),maxCoreScatter = NULL, minGap = NULL,
> maxAbsCoreScatter = NULL, minAbsGap = NULL,useMedoids = FALSE,
> maxDistToLabel = cutHeight,respectSmallClusters = TRUE, verbose = 2, indent
> = 0)
>
> However, now I am getting a different error:
>
>  Detecting clusters...
> ..cutHeight not given, setting it to 0.847  ===>  99% of the (truncated)
> height range in dendro.
> Error in ifelse(method == "hybrid", 1, FALSE) : object 'method' not found
>
> Anny suggestions on how to fix this?

Yes, leave out the 'deepSplit = (ifelse(method=="hybrid", 1, FALSE))'
from the call. This is not really a cutreeDynamic problem, it is a
perhaps somewhat confusing aspect of R language. If you don't specify
deepSplit, its default value will be evaluated within the function
'interior' where the variable 'method' is defined. If you do specify
deepSplit, the expression that you specify is evaluated from 'outside'
the function where the variable 'method' is undefined. Thus, the
seemingly same expression can lead to two different results.

In fact, you may want to leave out all arguments for which you are
using a default value, it will make your call shorter and less prone
to the type of error you just experienced.

HTH,

Peter



More information about the R-help mailing list