R小技巧彙總

Life·Intelligence發表於2024-11-20

一個R lib資料夾,最好就裝一個版本的R packages,因為不同版本存在相容性問題。

偶然間我把新版本裝到了舊版本里,產生了相容性問題。

用以下程式碼重灌就行

GPT神器,問題如下:

  • how to list R package that build under specific version of R?
  • how to reinstall these packages?
installed <- installed.packages()
built_under <- installed[installed[, "Built"] == "4.4.1", ]
built_under[, c("Package", "Built")]

specific_version <- installed[installed[, "Built"] == "4.4.1", ]
packages_to_reinstall <- specific_version[, "Package"]

install.packages(packages_to_reinstall)

  

相關文章