有的时候的R包总是安装不上,版本错误,环境错误,一大堆,比如seurat包,但是那个时候只记得install.packages了,R包安装的所有方法学习完,基本上解决了大部分包的安装。
镜像设置
初级
这个我之前都不知道,之后是看了张敬信老师的课件设置了一写,但是设置镜像也会遇到问题,比如一些生信有关的包
可以用下面的代码检验
options()$repos
升级模式-自定义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#检查是否设置成功
高级模式
不需要再次复制之前的代码,需要用到R的配置文件
.Rprofile :代码文件,配置多种多样
.Rvenviron :设置R的环境变量
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个基础函数
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()#当列名以变量的形式储存
#arrange
arrange(test, Sepal.Length)#默认从小到大排序
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))
今天的学习就结束了!