2.3 mutate,数据框新增一列
test mutate(test, new = Sepal.Length * Sepal.Width)
#R中的修改必须要赋值,不赋值=没发生
test...###
library(dplyr)
i = rnorm(10)
case_when(i>0 ~ "+",
i<0 ~ "-",
T ~ "0")
★★★★★长脚本的管理方式...,继续写在apply的括号里
apply(iris[,1:4], 2, plot,col = iris[,5])
# 或者也可以自定义函数
jimmy <- function(g){
plot(g,...col = iris[,5])
}
par(mfrow = c(2,2))
apply(iris[,1:4], 2, jimmy)
4.2 lapply(list, FUN, …)函数--参数与自定义函数相似...###
ggplot2 分面相关设置(facet)详解
7.一些实操中的便捷函数
7.1 match() 函数
load("matchtest.Rdata")
x
y
## 把y的列名正确替换为x里面的