###
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里面的...ID的方法
## (1)分步解法
a = colnames(y)
b = x$file_name
k = match(a,b);k
# match(a,b)的意思是a里的每个元素在b的第几个位置上。