On Mon, 4 Feb 2019 21:01:06 +0000 (UTC)
Andras Farkas via R-help <r-help@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

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to