Re: [R] counting the duplicates in an object of list

2011-09-07 Thread zhenjiang xu
bco.com > > *From:* zhenjiang xu [mailto:zhenjiang...@gmail.com] > *Sent:* Wednesday, September 07, 2011 8:04 PM > > *To:* William Dunlap > *Cc:* r-help > *Subject:* Re: [R] counting the duplicates in an object of list > > ** ** > > I tried converting th

Re: [R] counting the duplicates in an object of list

2011-09-07 Thread William Dunlap
ill Dunlap Spotfire, TIBCO Software wdunlap tibco.com From: zhenjiang xu [mailto:zhenjiang...@gmail.com] Sent: Wednesday, September 07, 2011 8:04 PM To: William Dunlap Cc: r-help Subject: Re: [R] counting the duplicates in an object of list I tried converting the elements to strings before, but due to

Re: [R] counting the duplicates in an object of list

2011-09-07 Thread zhenjiang xu
gt; wdunlap tibco.com > > *From:* zhenjiang xu [mailto:zhenjiang...@gmail.com] > *Sent:* Wednesday, September 07, 2011 7:25 PM > *To:* William Dunlap > *Cc:* r-help > *Subject:* Re: [R] counting the duplicates in an object of list > > ** ** > > Now I naile

Re: [R] counting the duplicates in an object of list

2011-09-07 Thread William Dunlap
2011 7:25 PM To: William Dunlap Cc: r-help Subject: Re: [R] counting the duplicates in an object of list Now I nailed down the problem, but I am still confused why match() takes the 1st two components and the last two the same. > match(a,a) [1] 1 2 3 1 2 > a [[1]] [1] "YARCTy1-1" &q

Re: [R] counting the duplicates in an object of list

2011-09-07 Thread zhenjiang xu
Now I nailed down the problem, but I am still confused why match() takes the 1st two components and the last two the same. > match(a,a) [1] 1 2 3 1 2 > a [[1]] [1] "YARCTy1-1" "YAR009C" "YBLWTy1-1" "YBL005W-B" "YBRWTy1-2" "YBR012W-B" [7] "YDRCTy1-1" "YDR098C-B" "YDRCTy1-2" "YDR210C-D" "YDRCTy

Re: [R] counting the duplicates in an object of list

2011-09-07 Thread zhenjiang xu
Thanks, Bill. match() is nice and efficient. However, I met a problem: My real data is a large _list_ named "read.genes". I found conflict results between match() and unique() - the lengths of the outcomes are different (and my final result are wrong too). I suspect that some different list compon

Re: [R] counting the duplicates in an object of list

2011-08-31 Thread William Dunlap
table(match(x, x)) gives you the numbers but the labels are a bit more work. E.g., I'll define another list > x <- list(c("1", "2", "4"), c("1", "2", "4"), 2^(0:4), 3^(1:2), 2^(0:4)) > tb <- table(m <- match(x, x)) > m [1] 1 1 3 4 3 > tb 1 3 4 2 2 1 which says that the first elem