xtable() を使用した Rmarkdown チャンクが LaTeX テーブルのレンダリングを停止しました

xtable() を使用した Rmarkdown チャンクが LaTeX テーブルのレンダリングを停止しました

論文の .pdf 結果セクションを編むために使用するデータ分析 Rmarkdown ファイルがあります。今朝、Rstudio でニット ボタンを使用して PDF を編んだとき、美しく機能する LaTeX テーブル コードがありました。しかし、どうやら壊れてしまったようです。常に次のエラーと出力が表示されます: error in as.string(y) : Cannot coerce argument to a stringCalls: <Anonymous> ... print -> print.xtable -> +.string -> paste -> as.string

データフレームclass(df)を読み取り、例を[1] "data.table" "data.frame"呼び出した後にエラーが発生します。sum_table

私が試したこと:

  • xtable() および print() 関数への追加を 1 つずつ削除して、非常にシンプルな形式に戻します。
  • 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

関連情報