001、
data <- data.frame(x1 = c(1, 2, 3, 4), x2 = c(5, 6, 7, 8)) ## 测试数据框 data transform(data, x1 = x1 + 10) ## 修改列 transform(data, x1 = x1 + 10, x2 = x2 * 10, x3 = x1 + x2, x4 = x1 * x2) ## 添加列
data <- data.frame(x1 = c(1, 2, 3, 4), x2 = c(5, 6, 7, 8)) data data <- transform(data, x1 = x1 + 10, x2 = x2 * 10, x3 = x1 + x2, x4 = x1 * x2) data data <- transform(data, x2 = NULL, x3 = NULL) ## 删除列 data