Warnings when knitting zero-row nested tibbles

When filtering a nested tibble down to zero rows (no match for the requested filter), printing that tibble in the context of a knit (either a html_notebook or html_document) is throwing a warning of

Warning messages: 1: In [<-.data.frame(tmp, is_list, value = list(11 = "<>")) : replacement element 1 has 1 row to replace 0 rows

The below reprex will generate the warning when embedded in a notebook and knitted to html_document. Any thoughts on where the best place to file this issue? I'm unsure as to whether this is a tidyverse (or what part of tidyverse), knitr, rmarkdown, or Rstudio issue. It was driving me batty just tracking it down and my brain is a bit mushy now. :slight_smile:

library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
mt_df <- mtcars %>% tidyr::nest(data = c(cyl))
mt_df %>% filter(disp == 6)
#> # A tibble: 0 x 11
#> # … with 11 variables: mpg <dbl>, disp <dbl>, hp <dbl>, drat <dbl>, wt <dbl>,
#> #   qsec <dbl>, vs <dbl>, am <dbl>, gear <dbl>, carb <dbl>, data <list>
mt_df %>% filter(disp == 999)
#> # A tibble: 0 x 11
#> # … with 11 variables: mpg <dbl>, disp <dbl>, hp <dbl>, drat <dbl>, wt <dbl>,
#> #   qsec <dbl>, vs <dbl>, am <dbl>, gear <dbl>, carb <dbl>, data <list>

Created on 2021-02-04 by the reprex package (v1.0.0)

Session info
sessionInfo()
#> R version 4.0.3 (2020-10-10)
#> Platform: x86_64-apple-darwin17.0 (64-bit)
#> Running under: macOS Big Sur 10.16
#> 
#> Matrix products: default
#> BLAS:   /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.dylib
#> LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
#> 
#> locale:
#> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] dplyr_1.0.2
#> 
#> loaded via a namespace (and not attached):
#>  [1] knitr_1.31       magrittr_2.0.1   tidyselect_1.1.0 R6_2.5.0        
#>  [5] rlang_0.4.10     fansi_0.4.1      stringr_1.4.0    styler_1.3.2    
#>  [9] highr_0.8        tools_4.0.3      xfun_0.19        utf8_1.1.4      
#> [13] cli_2.3.0        htmltools_0.5.0  ellipsis_0.3.1   assertthat_0.2.1
#> [17] yaml_2.2.1       digest_0.6.27    tibble_3.0.6     lifecycle_0.2.0 
#> [21] crayon_1.4.0     tidyr_1.1.2      purrr_0.3.4      vctrs_0.3.6     
#> [25] fs_1.5.0         glue_1.4.2       evaluate_0.14    rmarkdown_2.6   
#> [29] reprex_1.0.0     stringi_1.5.3    compiler_4.0.3   pillar_1.4.7    
#> [33] generics_0.1.0   backports_1.2.1  pkgconfig_2.0.3

I can reproduce. I believe this is an issue with the IDE with the code executing a chunk. I can't reproduce when Knitting a document - only when executing a chunk.

Did you already look for an existing issue in the IDE ? If none I believe you can open one.

Groovy. It looks like #7546 and #7562 are similar issues, but not quite the same. I'll create another issue. Sounds like nested tibbles are tricky in general!

1 Like

Issue https://github.com/rstudio/rstudio/issues/8898 opened for RStudio Desktop. It looks like a new stale issue policy has been implemented on the main RStudio repository, so anyone finding/experiencing this issue is urged to +1 the report so that this can be corrected!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.