xtable()이 포함된 Rmarkdown 청크가 LaTeX 테이블 렌더링을 중지했습니다.

xtable()이 포함된 Rmarkdown 청크가 LaTeX 테이블 렌더링을 중지했습니다.

논문에 대한 .pdf 결과 섹션을 구성하는 데 사용할 데이터 분석 Rmarkdown 파일이 있습니다. 오늘 아침에 니트 버튼을 사용하여 Rstudio에서 PDF를 함께 니트할 때 LaTeX 테이블 코드가 아름답게 작동했습니다. 그런데, 깨뜨린 것 같더라고요. 지속적으로 다음과 같은 오류 및 출력이 발생합니다 error in as.string(y) : Cannot coerce argument to a string.Calls: <Anonymous> ... print -> print.xtable -> +.string -> paste -> as.string

내 데이터프레임을 class(df)읽고 예제를 [1] "data.table" "data.frame"호출한 후 오류가 발생합니다 .sum_table

내가 시도한 것:

  • xtable() 및 print() 함수에 대한 추가 사항을 하나씩 제거하여 매우 간단한 형식으로 되돌립니다.
  • Rmd 청크 대신 한 줄씩 코드를 실행합니다.
  • xtable()에 표시 인수 추가xtable 문서
  • xtable 및 R을 제거하고 다시 설치했습니다. MacOS 10.12.6(이전 컴퓨터), R 3.6.3 및 Rstudio 1.2.5033을 실행하고 있습니다.
  • booktabs=TRUEprint()에 인수를 추가했습니다 .xtable 예

이 오류나 문제 해결에 대한 아이디어가 있습니까?

간단한 Rmd 청크 예:

---
output: 
  pdf_document:
    fig_caption: yes
indent: true
---
# Rmd chunk settings
# results = 'asis' to output LaTex code that is recognized as code
{R Summary_Table, echo = FALSE, results = 'asis'}

library(knitr)
library(tinytex)
library(xtable)
options(xtable.timestamp = FALSE)

df <- data.frame(A = c(1:10),
                 B = c(11:20),
                 C = c(21:30))

sum_table <- xtable(df)
sum_table # Error thrown here "as.string(y) : Cannot coerce argument to a string"
print.xtable(sum_table)
# try another print function
print(sum_table)
# try adding booktabs argument
print(sum_table, booktabs = TRUE)

#Tried adding display argument to xtable(), extra for xtable's automatic
# number column. Thought maybe num variables couldn't be turned into a string? 
sum_table2 <- xtable(df, display = c("s","f","f","f"))
sum_table2

관련 정보