配置Rstudio的下载镜像
- 初级模式
在R软件tool
目录下Global options
选择Packages
单元将Primary CRAN repository
修改为中国的清华镜像。
(但是这个是CRAN的镜像,如果要下载Bioconductor的包,这个镜像是没有办法用的;另外即使设置了这里,Rstudio也不是每次都能真的从CRAN去下载包,可以通过options()$repos
来检验,很多时候还是无奈地回到了R的国外官网,速度超慢😛)(参考;生信星球学习小组,Day6) - 升级模式
# options函数就是设置R运行过程中的一些选项设置
options("repos" = c(CRAN="https://mirrors.tuna.tsinghua.edu.cn/CRAN/")) #对应清华源
options(BioC_mirror="https://mirrors.ustc.edu.cn/bioc/") #对应中科大源
# 当然可以换成其他地区的镜像
学习R包
R包的安装
- 确定所需安装的包在CRAN还是在Biocductor。(谷歌搜索)
2.安装包
>install.packages("包")
>BioManager::install("包")
R包的加载
>library(ggplot2)
>requir(ggplot2)
dplyr五个基础函数
- mutate(),新增列
-
select(),按列筛选
筛选列
- dplyr两个使用函数
3.1 管道操作%>%(Ctrl+Shift+M
)
image.png
3.2 count()统计某列
image.png
dplyr处理关系数据
1.內连inner_join,取交集

2.左连left_join

3.全连full_join
注;全连接是连接的两个数据框需含有相同列,如by=‘x’


4.半连接:返回能够与y表匹配的x表所有记录semi_join

5.反连接:返回无法与y表匹配的x表的所记录anti_join

6.简单合并
注意:变量(x,y,i,o,)的不同所组成的数据框的差异!!!
bind_rows()
函数需要两个表格列数相同,而bind_cols()
函数则需要两个数据框有相同的行数


网友评论