有的時(shí)候的R包總是安裝不上,版本錯(cuò)誤,環(huán)境錯(cuò)誤,一大堆,比如seurat包,但是那個(gè)時(shí)候只記得install.packages了,R包安裝的所有方法學(xué)習(xí)完,基本上解決了大部分包的安裝。
鏡像設(shè)置
初級(jí)
這個(gè)我之前都不知道,之后是看了張敬信老師的課件設(shè)置了一寫,但是設(shè)置鏡像也會(huì)遇到問題,比如一些生信有關(guān)的包
可以用下面的代碼檢驗(yàn)
options()$repos
升級(jí)模式-自定義CRAN和Bioconductor
options("repos" = c(CRAN="https://mirrors.tuna.tsinghua.edu.cn/CRAN/")) #清華源
options(BioC_mirror="https://mirrors.ustc.edu.cn/bioc/") #中科大源
options()$BioC_mirror#檢查是否設(shè)置成功
高級(jí)模式
不需要再次復(fù)制之前的代碼,需要用到R的配置文件
.Rprofile :代碼文件,配置多種多樣
.Rvenviron :設(shè)置R的環(huán)境變量
file.edit('~/.Rprofile')
ptions("repos" = c(CRAN="https://mirrors.tuna.tsinghua.edu.cn/CRAN/"))
options(BioC_mirror="https://mirrors.ustc.edu.cn/bioc/")
安裝
install.packages("")
BiocManager::install("")
#谷歌搜索去哪里安裝
加載
library()
require()
dplyr5個(gè)基礎(chǔ)函數(shù)
mutate(test, new =test[1]*test[2])#新增列
#按列
select(test,1)
select(test,c(1,5))
select(test,列名)
#篩選
filter(test,Species == "setosa")
filter(test,Species == "setosa"&Sepal.Length > 5)
filter(test, Species %in% c("setosa","versicolor"))
one_of()#當(dāng)列名以變量的形式儲(chǔ)存
#arrange
arrange(test, Sepal.Length)#默認(rèn)從小到大排序
arrange(test, desc(Sepal.Length))
#匯總
summarise(test, mean(Sepal.Length), sd(Sepal.Length))
group_by(test, Species)
summarise(group_by(test, Species),mean(Sepal.Length), sd(Sepal.Length))
今天的學(xué)習(xí)就結(jié)束了!