How to put a newline into a column header in an xtable in R

后端 未结 2 888
没有蜡笔的小新
没有蜡笔的小新 2021-01-31 10:34

I have a dataframe that I am putting into a sweave document using xtable, however one of my column names is quite long, and I would like to break it over two lines to save space

2条回答
  •  孤城傲影
    2021-01-31 11:31

    @Sharpie 's technique did not work for me, as pandoc failed with error 43 on conversion to pdf. Therefore, here is what I did:

    moved the \\centering marker:

    names(calqc_table)=c(rep("\\multicolumn{1}{p{0.75in}}{\\centering Identifier of the Run within the Study}", 6))
    

    (here applied to all 6 columns of the table)

    and disabled sanitization in xtable printing:

    print(calqc_table, sanitize.colnames.function=function(x){x})
    

提交回复
热议问题