Try   HackMD

目前使用的R套件列表與批次安裝指令

重灌系統、裝好 R 之後,總是只能憑記憶安裝套件,而且常常會在需要的時候才發現少裝了某套件,就要停下手邊的工作來安裝,多少會打亂工作節奏。因此,想把平常使用的套件記錄下來,之後如果又重新裝了 R 或者整個系統,就可以一次裝好。

在開始裝之前,我會先預設 CRAN mirror,在 R 資料夾的 etc 目錄底下,修改 Profile.site 檔案:

# set a CRAN mirror #Automatic redirection to servers worldwide, currently sponsored by Rstudio local({r = getOption("repos") r["CRAN"] = "https://cran.csie.ntu.edu.tw/" options(repos=r)})

以下微微修改自網路上找到的指令:

batchinstall <- function(pkg){ new.pkg <- pkg[!(pkg %in% installed.packages()[, "Package"])] if (length(new.pkg)) install.packages(new.pkg, dependencies = TRUE) sapply(pkg, require, character.only = TRUE) } batchinstall(pkgs)

只要把其中的 pkgs 填入自己要安裝的套件即可。安裝好之後,會列出安裝的各套件是否成功。
以下是自己常用的套件:

pkgs <- c("ade4", "adegenet", "ape", "Cairo", "dplyr", "data.table", "devtools", "e1071", "factoextra", "FactoMineR", "forecast", "ggplot2", "ggpubr", "ggrepel", "ggsci", "ggsignif", "ggthemes", "ggpmisc", "ggvenn", "gridExtra", "gtable", "Hmisc","indicspecies", "iNEXT", "insect", "lme4", "lmtest", "lubridate", "magrittr", "mgcv", "mlr3verse", "nlme", "openxlsx", "patchwork", "plotly", "plyr", "profvis", "psych", "purrr", "readxl", "reshape2", "rpart", "rstatix", "scales", "scatterplot3d", "showtext", "SpadeR", "SparseM", "stringi", "stringr", "tidyr", "vegan", "xgboost")

裝好 devtools 之後,就可以安裝位於 github 或者由 Bioconductor 收錄的套件:

devtools::install_github("vqv/ggbiplot") devtools::install_github("NightingaleHealth/ggforestplot") devtools::install_github("sinhrks/ggfortify") devtools::install_github("gavinsimpson/ggvegan") devtools::install_bioc(c("Biostrings", "dada2", "phyloseq", "DESeq2", "ShortRead"))

清單會隨時更新,以備未來的不時之需。
🐕‍🦺