I think you want the set operations:
list1-c(1,3,6,8,9)
list2-c(3,5,1,0)
union(list1, list2)
[1] 1 3 6 8 9 5 0
intersect(list1, list2)
[1] 1 3
On 10/28/06, Milton Cezar Ribeiro [EMAIL PROTECTED] wrote:
Hi there,
Could someone help to compare to list. I do something like:
list1-c(1,3,6,8,9)
list2-c(3,5,1,0)
mathlist-NULL
for (i in list1) {
for (j in list2) {
if (i==j) mathlist-c(mathlist,i)
}}
mathlist
Is there a more elegant way to solve this question?
Kind regards
Miltinho
BRAZIL
-
Você quer respostas para suas perguntas? Ou você sabe muito e quer
compartilhar seu conhecimento? Experimente o Yahoo! Respostas!
[[alternative HTML version deleted]]
__
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.
--
Jim Holtman
Cincinnati, OH
+1 513 646 9390
What is the problem you are trying to solve?
[[alternative HTML version deleted]]
__
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.