pairwise comparisions
On Sep 10, 2012, at 7:00 AM, priya wrote:
Hi , I am new to R .
How new? Is this still in a file? ... or has it been imported to an R object. If it really still is in a file, then Bert's suggestion of first reading "Intro to R" rather than posting to R help is on point. If it is an R object, you _should_ have used dput(head(obj)) to provide an appropriate test case for solutions.
I am facing difficulty how to make pairwise comparisions. For example. I have a file which looks like below a b c d x 3 6 7 6 y 7 8 6 5 z 5 4 7 8 Here I need to look for the each pairwise comparisions (ab,ac,ad,bc,bd,cd for each row)
Let's assume it's in a matrix of data.frame named X. To get pairwise combinations try: CX <- combn( colnames(X), 2) That's going to be a 2 row character matrix. Perhaps this will work but since you provide not example it will remain untested. apply(CX, 2, function(comb), pmin(X[, comb[1]], X[, comb[2]] ) )
For instance ,looking at first row, for x i need to look for ab values and take the min(3,6) >5 ,if its satistfies the count should be noted, (now count is 0), bc values ,min(6,7) >5 ,count for x =1 etc. Likewise all the comparisons are made and count is noted for x,y,z. Is there any function to make pairwise comparisions in R or any easy way to do this? Any help is greatly appreciated.
David Winsemius, MD Alameda, CA, USA