Rotate a table from R markdown in pdf

前端 未结 3 1362
暗喜
暗喜 2021-01-04 00:28

I\'m writing in R Markdown and have a contingency table that is quite wide. I am converting the R markdown document to a PDF using pandoc.

Is it possible to rotate o

3条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-04 01:23

    Can you just use t()?

    library(xtable)
    xtable(t(iris[1:5,]))
    

    If your table is still to long, split it up into multiple tables. e.g.:

    splits = floor(seq(1, ncol(iris), length=5))
    for(i in 2:length(splits)){
     mini.tab = iris[ , splits[i-1]:splits[i]]
     xtable(mini.tab)
    }
    

提交回复
热议问题