r - Change default alignment in pander (pandoc.table) -
i switching pander
of knitr-markdown
formatting, because provides such great pandoc
support. 1 of things not happy default center-alignment. marketing people may love it, technical reports horror.
the best choice used hmisc
use left alignment texts , dates default, , right alignment number of type.
is there simple way globally set in pander
?
library(pander) pander(data.frame( name = letters[1:3], size = 1:3, we.have.dates = sys.date() - 1:3 ))
thanks kind words , great question. there's not yet documented feature in pander
, can pass r function default table alignment. quick demo:
> panderoptions('table.alignment.default', + function(df) ifelse(sapply(df, is.numeric), 'right', 'left')) > pander(data.frame( + name = letters[1:3], + size = 1:3, + we.have.dates = sys.date() - 1:3 + )) ----------------------------- name size we.have.dates ------ ------ --------------- 1 2014-11-18 b 2 2014-11-17 c 3 2014-11-16 -----------------------------
so trick here define function takes 1 argument analysed, , returns vector of column alignment parameters.
Comments
Post a Comment