Skip to content

pluck() converts zero-length objects to NULL #480

@VincentGuyader

Description

@VincentGuyader

HI,

Hello I noticed something that seems strange to me. Dont know if it's a bug, but I dont understand the result.
map("result") return somthing wrong (to me), but map(~.x$result) is OK

this is a minimal example :

library(purrr)
> Warning: le package 'purrr' a été compilé avec la version R 3.4.4
list(list(result=data.frame(),error=1)) %>% map("result") 
> [[1]]
> NULL   # WHY ?
list(list(result=data.frame(),error=1)) %>%  map(~`$`(.x,"result"))
> [[1]]
> data frame with 0 columns and 0 rows
list(list(result=data.frame(),error=1)) %>%  map(~.x$result)
> [[1]]
> data frame with 0 columns and 0 rows

Any idea why ?

Regards

> sessionInfo()
R version 3.4.3 (2017-11-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=French_France.1252  LC_CTYPE=French_France.1252   
[3] LC_MONETARY=French_France.1252 LC_NUMERIC=C                  
[5] LC_TIME=French_France.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] shiny_1.0.5     bindrcpp_0.2    forcats_0.3.0   stringr_1.3.0   dplyr_0.7.4    
 [6] purrr_0.2.4     readr_1.1.1     tidyr_0.8.0     tibble_1.4.2    ggplot2_2.2.1  
[11] tidyverse_1.2.1 tictoc_1.0      cleanser_0.1   

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.16      lubridate_1.7.2   lattice_0.20-35   rprojroot_1.3-2  
 [5] assertthat_0.2.0  digest_0.6.15     psych_1.7.8       mime_0.5         
 [9] R6_2.2.2          cellranger_1.1.0  plyr_1.8.4        backports_1.1.2  
[13] reprex_0.1.2      evaluate_0.10.1   httr_1.3.1        pillar_1.2.1     
[17] rlang_0.2.0       settings_0.2.4    lazyeval_0.2.1    readxl_1.0.0     
[21] miniUI_0.1.1      rstudioapi_0.7    callr_2.0.2       whisker_0.3-2    
[25] R.utils_2.6.0     R.oo_1.21.0       rmarkdown_1.9     devtools_1.13.5  
[29] shinyjs_1.0       foreign_0.8-69    munsell_0.4.3     broom_0.4.3      
[33] validate_0.2.0    compiler_3.4.3    httpuv_1.3.6.2    modelr_0.1.1     
[37] pkgconfig_2.0.1   mnormt_1.5-5      htmltools_0.3.6   crayon_1.3.4     
[41] withr_2.1.2       R.methodsS3_1.7.1 grid_3.4.3        nlme_3.1-131     
[45] jsonlite_1.5      xtable_1.8-2      gtable_0.2.0      magrittr_1.5     
[49] scales_0.5.0      debugme_1.1.0     cli_1.0.0         stringi_1.1.7    
[53] reshape2_1.4.3    xml2_1.2.0        tools_3.4.3       glue_1.2.0       
[57] hms_0.4.2         parallel_3.4.3    yaml_2.1.18       colorspace_1.3-2 
[61] simplemagic_0.1.0 rvest_0.3.2       memoise_1.1.0     knitr_1.20       
[65] bindr_0.1.1       haven_1.1.1 

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behaviorpluck 🍐

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions