[R] list with list function
Ivan Krylov
kry|ov@r00t @end|ng |rom gm@||@com
Mon Feb 4 22:21:09 CET 2019
On Mon, 4 Feb 2019 21:01:06 +0000 (UTC)
Andras Farkas via R-help <r-help using r-project.org> wrote:
> listA<-list(a,b,c)
> listB<-list(d,e,f)
>
> what I would like to do with a function <...> as opposed to manually
> is to derive the following answer
>
> listfinal<-list(a[-d],b[-e],c[-f])
The `Map` function, unlike `lapply`, iterates over its arguments
simultaneously:
Map(function(dt, idx) dt[-idx], listA, listB)
# [[1]]
# [1] "1999-07-31" "1999-06-12"
#
# [[2]]
# [1] "1999-03-10" "1999-04-04"
#
# [[3]]
# [1] "1999-08-07"
--
Best regards,
Ivan
More information about the R-help
mailing list