You can also try 'mapply' > aa<-list(c(1:3), c(4:6)) > bb<-list(3,5) > mapply(setdiff, aa, bb) [,1] [,2] [1,] 1 4 [2,] 2 6 >
On Fri, Feb 1, 2013 at 5:16 AM, Simone Gabbriellini <simone.gabbriell...@gmail.com> wrote: > Dear List, > > I have a data structure like: > >> aa > [[1]] > [1] 1 2 3 > > [[2]] > [1] 4 5 6 > >> bb > [[1]] > [1] 3 > > [[2]] > [1] 5 > > I would like to set differences between "aa" and "bb" and get as > result another list of lists like: > >> res > [[1]] > [1] 1 2 > > [[2]] > [1] 4 6 > > I am trying: > > lapply(aa, setdiff, bb) > > but I simply get "aa" back as result. Could you please point me in the > right direction about the combination of functions that I need to > accomplish this task? > > Best regards, > Simone > > -- > Simone Gabbriellini, PhD > > PostDoc@DISI, University of Bologna > mobile: +39 340 39 75 626 > email: simone.gabbriell...@unibo.it > home: www.digitaldust.it > > DigitalBrains srl > Amministratore > mobile: +39 340 39 75 626 > email: simone.gabbriell...@digitalbrains.it > home: www.digitalbrains.it > > ______________________________________________ > R-help@r-project.org mailing list > 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. -- Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. ______________________________________________ R-help@r-project.org mailing list 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.