繼續(xù)R語言--R包
一、安裝R包

安裝R包
二、實例--dplyr
#配置鏡像+安裝+加載
options("repos" = c(CRAN="https://mirrors.tuna.tsinghua.edu.cn/CRAN/"))
options(BioC_mirror="https://mirrors.ustc.edu.cn/bioc/")
install.packages("dplyr")
library(dplyr)
五個基礎(chǔ)函數(shù)
mutate()新增列
select()按列篩選
filter()篩選行
arrange()按列排序
summarise()匯總兩個使用技能
%<%管道操作
還不是很理解管道操作,再研究研究,??鏈接
count()統(tǒng)計某列的unique值處理關(guān)系數(shù)據(jù)
#將兩個表進(jìn)行連接
options(stringsAsFactors = F)
test1 <-tibble(x = c('b','e','f','x'),
z = c("A","B","C",'D'),
stringsAsFactors = F)
test2 <- tibble(x = c('a','b','c','d','e','f'),
y = c(1,2,3,4,5,6),
stringsAsFactors = F)
#內(nèi)連inner_join,取交集
inner_join(test1,test2,by="x")
#左連
left_join(test2,test1,by='x')
left_join(test2,test1,by='x')
#全連
full_join(test1,test2,by='x')
#半連接,返回能夠與y表匹配的x表所有記錄
semi_join(x=test1,y=test2,by='x')
#反連接,返回?zé)o法與y表匹配的x表的所有記錄
anti_join(x=test2,y=test1,by='x')
#簡單合并
bind_rows(test1,test2)#需要兩個表格列數(shù)相同
bind_cols(test1,test3)#需要兩個表格行數(shù)相同