UUPharmacometrics / xpose

Graphical diagnostics for pharmacometric models
https://uupharmacometrics.github.io/xpose
GNU Lesser General Public License v3.0
55 stars 28 forks source link

`filter` function not assigning `xpose_data` class to the return object, issue with recent tidyverse? #115

Closed yoshidk6 closed 6 years ago

yoshidk6 commented 6 years ago

I recently updated the tidyverse package and found that filter function seems to return object without xpose_data class assigned. It can be worked around it by manually adding xpose_data class to the returned object but it would be nice if we don't need to.

Comparing session info though, I'm not sure what is causing this, as dplyr or rlang versions are the same. Unlikely but possibly the recent ggplot2 major update had something to do with it?

Let me know if you need any other information.

a <-  filter(xpdb, ARM==1)

class(a)
#[1] "uneval"

str(a)
# List of 7
# $ code    :Classes ‘nm_model’, ‘tbl_df’, ‘tbl’ and 'data.frame':  746 obs. of  5 variables:
#   ..$ problem   : int [1:746] 0 0 1 1 1 1 1 1 1 1 ...
# ..$ level     : int [1:746] 0 0 1 2 2 3 3 4 4 4 ...
# ..$ subroutine: chr [1:746] "oth" "oth" "pro" "inp" ...
# ..$ code      : chr [1:746] "Fri 08/31/2018 " "03:43 PM" " "ID ARM TIME DV TRT STUD" ...
# ..$ comment   : chr [1:746] "" "" "" "" ...
# ..- attr(*, "file")= chr "run33.lst"
# ..- attr(*, "dir")= chr "run33"
# ..- attr(*, "software")= chr "nonmem"
# $ summary :Classes ‘tbl_df’, ‘tbl’ and 'data.frame':  30 obs. of  5 variables:
# ...

Here is the current session info:

# sessionInfo()
# R version 3.4.3 (2017-11-30)
# Platform: x86_64-w64-mingw32/x64 (64-bit)
# Running under: Windows 7 x64 (build 7601) Service Pack 1
# 
# Matrix products: default
# 
# locale:
# [1] LC_COLLATE=English_United States.1252 
# [2] LC_CTYPE=English_United States.1252   
# [3] LC_MONETARY=English_United States.1252
# [4] LC_NUMERIC=C                          
# [5] LC_TIME=English_United States.1252    
# 
# attached base packages:
# [1] stats     graphics  grDevices utils     datasets  methods  
# [7] base     
# 
# other attached packages:
# [1] bindrcpp_0.2.2  lubridate_1.7.4 forcats_0.3.0   stringr_1.3.1  
# [5] dplyr_0.7.4     purrr_0.2.4     readr_1.1.1     tidyr_0.8.0    
# [9] tibble_1.4.2    tidyverse_1.2.1 xpose_0.4.2     ggplot2_3.0.0  
# [13] usethis_1.3.0   testthat_2.0.0  devtools_1.13.5
# 
# loaded via a namespace (and not attached):
# [1] tidyselect_0.2.4 reshape2_1.4.3   haven_1.1.1      lattice_0.20-35 
# [5] colorspace_1.3-2 yaml_2.1.19      rlang_0.2.0      pillar_1.2.2    
# [9] foreign_0.8-69   glue_1.2.0       withr_2.1.2      tweenr_0.1.5    
# [13] modelr_0.1.2     readxl_1.1.0     bindr_0.1.1      plyr_1.8.4      
# [17] munsell_0.4.3    gtable_0.2.0     cellranger_1.1.0 rvest_0.3.2     
# [21] psych_1.8.4      memoise_1.1.0    knitr_1.20       parallel_3.4.3  
# [25] broom_0.4.4      Rcpp_0.12.16     udunits2_0.13    scales_0.5.0    
# [29] backports_1.1.2  jsonlite_1.5     mnormt_1.5-5     ggforce_0.1.1   
# [33] hms_0.4.2        digest_0.6.15    stringi_1.2.2    grid_3.4.3      
# [37] cli_1.0.0        tools_3.4.3      magrittr_1.5     lazyeval_0.2.1  
# [41] crayon_1.3.4     pkgconfig_2.0.1  MASS_7.3-47      xml2_1.2.0      
# [45] assertthat_0.2.0 httr_1.3.1       rstudioapi_0.7   R6_2.2.2        
# [49] units_0.5-1      nlme_3.1-131     compiler_3.4.3  

Here is the previous session info when the code was working:

# > sessionInfo()
# R version 3.4.3 (2017-11-30)
# Platform: x86_64-w64-mingw32/x64 (64-bit)
# Running under: Windows 7 x64 (build 7601) Service Pack 1
#
# Matrix products: default
#
# locale:
# [1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
# [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
# [5] LC_TIME=English_United States.1252    
#
# attached base packages:
# [1] stats     graphics  grDevices utils     datasets  methods   base     
# other attached packages:
# [1] bindrcpp_0.2.2  xpose_0.4.2     lubridate_1.7.4 forcats_0.3.0   stringr_1.3.1  
# [6] dplyr_0.7.4     purrr_0.2.4     readr_1.1.1     tidyr_0.8.0     tibble_1.4.2   
# [11] ggplot2_2.2.1   tidyverse_1.2.1 usethis_1.3.0   testthat_2.0.0  devtools_1.13.5
#
# loaded via a namespace (and not attached):
# [1] tidyselect_0.2.4 reshape2_1.4.3   haven_1.1.1      lattice_0.20-35 
# [5] colorspace_1.3-2 yaml_2.1.19      rlang_0.2.0      pillar_1.2.2    
# [9] foreign_0.8-69   glue_1.2.0       withr_2.1.2      tweenr_0.1.5    
# [13] modelr_0.1.2     readxl_1.1.0     bindr_0.1.1      plyr_1.8.4      
# [17] munsell_0.4.3    gtable_0.2.0     cellranger_1.1.0 rvest_0.3.2     
# [21] psych_1.8.4      memoise_1.1.0    labeling_0.3     knitr_1.20      
# [25] parallel_3.4.3   broom_0.4.4      Rcpp_0.12.16     udunits2_0.13   
# [29] scales_0.5.0     backports_1.1.2  jsonlite_1.5     mnormt_1.5-5    
# [33] ggforce_0.1.1    hms_0.4.2        digest_0.6.15    stringi_1.2.2   
# [37] grid_3.4.3       cli_1.0.0        tools_3.4.3      magrittr_1.5    
# [41] lazyeval_0.2.1   crayon_1.3.4     pkgconfig_2.0.1  MASS_7.3-47     
# [45] xml2_1.2.0       assertthat_0.2.0 httr_1.3.1       rstudioapi_0.7  
# [49] R6_2.2.2         units_0.5-1      nlme_3.1-131     compiler_3.4.3  
bguiastr commented 6 years ago

@yoshidk6 you are right the recent tidyverse update is now causing the custom object class to be dropped when this object is modified. The problem you are describing has been fixed in xpose 0.4.3 (I can see from your session info that you still use 0.4.2).

With xpose 0.4.3 I also added a convenience function as.xpdb() that you can use if for some reason you are trying to modify the xpdb object outside of xpose.

Hope it helps!

yoshidk6 commented 6 years ago

Sorry, I didn't know you already addressed this. Thanks a lot!