I am using summary()
to generate simple summaries of date variables in a knitr
document and want to have the results nicely formatted.
summary(some_date)
produces the results I want (the values are displayed as dates) but it is not nicely formatted. So, I tried:
pander::pander(summary(some_date))
This produces nicely formatted results, but the values are displayed as integers instead of dates. (This is true for Date, POSIXct, and POSIXlt dates).
Is there some way to nicely format the results of a summary()
of dates in a knitr
document? Maybe there is some package other than pander
which is better for this task.
Examples below:
summary(some_date)
## Min. 1st Qu. Median Mean 3rd Qu.
## "2014-05-01" "2015-02-15" "2015-06-17" "2015-05-05" "2015-09-08"
## Max.
## "2015-11-21"
pander::pander(summary(some_date))
Min. 1st Qu. Median Mean 3rd Qu. Max.
16191 16481 16603 16560 16686 16760
sessionInfo()
## R version 3.2.3 (2015-12-10)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 14.04.3 LTS
##
## locale:
## [1] LC_CTYPE=en_AU.UTF-8 LC_NUMERIC=C
## [3] LC_TIME=en_AU.UTF-8 LC_COLLATE=en_AU.UTF-8
## [5] LC_MONETARY=en_AU.UTF-8 LC_MESSAGES=en_AU.UTF-8
## [7] LC_PAPER=en_AU.UTF-8 LC_NAME=C
## [9] LC_ADDRESS=C LC_TELEPHONE=C
## [11] LC_MEASUREMENT=en_AU.UTF-8 LC_IDENTIFICATION=C
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] pander_0.6.0 ggplot2_2.0.0 daff_0.1.4 magrittr_1.5 dplyr_0.4.3
## [6] readr_0.2.2
##
## loaded via a namespace (and not attached):
## [1] Rcpp_0.12.2 knitr_1.11 munsell_0.4.2 lattice_0.20-33
## [5] colorspace_1.2-6 R6_2.1.1 plyr_1.8.3 stringr_1.0.0
## [9] tools_3.2.3 parallel_3.2.3 grid_3.2.3 packrat_0.4.6-4
## [13] nlme_3.1-122 gtable_0.1.2 mgcv_1.8-7 DBI_0.3.1
## [17] htmltools_0.2.6 lazyeval_0.1.10 yaml_2.1.13 assertthat_0.1
## [21] digest_0.6.8 Matrix_1.2-3 formatR_1.2.1 curl_0.9.4
## [25] evaluate_0.8 rmarkdown_0.9 labeling_0.3 V8_0.9
## [29] stringi_1.0-1 scales_0.3.0 jsonlite_0.9.19
Thanks for the bug report, with the development version of pander
it should now render correctly:
> pander::pander(summary(as.Date('2015-01-01') + 1:100))
-----------------------------------------------------------------
Min. 1st Qu. Median Mean 3rd Qu. Max.
---------- ---------- ---------- ---------- ---------- ----------
2015-01-02 2015-01-26 2015-02-20 2015-02-20 2015-03-17 2015-04-11
-----------------------------------------------------------------
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With