解决R包的一些依赖包安装的问题:
# 根据R包依赖包进行安装----
install_packages_with_dependencies <- function(package_names) {
# Iterate through each package name
for (pkg in package_names) {
# Check dependencies
dependencies <- tools::package_dependencies(pkg, recursive = TRUE)
# Install dependencies first
if (length(dependencies) > 0) {
install.packages(dependencies)
}
# Install the package itself
install.packages(pkg)
}
}
packages_to_install <- c("ggplot2", "dplyr")
install_packages_with_dependencies(packages_to_install)
# R包安装的几种方式----
# 直接安装
install.packages("devtools")
install.packages("BiocManager",ask = F, update = F)
# BiocManager安装
install.packages("BiocManager")
BiocManager::install(package_name)
# github源安装,可以指定版本
devtools::install_github("MRCIEU/ieugwasr@v0.2.1")
devtools::install_github("MRCIEU/ieugwasr")
#本地源文件安装
install.packages('./R_Packages/gwasvcf-master/', repos = NULL, type = "source")
install.packages('./R_Packages/gwasglue-master/', repos = NULL, type = "source")
# 查看已安装版本----
packageVersion('TwoSampleMR') # 0.5.7
packageVersion('ieugwasr') # 0.1.5
installed.packages()["gtsummary", "Version"]
# 使用西湖大学镜像,比较好的镜像----
options("BioC_mirror" = "https://mirrors.westlake.edu.cn/bioconductor")
options("repos" = c(CRAN = "https://mirrors.tuna.tsinghua.edu.cn/CRAN/"))
options("BioC_mirror" = "http://mirrors.tuna.tsinghua.edu.cn/bioconductor/")