如果你能帮助我解决一个简单的问题:
我相信我的 ubuntu 机器自动安装了 R 3.6.0:当我输入:> R. 它说:
R version 3.6.0 (2019-04-26) -- "Planting of a Tree" Copyright (C) 2019 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bit)
但是,我需要使用 R 的早期版本,即 R 3.5,该版本已安装并运行在我的 Ubuntu 机器上,并且我可以在目录中看到很多文件夹(下面有一个长列表):
/home/bogdan/R/x86_64-pc-linux-gnu-library/3.5
请您建议我如何恢复到 R 3.5 而不是使用 R 3.6 。非常感谢,
波格丹
ps:~/R/x86_64-pc-linux-gnu-library/3.5 中的文件夹列表由 453 个元素组成。
abind/
acepack/
ALL/
alphahull/
amap/
annotate/
AnnotationDbi/
AnnotationFilter/
AnnotationForge/
apcluster/
ape/
aroma.light/
askpass/
assertthat/
backports/
base64enc/
bbmle/
beachmat/
beeswarm/
BH/
bibtex/
bindr/
bindrcpp/
Biobase/
BiocFileCache/
BiocGenerics/
biocGraph/
BiocInstaller/
BiocManager/
BiocNeighbors/
BiocParallel/
BiocStyle/
BiocVersion/
biocViews/
biomaRt/
Biostrings/
biovizBase/
bit/
bit64/
bitops/
bladderbatch/
blob/
bookdown/
brew/
broom/
BSgenome/
Cairo/
callr/
car/
carData/
Category/
caTools/
CCA/
CCP/
cellranger/
cellrangerRkit/
checkmate/
circlize/
cli/
clipr/
clisymbols/
coda/
colorspace/
combinat/
ComplexHeatmap/
contfrac/
corpcor/
corrplot/
cowplot/
crayon/
crosstalk/
cubature/
curl/
cvTools/
data.table/
DBI/
dbplyr/
DDRTree/
DelayedArray/
DelayedMatrixStats/
deldir/
densityClust/
DEoptimR/
desc/
DESeq/
DESeq2/
deSolve/
destiny/
devtools/
dichromat/
digest/
diptest/
distillery/
doBy/
docopt/
doParallel/
doRNG/
doSNOW/
dotCall64/
dplyr/
DropletUtils/
dtw/
dynamicTreeCut/
e1071/
EDASeq/
edgeR/
ellipse/
ellipsis/
elliptic/
EnrichmentBrowser/
enrichR/
EnsDb.Hsapiens.v86/
EnsDb.Mmusculus.v79/
ensembldb/
evaluate/
extRemes/
fansi/
fastcluster/
fastICA/
fda/
fields/
fitdistrplus/
fit.models/
flexmix/
FNN/
forcats/
foreach/
formatR/
Formula/
fpc/
fs/
futile.logger/
futile.options/
gage/
gbRd/
gdata/
genefilter/
geneplotter/
generics/
GenomeInfoDb/
GenomeInfoDbData/
GenomicAlignments/
GenomicFeatures/
GenomicRanges/
GEOquery/
GetoptLong/
GGally/
ggbeeswarm/
ggbio/
ggdendro/
ggfortify/
ggplot2/
ggrepel/
ggridges/
ggthemes/
gh/
git2r/
githubinstall/
Glimma/
GlobalOptions/
glue/
gmodels/
GO.db/
goftest/
googleVis/
GOplot/
GOstats/
gplots/
graph/
graphite/
gridExtra/
GSA/
GSEABase/
gtable/
gtools/
hash/
haven/
HDF5Array/
hdf5r/
hexbin/
highr/
Hmisc/
hms/
HSMMSingleCell/
htmlTable/
htmltools/
htmlwidgets/
httpuv/
httr/
hwriter/
hypergeo/
ica/
igraph/
impute/
ini/
inline/
IRanges/
irlba/
iterators/
jsonlite/
kBET/
KEGGgraph/
KEGGREST/
kernlab/
knitr/
labeling/
laeken/
lambda.r/
lars/
later/
latticeExtra/
lazyeval/
limma/
Linnorm/
lle/
lme4/
Lmoments/
lmtest/
locfit/
loo/
lsei/
lubridate/
M3Drop/
magrittr/
maps/
maptools/
markdown/
MAST/
Matrix/
MatrixModels/
matrixStats/
mclust/
MCMCglmm/
memoise/
metap/
mime/
minqa/
mixtools/
mnormt/
mockery/
modelr/
modeltools/
moments/
monocle/
munsell/
Mus.musculus/
mvoutlier/
mvtnorm/
NADA/
nloptr/
npsurv/
numDeriv/
openssl/
openxlsx/
OrganismDbi/
org.Hs.eg.db/
org.Mm.eg.db/
orthopolynom/
ouija/
packrat/
pathview/
pbapply/
pbkrtest/
pcaMethods/
pcaPP/
pcaReduce/
penalized/
permute/
PFAM.db/
pheatmap/
pillar/
pkgbuild/
pkgconfig/
pkgload/
pkgmaker/
PKI/
plogr/
plotly/
pls/
plyr/
plyranges/
png/
polyclip/
polynom/
prabclus/
praise/
preprocessCore/
prettyunits/
processx/
progress/
promises/
ProtGenerics/
proxy/
pryr/
ps/
purrr/
qlcMatrix/
quantreg/
R6/
randomForest/
ranger/
RANN/
rappdirs/
RBGL/
rcmdcheck/
RColorBrewer/
Rcpp/
RcppAnnoy/
RcppArmadillo/
RcppEigen/
RcppProgress/
RCurl/
Rdpack/
readr/
readxl/
refGenome/
registry/
reldist/
rematch/
remotes/
ReportingTools/
reprex/
reshape/
reshape2/
reticulate/
Rgraphviz/
rhdf5/
Rhdf5lib/
rio/
rJava/
rjson/
RJSONIO/
rlang/
RMariaDB/
rmarkdown/
R.methodsS3/
Rmisc/
RMTstat/
rngtools/
robCompositions/
robust/
robustbase/
ROCR/
R.oo/
Rook/
rprojroot/
rrcov/
Rsamtools/
rsconnect/
RSQLite/
rstan/
rstudioapi/
rsvd/
rtracklayer/
Rtsne/
RUnit/
R.utils/
RUVSeq/
rvest/
S4Vectors/
safe/
SC3/
scales/
scater/
scatterplot3d/
scde/
scfind/
scImpute/
scmap/
SCnorm/
scran/
scRNAseq/
scRNA.seq.funcs/
SDMTools/
segmented/
selectr/
sessioninfo/
Seurat/
sgeostat/
shape/
shiny/
ShortRead/
SingleCellExperiment/
slam/
SLICER/
smoother/
snow/
snowfall/
sourcetools/
sp/
spam/
SparseM/
sparsesvd/
spatstat/
spatstat.data/
spatstat.utils/
SPIA/
splancs/
sROC/
StanHeaders/
statmod/
stringi/
stringr/
SummarizedExperiment/
sva/
sys/
tensor/
tensorA/
testthat/
tibble/
tidyr/
tidyselect/
tidyverse/
tinytex/
topGO/
trimcluster/
tripack/
truncnorm/
TSCAN/
tsne/
TTR/
TxDb.Mmusculus.UCSC.mm10.ensGene/
TxDb.Mmusculus.UCSC.mm10.knownGene/
UpSetR/
usethis/
utf8/
VariantAnnotation/
vcd/
vegan/
VennDiagram/
Vennerable/
venneuler/
VGAM/
VIM/
vipor/
viridis/
viridisLite/
WGCNA/
whisker/
withr/
WriteXLS/
xfun/
XML/
xml2/
xopen/
xtable/
xts/
XVector/
yaml/
zCompositions/
zip/
zlibbioc/
zoo
ps2:我该怎么做:
$apt-cache policy r-base
r-base:
Installed: 3.6.0-1xenial
Candidate: 3.6.0-2xenial
Version table:
3.6.0-2xenial 500
500 https://cloud.r-project.org/bin/linux/ubuntu xenial-cran35/ Packages
*** 3.6.0-1xenial 500
500 https://cloud.r-project.org/bin/linux/ubuntu xenial-cran35/ Packages
100 /var/lib/dpkg/status
3.5.3-1xenial 500
500 https://cloud.r-project.org/bin/linux/ubuntu xenial-cran35/ Packages
3.5.2-1xenial 500
500 https://cloud.r-project.org/bin/linux/ubuntu xenial-cran35/ Packages
3.5.1-2xenial 500
500 https://cloud.r-project.org/bin/linux/ubuntu xenial-cran35/ Packages
3.5.1-1xenial 500
500 https://cloud.r-project.org/bin/linux/ubuntu xenial-cran35/ Packages
3.5.0-1xenial 500
500 https://cloud.r-project.org/bin/linux/ubuntu xenial-cran35/ Packages
3.2.3-4 500
500 http://archive.ubuntu.com/ubuntu xenial/universe amd64 Packages
500 http://archive.ubuntu.com/ubuntu xenial/universe i386 Packages
答案1
首先,我们需要使用以下命令保存所有与 R 相关的包的列表:
dpkg -l | grep "^ii r-" > r_packages.txt
为了在 Ubuntu 16.04 LTS 上获取 R 3.5,我们需要添加 CRAN 存储库:
sudo add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu xenial-cran35/"
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9
sudo apt-get update
然后,我们需要使用一个长命令将 APT 调整为 CRAN 存储库的 R 3.5.x 版本的最高优先级:
cat <<EOF | sudo tee /etc/apt/preferences.d/pin-r35
Package: r-*
Pin: release a=xenial-cran35
Pin: version 3.5*
Pin-Priority: 800
Package: r-cran-nlme
Pin: release a=xenial-cran35
Pin: version 3.1.139-1xenial0
Pin-Priority: 800
Package: r-cran-cluster
Pin: release a=xenial-cran35
Pin: version 2.0.8-1xenial0
Pin-Priority: 800
EOF
清除所有 R 包(确保r_packages.txt
之前已保存):
sudo apt-get purge r-*
sudo apt-get autoremove
然后从已保存的列表中重新安装 R 包列表,r_packages.txt
同时使用以下命令在 3.6 版本上进行过滤:
sudo apt-get install $(cat r_packages.txt | grep "3.6" | awk '{print $2}')
并可选择安装所有软件包(即不带过滤器):
sudo apt-get install $(cat r_packages.txt | awk '{print $2}')
最后检查 R 版本是否为 3.5:
$ R R version 3.5.3 (2019-03-11) -- "Great Truth"
笔记:
- 我已经在干净的 Ubuntu 16.04 LTS VM 上检查了这种方法,并且安装了两个必备的 R 包 -
r-base
和r-base-dev
(以及它们的依赖项)。 - 如果您想恢复到 R 3.6 - 那么只需删除 pin/lock 文件
sudo rm /etc/apt/preferences.d/pin-r35
并运行sudo apt-get dist-upgrade
即可获取最新的依赖项。