我对重采样列表应用了 RNN,五分之三的列表没有产生预测,并且想要删除空列表。
# A tibble: 5 x 3
splits id predict
<list> <chr> <list>
1 <split [24/12]> Slice1 <tibble [48 × 3]>
2 <split [24/12]> Slice2 <tibble [48 × 3]>
3 <split [24/12]> Slice3 <lgl [1]>
4 <split [24/12]> Slice4 <lgl [1]>
5 <split [24/12]> Slice5 <lgl [1]>
因此尝试使用discard() 或Filter() 删除列表3、4、5,但我未能从小标题中删除列表。
> discard(sample_predictions, ~nrow(.) == 0)
Error: Predicate functions must return a single `TRUE` or `FALSE`, not a logical vector of length 0
Backtrace:
1. purrr::discard(sample_predictions, ~nrow(.) == 0)
2. purrr:::probe(.x, .p, ...)
3. purrr::map_lgl(.x, .p, ...)
4. purrr:::.f(.x[[i]], ...)
> Filter(function(x) dim[x]>0,sample_predictions )
Error in dim[x] : object of type 'builtin' is not subsettable