mutate()
添加新变量并保留现有变量; transmute()
添加新变量并删除现有变量。 新变量将覆盖同名的现有变量。 可以通过将变量的值设置为来删除变量 NULL
.
1、mutate()函数功能
功能:增加列
library(dplyr) mydata2 <-iris # Mutate function for creating new variable to the dataframe in R mydata3 = mutate(mydata2, sepal_length_width_ratio=Sepal.Length/Sepal.Width) head(mydata3)
可以看出增加了一列
优秀教程:https://www.datasciencemadesimple.com/create-new-variable-r-using-mutate-function-dplyr-mutate-mutate_all-mutate_at/
2、arrange()函数功能
功能:按列排序
优秀教程:https://www.statology.org/arrange-rows-r/
3、filter()函数
功能:对数据过滤
https://www.statology.org/filter-rows-r/
4、case_when()
优秀教程:https://www.datasciencemadesimple.com/case-statement-r-using-case_when-dplyr/