R语言基础3

下载、加载R包万能代码

rm(list = ls())
options()repos options()BioC_mirror
options(BioC_mirror="http://mirrors.tuna.tsinghua.edu.cn/bioconductor/")
options("repos" = c(CRAN="https://mirrors.tuna.tsinghua.edu.cn/CRAN/"))
options()repos options()BioC_mirror
if (!requireNamespace("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("DESeq2",ask = F,update = F)

dplyr五个基础函数

mutate(data, new = )#新增列
select(test,列名或列的向量)#按照列名列号筛选列
filter(test, 某列名 == ?)#按列的条件筛选行
arrange(test, Sepal.Length)#默认按照Sepal.Length列大小从小到大排
arrange(test, desc(Sepal.Length))#用desc从大到小
summarise(test, mean(Sepal.Length), sd(Sepal.Length))# 计算Sepal.Length的平均值和标准差

使用技能

count统计某列的unique值:

count(test,Species)

管道操作 %>% (cmd/ctr + shift + M):

test %>%
group_by(Species) %>%
summarise(mean(Sepal.Length), sd(Sepal.Length))

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容