Hello I am struggling to accomplice an idea which is as follows: I have a vector say: a <- c("a", "b", "c", "a") and another: b <- c("m", "n", "o", "m"). Length of those 2 vectors are essentially be same. Here task is to check the duplicates in the vector 'a' and then to check whether any duplicates are there in the same places of 'b'. If not, flag a FALSE. I above example, it is correct hence TRUE. However in general how can I implement this? Can somebody please help me? Thanks, [[alternative HTML version deleted]]
?duplicated This will identify common locations where duplications occur: duplicated(a) & duplicated(b) Ravi. ------------------------------------------------------- Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins University Ph. (410) 502-2619 email: rvaradhan at jhmi.edu -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Nipesh Bajaj Sent: Wednesday, February 09, 2011 10:12 AM To: r-help at r-project.org Subject: [R] A question on Duplicating Hello I am struggling to accomplice an idea which is as follows: I have a vector say: a <- c("a", "b", "c", "a") and another: b <- c("m", "n", "o", "m"). Length of those 2 vectors are essentially be same. Here task is to check the duplicates in the vector 'a' and then to check whether any duplicates are there in the same places of 'b'. If not, flag a FALSE. I above example, it is correct hence TRUE. However in general how can I implement this? Can somebody please help me? Thanks, [[alternative HTML version deleted]] ______________________________________________ R-help at 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.
ab = paste(a,b,sep=";~;~;~") flag = length(ab)==length(unique(ab)) This should work unless you use 3 consecutive winking elephants in other places in your program. -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Nipesh Bajaj Sent: Wednesday, February 09, 2011 10:12 AM To: r-help at r-project.org Subject: [R] A question on Duplicating Hello I am struggling to accomplice an idea which is as follows: I have a vector say: a <- c("a", "b", "c", "a") and another: b <- c("m", "n", "o", "m"). Length of those 2 vectors are essentially be same. Here task is to check the duplicates in the vector 'a' and then to check whether any duplicates are there in the same places of 'b'. If not, flag a FALSE. I above example, it is correct hence TRUE. However in general how can I implement this? Can somebody please help me? Thanks, [[alternative HTML version deleted]] ______________________________________________ R-help at 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. message may contain confidential information. If you are not the designated recipient, please notify the sender immediately, and delete the original and any copies. Any use of the message by you is prohibited.