dplyr包是plyr的迭代,使用过plyr的同学一定都赞叹过hadley大神的神作,以下内容简单介绍dplyr有哪些函数
filter筛选行。如filter(flights,month==1,day==1),和subset类似,但是速度快很多slice按位置筛选。如slice(flights,1:10)选择1~10行arrange排序。如arrange(flights,year,month,day)select选择列。如select(flights,year,month,day),select(flights,-(year:day))rename重命名。如rename(flights,newname = oldname)distinct选择唯一值。如distinct(select(flights,tailnum))mutate添加新列。如mutate(flights,newcol1 = ...,newcol2 = ...)transmute只保留新列。summarise汇总。如summarise(flights,delay = mean(...),na.rm = TRUE)group_by分组。如group_by(flights,tailnum)按tailnum分组n()统计当前组的总数n_distinct(x)当前组的唯一值总数first(x)当前组的第一个值last(x)当前组的最后一个值nth(x,n)当前组的第n个值