R: How do I remove the first element from each inner element of a list without converting it to matrix?

蹲街弑〆低调 提交于 2019-12-04 15:07:54

Assuming the pattern is just that you want the second element removed,

lapply(List, function(x) x[-2])

Using purrr::map it would be even shorter by doing

# setup some example data
nestedList = list(list(4,5,6),list(1,2,3))

# remove first element from each sublist
map(nestedList, tail, -1)
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!