Philip Robinson
2012-Jan-15 08:28 UTC
[R] determining the difference between 2 character strings
Hi, I am struggling, I have 2 lists with shared elements, one ~600, one ~1000, and I need to determine the difference between them. They are character strings, and to use setdiff(), or unique() I need vectors. I don't know how to force these character strings into a form where you can use functions like setdiff(). Any help would be greatly appreciated.> head(R1)[1] "ccc-5-96078266-C-T" "ccc-5-96127578-C-T" "ccc-5-96133900-A-G" "ccc-5-96145958-C-T" "ccc-5-96147966-C-T" "ccc-5-96150086-T-C"> head(R2)[1] "imm_5_96030100" "imm_5_96377451" "imm_5_96334858" "imm_5_96318074" "imm_5_96356643" "imm_5_96389465" thanks Philip
Jim Holtman
2012-Jan-15 08:53 UTC
[R] determining the difference between 2 character string
why cann't you use setdiff or unique? in the sample data how do you tell the difference? do you compare the whole string, or partial? a better definition of your problem and what you have tried would help. it would seem like there is nothing the same between your sample data. Sent from my iPad On Jan 15, 2012, at 3:28, Philip Robinson <philip.c.robinson at gmail.com> wrote:> Hi, > > I am struggling, I have 2 lists with shared elements, one ~600, one > ~1000, and I need to determine the difference between them. > > They are character strings, and to use setdiff(), or unique() I need > vectors. I don't know how to force these character strings into a form > where you can use functions like setdiff(). Any help would be greatly > appreciated. > > >> head(R1) > [1] "ccc-5-96078266-C-T" "ccc-5-96127578-C-T" "ccc-5-96133900-A-G" > "ccc-5-96145958-C-T" "ccc-5-96147966-C-T" "ccc-5-96150086-T-C" > >> head(R2) > [1] "imm_5_96030100" "imm_5_96377451" "imm_5_96334858" > "imm_5_96318074" "imm_5_96356643" "imm_5_96389465" > > thanks > Philip > > ______________________________________________ > 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.
R. Michael Weylandt <michael.weylandt@gmail.com>
2012-Jan-15 14:30 UTC
[R] determining the difference between 2 character strings
On Jan 15, 2012, at 3:28 AM, Philip Robinson <philip.c.robinson at gmail.com> wrote:> Hi, > > I am struggling, I have 2 lists with shared elements, one ~600, one > ~1000, and I need to determine the difference between them. > > They are character strings, and to use setdiff(), or unique() I need > vectors.You can have character vectors. (in fact, from the below, I'm almost certain you already do) Michael> I don't know how to force these character strings into a form > where you can use functions like setdiff(). Any help would be greatly > appreciated. > > >> head(R1) > [1] "ccc-5-96078266-C-T" "ccc-5-96127578-C-T" "ccc-5-96133900-A-G" > "ccc-5-96145958-C-T" "ccc-5-96147966-C-T" "ccc-5-96150086-T-C" > >> head(R2) > [1] "imm_5_96030100" "imm_5_96377451" "imm_5_96334858" > "imm_5_96318074" "imm_5_96356643" "imm_5_96389465" > > thanks > Philip > > ______________________________________________ > 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.