[R] list with list function
motyoc@k@ @end|ng |rom y@hoo@com
Tue Feb 5 18:11:41 CET 2019
Thanks Rui and Ivan, works perfectly...
On Monday, February 4, 2019, 4:18:39 PM EST, Rui Barradas <ruipbarradas using sapo.pt> wrote:
Map('[', listA, lapply(listB, '*', -1))
Hope this helps,
Às 21:01 de 04/02/2019, Andras Farkas via R-help escreveu:
> Hello everyone,
> wonder if you would have a thought on a function for the following:
> we have
> a<-sample(seq(as.Date('1999/01/01'), as.Date('2000/01/01'), by="day"),5)
> b<-sample(seq(as.Date('1999/01/01'), as.Date('2000/01/01'), by="day"), 4)
> c<-sample(seq(as.Date('1999/01/01'), as.Date('2000/01/01'), by="day"), 3)
> what I would like to do with a function (my real listA and listB can be of any length but always equal length, but their components like a,b,and c those can be unequal) as opposed to manually is to derive the following answer
> essentially the elements in listB serve as identifying the position of corresponding list element in listA and removing it from listA.
> these lists listA and listB in practice are columns of a data frame that I am trying to work with and were generated with a function using lapply...
> appreciate any thoughts you may have to make this functional...
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
[[alternative HTML version deleted]]
More information about the R-help