且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用R从另一个列表中的索引中提取列表中的元素

更新时间:2023-01-22 07:47:34

我们可以使用Map基于'indexList'的索引提取相应的list元素

We can use Map to extract the corresponding list elements based on the index from 'indexList'

Map(`[`, dataList, indexList)


或使用purrr

library(purrr)
map2(dataList, indexList, `[`)