- 欧氏距离计算
R
df <- data.frame(x = 1:10, y = 1:10, row.names = paste0("s", 1:10))
euro_dist <- as.matrix(dist(df))
2. 集合运算
R
union(x, y) # 并集
intersect(x, y) # 交集
setdiff(x, y) # 只在x中存在,y中不存在的元素
setequal(x, y) # 判断集合元素是否相同(顺序可以不同)
is.element(x, y) # x %in% y
# x, y: vectors (of the same mode) containing a sequence of items (conceptually) with no duplicated values.