首页 > 解决方案 > 如何在忽略内部生成的索引的同时使用`boot`

问题描述

标签: rstatistics-bootstrap

解决方案


你有一个 XY 问题。无需尝试覆盖索引,只需使用tidyr's new nest/unnest 功能来进行集群引导,如下所示:

dNest = d %>% group_nest(cluster)
boot( data = dNest, 
      statistic = function(original, indices) {
        bNest = original[indices,]
        # "data" is an automatically generated column name in dNest 
        b = bNest %>% unnest(data)
        return( my_stat(b) ) } )

或者,为了在集群引导之外获得更大的灵活性,您可以boot从自己的重新采样中创建一个假对象。


推荐阅读