生信星球公众号:你还在每次配置Rstudio的下载镜像吗?
联网
R包安装命令是install.packages(“包”)#安装的包存在于CRAN网站
BiocManager::install(“包”)#安装的包存在于Biocductor
存在于哪里?可以谷歌搜到。
library和require,两个函数均可。使用一个包,是需要先安装再加载,才能使用包里的函数。
options("repos" = c(CRAN="https://mirrors.tuna.tsinghua.edu.cn/CRAN/"))
options(BioC_mirror="https://mirrors.ustc.edu.cn/bioc/")
#第一行第二行配置镜像
install.packages("dplyr")
#安装R包
`library(dplyr)
#`加载函数
test <- iris[c(1:2,51:52,101:102),]
#示例数据直接使用内置数据集iris的简化版1.mutate(),新增列mutate(test, new = Sepal.Length * Sepal.Width)
select(test,1)select(test,c(1,5))
vars <- c("Petal.Length", "Petal.Width")
select(test, one_of(vars))
filter(test, Species == "setosa")
filter(test, Species == "setosa"&Sepal.Length > 5 )
filter(test, Species %in% c("setosa","versicolor"))
arrange(test, Sepal.Length)#默认从小到大排序
arrange(test, desc(Sepal.Length))#用desc从大到小
summarise(test, mean(Sepal.Length), sd(Sepal.Length))# 计算Sepal.Length的平均值和标准差
group_by(test, Species)# 先按照Species分组
summarise(group_by(test, Species),mean(Sepal.Length), sd(Sepal.Length))#计算每组Sepal.Length的平均值和标准差
(加载任意一个tidyverse包即可用管道符号)
count(test,Species)
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。