Probably something along these lines, obviously replacing tbl
with employee_survey
...still untested.
scratch <- attr(tbl, "dimnames")
scratch$stype=paste(scratch$stype, "%")
scratch -> attr(tbl, "dimnames")
pandoc.table(tbl)
A somewhat similar process is possible on the cell contents. Again tested only on the example in ?svytable
:
ntbl <- as.character(round(tbl, 2))
ntbl <- paste(ntbl, "%")
attributes(ntbl) <- attributes(tbl)
ntbl
#---------------
stype
sch.wide E H M
No 406.16 % 101.54 % 270.78 %
Yes 4467.8 % 372.32 % 575.4 %
#-------------
pandoc.table(ntbl)
#----------------------------------
------------------------------------
E H M
--------- -------- -------- --------
**No** 406.16 % 101.54 % 270.78 %
**Yes** 4467.8 % 372.32 % 575.4 %
------------------------------------
Depending on how you want the significant digits displayed this is also possible:
ntbl <- format(round(tbl, 2),digits=5)
attributes(ntbl) <- attributes(tbl)
pandoc.table(ntbl)
-------------------------------
E H M
--------- ------- ------ ------
**No** 406.16 101.54 270.78
**Yes** 4467.80 372.32 575.40
-------------------------------