Closed msenn closed 6 years ago
Some print methods do not return their argument unchanged. For example:
library(ChainLadder) mcl <- MackChainLadder(RAA) # Printing changes it's argument mcl_print <- print(MackChainLadder(RAA)) identical(mcl, mcl_print) # Returns FALSE # Brackets change the assinged object (mcl_brackets <- MackChainLadder(RAA)) identical(mcl, mcl_brackets) # Returns FALSE # If object is assigned to a name before printing / brackets, results differ mcl_print2 <- print(mcl) identical(mcl_print, mcl_print2) # Returns TRUE (mcl_brackets2 <- mcl) identical(mcl_brackets, mcl_brackets2) # Returns FALSE
This behaviour can lead to confusion and is not in line with the print generic's documentation (?print):
print
?print
print prints its argument and returns it invisibly (via invisible(x))
invisible(x)
The behaviour I was expecting, illustrated with summary():
summary()
mtc_smry <- summary(mtcars) # Printing returns it's argument mtc_smry_print <- print(summary(mtcars)) identical(mtc_smry, mtc_smry_print) # Returns TRUE # Brackets have no impact (mtc_smry_brackets <- summary(mtcars)) identical(mtc_smry, mtc_smry_brackets) # Returns TRUE # No impact if object is assigned to a name before printing / brackets mtc_smry_print2 <- print(mtc_smry) identical(mtc_smry_print, mtc_smry_print2) # Returns TRUE (mtc_smry_brackets2 <- mtc_smry) identical(mtc_smry_brackets, mtc_smry_brackets2) # Returns TRUE
I am using the current GitHub version of ChainLadder. Here's my sessionInfo()
sessionInfo()
R version 3.5.0 (2018-04-23) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Red Hat Enterprise Linux Server 7.5 (Maipo) Matrix products: default BLAS: /opt/R/3.5.0/lib64/R/lib/libRblas.so LAPACK: /opt/R/3.5.0/lib64/R/lib/libRlapack.so locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 [4] LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C [10] LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] ChainLadder_0.2.6 loaded via a namespace (and not attached): [1] biglm_0.9-1 statmod_1.4.30 zoo_1.8-2 tidyselect_0.2.4 purrr_0.2.5 [6] reshape2_1.4.3 splines_3.5.0 haven_1.1.1 lattice_0.20-35 carData_3.0-1 [11] colorspace_1.3-2 stats4_3.5.0 yaml_2.1.19 rlang_0.2.1 pillar_1.2.3 [16] foreign_0.8-70 glue_1.3.0 tweedie_2.3.2 readxl_1.1.0 bindrcpp_0.2.2 [21] bindr_0.1.1 plyr_1.8.4 stringr_1.3.1 munsell_0.5.0 cplm_0.7-7 [26] gtable_0.2.0 cellranger_1.1.0 zip_1.0.0 expint_0.1-4 coda_0.19-1 [31] systemfit_1.1-22 rio_0.5.10 forcats_0.3.0 lmtest_0.9-36 curl_3.2 [36] Rcpp_0.12.17 scales_0.5.0 abind_1.4-5 ggplot2_3.0.0 stringi_1.2.3 [41] openxlsx_4.1.0 dplyr_0.7.6 grid_3.5.0 tools_3.5.0 sandwich_2.4-0 [46] magrittr_1.5 lazyeval_0.2.1 tibble_1.4.2 car_3.0-0 pkgconfig_2.0.1 [51] MASS_7.3-50 Matrix_1.2-14 data.table_1.11.4 actuar_2.3-1 assertthat_0.2.0 [56] minqa_1.2.4 R6_2.2.2 nlme_3.1-137 compiler_3.5.0
Issue
Some print methods do not return their argument unchanged. For example:
This behaviour can lead to confusion and is not in line with the
print
generic's documentation (?print
):Expected behaviour
The behaviour I was expecting, illustrated with
summary()
:System info
I am using the current GitHub version of ChainLadder. Here's my
sessionInfo()