Inserting blank spaces at the end of a column name in a table using pander

試著忘記壹切 提交于 2019-12-24 16:35:44

问题


I am trying to find a way of centering a column heading in a pander table using knitr to pdf in rmarkdwon, but keeping the column entries right justified.

---
title: "Table Doc"
output: pdf_document
---



```{r table, echo = FALSE}

table1 <- anova(lm(Petal.Length ~ Species*Petal.Width, iris))

names(table1) <- c("DF", "Sum Sq", "Mean Sq", "*F*", "*p*")

library(pander)

pander(table1, justify = c("left", rep("right", 5)))

```

There is no way to align individual cells inside a table in pandoc apparently. I want the entries to be to the right so they are all aligned properly but sit the column headings 'F' and 'p' in the center. So what I need to do is insert blank spaces after F and p to force them into the center. How do I do this? I tried simply inserting the blank spaces:

names(table1) <- c("DF", "Sum Sq", "Mean Sq", "*F*    ", "*p*    ")

but the spaces are not recognised by pander.

I also tried LaTex spacing characters

names(table1) <- c("DF", "Sum Sq", "Mean Sq", "*F*\\", "*p*\\")

but this didn't work either. Can anyone think of a workaround?

来源:https://stackoverflow.com/questions/36253549/inserting-blank-spaces-at-the-end-of-a-column-name-in-a-table-using-pander

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!