【发布时间】:2019-12-23 06:35:41
【问题描述】:
我有一个包含几个列的列表;我想删除每个小标题中的前 2 列(不使用 for 循环)。
#Example data with tibble and list
w <- c(1, 2, 3, 4, 5)
x <- c(1, 2, 3, 4, 5)
y <- c(1, 2, 3, 4, 5)
z <- c(1, 2, 3, 4, 5)
tibble <- tibble(w, x, y, z)
list <- list(tibble, tibble, tibble, tibble)
#Remove the first 2 columns in the tibble
tibble1 <- subset(tibble, select=-c(1:2))
tibble1
#Tried this to remove the first two columns of each tibble in list
list1 <- sapply(list, FUN = function(x) subset(x, select=-c(1:2)) )
list1
【问题讨论】:
标签: r