我有这个清单:
a <- list(list(c("sam1", "control"), c("sam1", "latanoprost free acid", "GSM6683", "GSM6684"), c("sam1", "prostaglandin F2alpha", "GSM6687", "GSM6688")), list(c("sam2", "control"), c("sam2", "latanoprost free acid", "GSM6681", "GSM6682"), c("sam2", "prostaglandin F2alpha", "GSM6685", "GSM6686")))
我想删除长度小于三个(<3)的元素(列表)。我尝试使用双重 lapply 来获得 [[i]][[j]] 和 <- NULL,但我得到的列表只有 NULL。像这样:
b <- lapply(seq(length(a)),function(i){
lapply(seq(length(a[[1]])),function(j){
if(length(a[[i]][[j]]) < 3) {a[[i]][[j]] <- NULL}
})
})
感谢您的任何帮助...