首先请设置R返回的报错与提示语言为英文,:
Sys.setenv(LANGUAGE = "en")
为什么要设置?见:为什么你的R语言不能默认显示英文呢
例如:
检查是否有error,没有就忽略
关键词是there is no package called,例如: Error in library(Seurat) : there is no package called ‘Seurat’ 解决办法是缺啥补啥,安装报错的这个包
关键词是 could not find function,例如: Error in Read10X("01_data/") : could not find function "Read10X"
例如:
> install.packages("idmap1")
Installing package into ‘C:/Users/win10/AppData/Local/R/win-library/4.3’
(as ‘lib’ is unspecified)
Warning in install.packages :
package ‘idmap1’ is not available for this version of R
A version of this package for your version of R might be available elsewhere,
see the ideas at
https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages
这个包不出自cran,所以不能用install.packages安装。 这个问题虽然是warning,但紧接着library就会报错,也就是安装失败,因此需要解决。
原因1:包名写错 原因2:安装命令使用错误,企图用install.packages安装bioconductor 的包 原因3:本机的R语言版本与包所要求的版本不符(极少)
例如matrix:R语言4.3该考虑更新了,或者也可以…
原因4:包被淘汰了
例如:装R包,被网络给制住了?
问题3中提到了R version,下面这个提示信息里也有,虽然被提到了,但R语言版本并没有问题,无需解决
> library(devtools)
Loading required package: usethis
Warning message:
package ‘usethis’ was built under R version 4.3.3
> BiocManager::install("limma")
'getOption("repos")' replaces Bioconductor standard
repositories, see 'help("repositories", package =
"BiocManager")' for details.
Replacement repositories:
CRAN: https://mirrors.tuna.tsinghua.edu.cn/CRAN/
Bioconductor version 3.18 (BiocManager 1.30.23), R 4.3.2
(2023-10-31 ucrt)
Installing package(s) 'limma'
trying URL 'https://mirrors.westlake.edu.cn/bioconductor/packages/3.18/bioc/bin/windows/contrib/4.3/limma_3.58.1.zip'
Content type 'application/zip' length 3068016 bytes (2.9 MB)
downloaded 2.9 MB
package ‘limma’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\win10\AppData\Local\Temp\RtmpqAIbRB\downloaded_packages
Installation paths not writeable, unable to update packages
path: C:/Program Files/R/R-4.3.2/library
packages:
KernSmooth, lattice
Old packages: 'backports', 'biglm', 'cli', 'correlation',
'datawizard', 'DBI', 'digest', 'downlit', 'dqrng',
'DynNom', 'evaluate', 'geepack', 'genekitr', 'ggfun',
'ggsci', 'glue', 'googleAuthR', 'hardhat', 'highr',
'Hmisc', 'HPO.db', 'insight', 'jmv', 'jstable', 'knitr',
'lavaan', 'leaps', 'markdown', 'mc2d', 'mvtnorm', 'nlme',
'paradox', 'performance', 'prediction', 'quantreg',
'rapiclient', 'RcppArmadillo', 'reticulate', 'rio',
'rlang', 'rms', 'RSQLite', 'scatterpie', 'SparseM',
'spData', 'spdep', 'survival', 'textshaping', 'tinyarray',
'vctrs', 'vegan', 'xfun', 'xts'
Update all/some/none? [a/s/n]:
n
推荐选n,紧接着library(limma)会发现没有报错,就是安装成功了。 如果选n,紧接着library(limma)会发现报错,就是安装失败了,只能再次运行上面的安装代码BiocManager::install("limma"),再次提问时选a。
关键词是is already loaded或者是is not exported by
library(EBImage)
Error in loadNamespace(i,c(ib.1oc,.libPaths()),versioncheck =v[[i]]):
namespace 'htmltools'0.5.7 is already loaded, but >= 0.5.8 is required
install.packages("celldex_1.14.0.tar.gz",repos = NULL)
Error: object 'altReadObject' is not exported by 'namespace:alabaster.base'
Execution halted
解决办法是安装报错的包,如果没啥特殊情况(例如报错的包实际上已经被移除),直接安装就会给你装最新版本。 第一步,取消加载:
第二步:重启 正上方菜单栏-session-restart R
第三步 :装包,根据包来自哪个网站(很容易搜到),决定使用install.packages或者是BiocManager::install
关键词是 connection,internet,url、404、http,download 可能的原因和解决办法
注意:用options代码完成镜像设置,在你的Rstudio窗口关闭再重新打开后就需要重新设置,不是永久的。设没设置镜像可以看安装时提示的网址。例如:
关键词是 not writable和 Permission denied 只有windows会遇到。解决办法是管理员方式重新打开Rstudio,重新运行代码
或者是设置R语言和Rstudio的权限,略复杂,要看视频了 https://www.bilibili.com/video/BV1J44y1R7ci/