我知道我在这里非常挑剔,但我正在使用 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$
,它会转化为您在 latex 文档中所期望的内容。但是,当我将 x 更改为 $\checkmark$ 时,如 this 中推荐的那样关联。它在表中保持这种状态,如下图所示:
如何将其更改为复选标记?
最佳答案
将对 xtable()
的调用更改为:
print(xtable(Softwares, align = rep("c", 8)), scalebox='0.75',
type = "latex", sanitize.text.function = function (x) x)
关于r - 如何向 Rmd 中的 xtable 添加复选标记。用于创建 pdf 的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42354946/