安裝和加載R包
安裝
install.packages("xxx")存在于CRAN
BioManager::install("xxx")存在于BioManager
加載
library()或requires()
使用鏡像下載R包

image.png
dplyr包中的五個(gè)基礎(chǔ)函數(shù)
1.mutate()新增列
1.使用示例數(shù)據(jù):test <- iris[c(1:2,51:52.101:102)]
2.image.png
2.select()按列篩選
(1)select(test,1)選取第一列
(2)select(test,c(1,5))選取第一和第五列
(3)select(test,Petal.Length)或vars <- c("Petal.Length")+
select(test,one_of(vars))選取名叫Petal.Length的列
3.fliter()選取行
image.png

image.png
4.arrange()按某一列進(jìn)行排列

image.png
從小到大

image.png
從大到小
5.summarise()匯總
summarise(test,mean(Sepal.Length),sd(Sepal.Length))或
group_by(test,Species)
summarise(group_by(test,Sepal.Length),mean(Sepal.Length),sd(Sepal.Length))來算Spetal.Length的平均值和標(biāo)準(zhǔn)差
dplyr兩個(gè)實(shí)用技能
管道操作

image.png
count統(tǒng)計(jì)某列的種類相同的值

image.png
dplyr處理關(guān)系數(shù)據(jù)
1.inner_join取交集
2.左連left_join
3.全連full_join
4.半連semi_jion
5.反連anti_jion
6.簡單合并:blind_rows()要求列數(shù)相同
blind_cols()要求行數(shù)相同
