you could try something like the following: t2 <- lapply(1:11, function(i) c("a", sample(letters[1:5], sample(10, 1), TRUE), "b")) ############ unq.vals <- unique(unlist(t2)) ind <- rowSums(sapply(t2, "%in%", x = unq.vals)) == length(t2) unq.vals[ind]
I hope it helps. Best, Dimitris ---- Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm Quoting Weiwei Shi <[EMAIL PROTECTED]>: > assume t2 is a list of size 11 and each element is a vector of characters. > > the following codes can get what I wanted but I assume there might be > a one-line code for that: > > t3 <- t2[[1]] > for ( i in 2:11){ > t3 <- intersect(t2[[i]], t3) > } > > or there is no such "apply"? > > On 4/24/07, Weiwei Shi <[EMAIL PROTECTED]> wrote: >> Hi, >> I searched the archives and did not find a good solution to that. >> >> assume I have 10 sets and I want to have the common character >> elements of them. >> >> how could i do that? >> >> -- >> Weiwei Shi, Ph.D >> Research Scientist >> GeneGO, Inc. >> >> "Did you always know?" >> "No, I did not. But I believed..." >> ---Matrix III >> > > > -- > Weiwei Shi, Ph.D > Research Scientist > GeneGO, Inc. > > "Did you always know?" > "No, I did not. But I believed..." > ---Matrix III > > ______________________________________________ > R-help@stat.math.ethz.ch 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. > > Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm ______________________________________________ R-help@stat.math.ethz.ch 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.