【发布时间】:2021-03-15 16:52:12
【问题描述】:
这是我的例子。
test <- list(el_1 = data.frame(col_1 = c(1,2), col_2 = c(2,3)), el_2 = NA)
我想删除列表的第二个元素。
这是我尝试过的。
test_1 <- sapply(test, function(x) x[!is.na(x)], simplify = F)
test_2 <- sapply(test, function(x) !is.na(x), simplify = F)
test_3 <- unlist(test)
它们都不起作用,在每种情况下,我的数据框都被转换为字符串。
【问题讨论】: