You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何为大型dendrogram对象创建可复现示例?

问题:dendrapply处理大型树状图时触发C栈溢出错误

我在处理名为dend的树状图(dendrogram)对象时遇到问题:使用自定义函数通过dendrapply遍历该对象时,触发了栈溢出错误。

自定义函数代码

positiveheights <- function(x){
    if(attributes(x)$height < 0){
        attributes(x)$height = 0.0001
    }
    x
}

dend = dendrapply(dend, positiveheights)

错误信息

Error: C stack usage 7969556 is too close to the limit

树状图对象信息

> dend
'dendrogram' with 2 branches and 20000 members total, at height 12.0029
> summary(dend)
     Length Class      Mode
[1,] 2      dendrogram list
[2,] 2      dendrogram list

我需要生成这个dend对象的可复现示例,但对象过大无法用dput()输出。类似生成大型矩阵可以用set.seed(123); matrix(rnorm(big_number)),那该如何创建具备关键特征(如分支高度、20000个成员规模)的可复现树状图示例?


内容的提问来源于stack exchange,提问作者user438383

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.24 18:22:40