首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Rmarkdown无法识别kable_styling命令中的内联

Rmarkdown无法识别kable_styling命令中的内联
EN

Stack Overflow用户
提问于 2021-02-22 02:31:17
回答 1查看 633关注 0票数 2

当我运行编织来编译kable_styling或Html时,我的Rmarkdown不能识别_。

我已经按照Yuhui的建议更新了包(包括tinytex和pandoc),并尝试编译成不同的R版本(3.6.3和4.0.4 - 64位)。

此外,我尝试安装ghostcript包,但没有找到与我的R版本匹配的版本。

这是来自错误的消息

代码语言:javascript
复制
I was unable to find any missing LaTeX packages from the error log projeto1v2.log.
! Missing $ inserted.
<inserted text> 
                $
l.227   kable_
              styling(full_width = FALSE,latex_options = "hold_position", ro...

Try to find the following text in projeto1v2.Rmd:
  kable_ 

You may need to add $ $ around a certain inline R expression ´r ´ in projeto1v2.Rmd (see the above
hint). See https://github.com/rstudio/rmarkdown/issues/385 for more info.
Erro: LaTeX failed to compile projeto1v2.tex. See https://yihui.org/tinytex/r/#debugging for
debugging tips. See projeto1v2.log for more info.
Além disso: Warning message:
In has_crop_tools() : 
Tool(s) not installed or not in PATH: ghostcript
-> As a result, figure cropping will be disabled.
Execução interrompida

一个可重复的例子:

代码语言:javascript
复制
library(kableExtra)
winelist <- data.frame(dados[1:12])

sumario <- round(sapply(dados, summary),2)
sumario <- t(sumario)

tabela1 <- data.frame(histograma="", sumario)

tabela1 %>%
kable(booktabs = TRUE) %>%
kable_styling(full_width = FALSE,latex_options = "hold_position", 
row_label_position='c', 
position='center') %>%
kable_paper(full_width = FALSE) %>%
column_spec(4, image = spec_hist(winelist))

来自Kaggle的数据集:Red Wine Quality

有人知道怎么纠正这个错误吗?

EN

回答 1

Stack Overflow用户

发布于 2021-02-22 04:10:57

你的代码对我来说工作得很好。刚刚将column_spec更改为2:

代码语言:javascript
复制
---
title: "Wine"
output: pdf_document
---

```{r setup, include=FALSE}

knitr::opts_chunk$set(echo =假,warning = FALSE,message =假)

代码语言:javascript
复制
```{r tabeladados}

库(Readr)

存档<- read_csv(“winequality_red /winequality-red.csv”)

dados <- winequality_red

库(KableExtra)

酒商<- data.frame(dados1:12)

sumario <- round(sapply(dados,summary),2)

sumario <- t(sumario)

tabela1 <- data.frame(histograma="",sumario)

tabela1 %>%

kable(booktabs = TRUE) %>%

kable_styling(full_width = FALSE,latex_options = "hold_position",

代码语言:javascript
复制
            row_label_position='c', 
代码语言:javascript
复制
            position='center') %>%

kable_paper(full_width = FALSE) %>%

column_spec(2,图像=spec_hist(葡萄酒列表))

代码语言:javascript
复制

-output

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66305686

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档