安装后无法加载 kableExtra

Can't Load kableExtra After Installation

如果我可以更好地格式化,我提前道歉 - 我是 Stack Overflow 的新手。我正在尝试安装 kableExtra 包。虽然我能够安装它,但在尝试加载包时我不断收到此错误消息。我该如何解决这个问题?

install.packages("kableExtra", dependencies = TRUE)
library(kableExtra)
Error: package or namespace load failed for ‘kableExtra’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/Users/tirdodbehbehani/Library/R/3.6/library/systemfonts/libs/systemfonts.so':
  dlopen(/Users/tirdodbehbehani/Library/R/3.6/library/systemfonts/libs/systemfonts.so, 6): Library not loaded: /opt/X11/lib/libfreetype.6.dylib
  Referenced from: /Users/tirdodbehbehani/Library/R/3.6/library/systemfonts/libs/systemfonts.so
  Reason: image not found
In addition: Warning message:
package ‘kableExtra’ was built under R version 3.6.2 
sessionInfo()

R version 3.6.1 (2019-07-05)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Catalina 10.15.7

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] rlang_0.4.11 hms_1.1.0   

loaded via a namespace (and not attached):
 [1] pillar_1.6.1      compiler_3.6.1    tools_3.6.1       digest_0.6.27    
 [5] evaluate_0.14     lifecycle_1.0.0   tibble_3.1.2      pkgconfig_2.0.3  
 [9] DBI_1.1.1         rstudioapi_0.13   yaml_2.2.1        xfun_0.24        
[13] dplyr_1.0.6       httr_1.4.2        stringr_1.4.0     knitr_1.33       
[17] xml2_1.3.2        generics_0.1.0    vctrs_0.3.8       tidyselect_1.1.1 
[21] glue_1.4.2        R6_2.5.0          fansi_0.5.0       rmarkdown_2.9.1  
[25] purrr_0.3.4       magrittr_2.0.1    scales_1.1.1      ellipsis_0.3.2   
[29] htmltools_0.5.1.1 assertthat_0.2.1  rvest_1.0.0       colorspace_2.0-2 
[33] utf8_1.2.1        stringi_1.6.2     munsell_0.5.0     crayon_1.4.1

您的 systemfonts 软件包副本似乎已损坏。您可以尝试在安装 kableExtra 之前重新安装它,但它可能会安装失败,因为您似乎还缺少 /opt/X11/lib/libfreetype.6.dylib 动态库。您可能需要安装它:但我不能建议如何在不了解您的系统的情况下安装它。

您编辑了问题以包含 运行ning sessionInfo() 的结果;谢谢!这告诉我的是,您正在 运行ning Mac: 所以您将安装 XQuartz 以获取 X11 库。我认为这应该让你 libfreetype.

我也看到你是运行ning R version 3.6.1。那是 2 岁的,当前的软件包可能不可用。保持最新通常是个好主意,最近发布了 R 4.1.0,因此我建议更新到该版本。在更新之前,运行 pkgnames <- rownames(installed.packages(priority = "NA")); dput(pkgnames) 并将结果保存到文件中。然后更新R,并且运行

pkgnames <- [ the long string you saved ]
install.packages(pkgnames)

安装您正在使用的任何贡献包的最新版本。