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

How to add a check mark to a xtable in an Rmd. file used to create a pdf

我知道我在这里很挑剔,但我正在 table 使用以下代码在 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 link 中被推荐。它在 table 中保持这种状态,如下图所示:

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

将您对 xtable() 的呼叫更改为:

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