How can I remove an element from a list?

前端 未结 16 1435
傲寒
傲寒 2020-11-28 01:21

I have a list and I want to remove a single element from it. How can I do this?

I\'ve tried looking up what I think the obvious names for this function would be in

16条回答
  •  粉色の甜心
    2020-11-28 01:50

    You can also negatively index from a list using the extract function of the magrittr package to remove a list item.

    a <- seq(1,5)
    b <- seq(2,6)
    c <- seq(3,7)
    l <- list(a,b,c)
    
    library(magrittr)
    
    extract(l,-1) #simple one-function method
    [[1]]
    [1] 2 3 4 5 6
    
    [[2]]
    [1] 3 4 5 6 7
    

提交回复
热议问题