[英]! LaTeX Error: Environment threeparttable undefined
使用 R Markdown 創建 pdf 時出現此錯誤:
output file: NCERA-210_Results.knit.md
! LaTeX Error: Environment threeparttable undefined.
Error: Failed to compile NCERA-210_Results.tex. See NCERA-210_Results.log for more info.
In addition: There were 50 or more warnings (use warnings() to see the first 50)
Execution halted
我的代碼是:
---
title: "NCERA-210 Results"
author: "NAME"
date: "8/29/2018"
output: pdf_document
---
```{r setup, echo=FALSE, results="asis", message=FALSE, warning=FALSE}
# load packages
library("MOTE")
library("tidyverse")
library("broom")
library("ggpubr")
library("markovchain")
library("gmodels")
library("scales")
library("formattable")
library("rmarkdown")
library("knitr")
library("igraph")
library("papaja")
library("citr")
```
```{r, echo=FALSE, results="hide", message=FALSE, warning=FALSE,
fig.show="hide"}
source("Thesis_Code.R")
```
## Summary of Ratings
```{r 'Table Rating Count', echo=FALSE, message=FALSE, warning=FALSE, results="asis"}
apa_table(rating.dist,
caption = "Count of Ratings in Dataset")
```
## Plot of Rating Distribution
```{r 'Plot of Rating Distribution', echo=FALSE, message=FALSE, warning=FALSE, results="asis"}
ggplot(rating.dist,
aes(Rating, Count)) +
geom_col() +
ggtitle("Distribution of Ratings")
```
## Summary of Short Ratings
```{r 'Table Short Rating Count', echo=FALSE, message=FALSE, warning=FALSE, results="asis"}
apa_table(s_rating.dist,
caption = "Count of Short Ratings in Dataset")
```
## Plot of Short Rating Distribution
```{r 'Plot of Short Rating Distribution', echo=FALSE, message=FALSE, warning=FALSE, results="asis"}
ggplot(s_rating.dist,
aes(Short_Rating, Count)) +
geom_col() +
ggtitle("Distribution of Short Ratings")
```
## Summary of Co-op Location Distribution
```{r 'Co-op Distribution', echo=FALSE, message=FALSE, warning=FALSE, results="asis"}
apa_table(state.dist,
caption = "Location Distribution in Dataset")
```
## Plot of Co-op Distribution
```{r 'Plot of Co-op Distribution', echo=FALSE, message=FALSE, warning=FALSE, results="asis"}
ggplot(state.dist,
aes(State, Count)) +
geom_col() +
ggtitle("Distribution of Cooperatives Across the U.S.")
```
## Co-op Activity
```{r 'Co-op Activity Summary',echo=FALSE, message=FALSE, warning=FALSE, results="asis"}
apa_table(coop_activity,
caption = "Count of Co-ops by Activity")
```
## Co-op Sales Quartiles by Decade & Short Rating
```{r 'Sales Quartiles', echo=FALSE, message=FALSE, warning=FALSE, results="asis"}
apa_table(sales.qt,
caption = "Co-op Sales Quartiles by Decade & Short Rating")
```
## Co-op Liabilities by Decade & Short Rating
```{r 'Liabilities Quartiles', echo=FALSE, message=FALSE, warning=FALSE, results="asis"}
apa_table(liab.qt,
caption = "Co-op Liabilities Quartiles by Decade & Short Rating")
```
## Co-op Cash Patronage Paid by Decade & Short Rating
```{r 'Cash Patronage Paid Quartiles', echo=FALSE, message=FALSE, warning=FALSE, results="asis"}
apa_table(pat.paid,
caption = "Co-op Cash Patronage Paid Quartiles by Decade & Short Rating")
```
我正在使用 papaja 包來制作 APA 風格的手稿。 我可以使用 Rmd 腳本創建 word 文檔,但當輸出為 pdf_document 時出現該錯誤。 但是,我可以使用 papaja 模板“APA 文章(第 6 版)”創建手稿,但這條路線需要大量腳本編輯以刪除不必要的代碼。
我想這個問題與 threepartabble 有關,但我似乎找不到任何關於使用 R 的指導。我使用的是 Mac 並安裝了 MacTex。
修復是安裝“kableExtra”出於某種原因,如果沒有它,pdf 將無法呈現。
這個提議的解決方案似乎不再有效。
請參閱以下線程: LaTeX 錯誤:新解決方案的環境 ThreePartTable 未定義,這需要通過運行更新 RMarkdown:
remotes::install_github('rstudio/rmarkdown')
這將糾正 threeparttablex 乳膠包和 rmarkdown 之間的沖突。 您可能還必須運行以下命令來手動安裝軟件包,如tinytex 頁面中所述,如果 bookdown 不會自動執行此操作:
library(tinytex)
tlmgr_install('threeparttablex') # install the threeparttablex package
tlmgr_update() # update everything
最后,我發現有必要終止你的 R 會話並重新啟動,以便預訂 rmarkdown 包和更新的乳膠包可用。 之后,您可以使用 apa_table with results='as-is',例如:
```{r apatable, results='asis'}
apa_table(head(iris, 20), caption = 'Here is a nice table!')
```
而且,bookdown 還將處理標簽,就像它處理自己的基於 knitr::kable 的表一樣。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.