如何在Rmd中的xtable中添加复选标记。用于创建pdf的文件

时间:2017-02-20 21:56:33

标签: r latex knitr r-markdown xtable

我知道我在这里非常挑剔,但我正在使用以下代码在r markdown中使用knitr创建一个表:

---
title: "Test table"
author: "Derek Corcoran"
date: "February 20, 2017"
output: pdf_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

## Tables

This is a $\psi$

```{r, results='asis', echo = FALSE}
library(xtable)
Softwares <- structure(list(X = structure(c(9L, 5L, 7L, 4L, 1L, 8L, 6L, 2L, 
3L), .Label = c("Alpha diversity models", "Build in model selection", 
"Built in response plot", "Multiple Species Abundance", "Multiple Species Single Season occupancy", 
"Priority area selection", "Single Species Abundance", "Single Species Dynamic occupancy", 
"Single Species Single Season occupancy"), class = "factor"), 
Diversityoccupancy = structure(c(1L, 1L, 1L, 1L, 1L, NA, 
1L, 1L, 1L), .Label = "x", class = "factor"), Unmarked = structure(c(1L, 
NA, 2L, NA, NA, 2L, NA, NA, NA), .Label = c("$\\checkmark$", 
"x"), class = "factor"), stocc = structure(c(1L, NA, NA, 
NA, NA, NA, NA, NA, NA), .Label = "x", class = "factor"), 
Presence = structure(c(1L, NA, 1L, NA, NA, 1L, NA, NA, NA
), .Label = "x", class = "factor"), Pom = structure(c(1L, 
NA, NA, NA, NA, NA, NA, NA, NA), .Label = "x", class = "factor"), 
camptrapR = structure(c(1L, NA, NA, NA, NA, NA, NA, NA, NA
), .Label = "x", class = "factor")), .Names = c("X", "Diversityoccupancy", 
"Unmarked", "stocc", "Presence", "Pom", "camptrapR"), class = "data.frame", row.names = c(NA, 
-9L))

names <- colnames(Softwares[,-1])
colnames(Softwares) <- c("", names)
print(xtable(Softwares, align = rep("c", 8)), scalebox='0.75')
```

我将函数应用的所有值都作为 x ,但我想将其更改为复选标记。正如您在第一部分中看到的那样,我不是代码,而是放This is a $\psi$,它会转换为您在乳胶文档中所期望的内容。但是,当我将 x 更改为 $ \ checkmark $ 时,会在this链接中建议。它在表格中保持这种状态,如下图所示:

enter image description here

如何将其更改为复选标记?

1 个答案:

答案 0 :(得分:2)

将您的通话更改为xtable()

print(xtable(Softwares, align = rep("c", 8)), scalebox='0.75',
type = "latex", sanitize.text.function = function (x) x)