Re: [R] map two names into one

2012-11-08 Thread arun
un2(vec4)) #[1] FALSE  vec5 #[1] "Iphone 4S 16G"  identical(fun2(vec6),fun2(vec7)) #[1] TRUE A.K. From: Tammy Ma To: smartpink...@yahoo.com; "r-help@r-project.org" Sent: Thursday, November 8, 2012 8:12 AM Subject: Re: [R] map two name

Re: [R] map two names into one

2012-11-08 Thread arun
t;  fun1(vec6) #[1] "5830aceGlaxyS"  identical(fun1(vec6),fun1(vec7)) #[1] TRUE  identical(fun1(vec5),fun1(vec1)) #[1] TRUE  identical(fun1(vec1),fun1(vec4)) #[1] FALSE A.K. From: Tammy Ma To: smartpink...@yahoo.com; "r-help@r-project.org" Sent:

Re: [R] map two names into one

2012-11-08 Thread arun
ec4) #[1] "16_3S_G_Iphone"  fun1(vec5) #[1] "16_4S_G_Iphone"  identical(fun1(vec1),fun1(vec5)) #[1] TRUE  identical(fun1(vec1),fun1(vec4)) #[1] FALSE A.K. ____ From: Tammy Ma To: smartpink...@yahoo.com; "r-help@r-project.org" Sent: Thursday, November 8, 2012 8:12 AM S

Re: [R] map two names into one

2012-11-08 Thread arun
not sure what the problem is.  It works with this example.  If you can provide some details, then it would be more helpful. A.K. ________ From: Tammy Ma To: smartpink...@yahoo.com; "r-help@r-project.org" Sent: Thursday, November 8, 2012 8:12 AM Subject: Re: [

Re: [R] map two names into one

2012-11-08 Thread arun
;-paste(sort(unlist(strsplit(vec4," "))),collapse= "_") res11<-paste(sort(unlist(strsplit(vec4," "))),collapse= "_")  identical(res11,res33) #[1] FALSE identical(res11,res44) #[1] TRUE A.K. From: Tammy Ma To: smartp

Re: [R] map two names into one

2012-11-08 Thread Tammy Ma
Thanks. Yes. Your approach can identify: Glaxy ace S 5830 and S 5830 Glaxy ace But you can not identify using same program: Iphone 4S 16 G Iphone 4S 16G How should I solve both in same time. Kind regards,Tammy [[alternative

Re: [R] map two names into one

2012-09-26 Thread arun
t;)  vec11 #[1] "5830_ACE_GALAXY_S"  vec22 #[1] "5830_ACE_GALAXY_S"  identical(vec11,vec22) #[1] TRUE  vec33<-paste(sort(unlist(strsplit(vec3," "))),collapse="_")  identical(vec11,vec33) #[1] FALSE A.K. - Original Message ----- From: Tammy Ma To:

Re: [R] map two names into one

2012-09-26 Thread Sarah Goslee
Hi Tammy, I think we need more information. Are the names always four parts? Does the fix always involve moving two parts from the back to the front? For that matter, which of the two you gave is correct? Or does it matter what order the parts are in as long as it's consistent? Sorting them would

Re: [R] map two names into one

2012-09-26 Thread Kenn Konstabel
It may be easy or difficult depending on what your data are like. "GALAXY ACE S 5830" vs "S 5830 GALAXY ACE" One easy and reasonably general way would be to divide each such bit into 4 "words" and then compare if set 2 contains exactly all words in set 1 but possibly in different order. x1 <- "G

[R] map two names into one

2012-09-26 Thread Tammy Ma
Dear R user: I have got the following problem: I have imported two data sets into R: one set includes price information, another one includes volume information. but I noticed the wrong data order problem in the product name, for instance, in one data set, "GALAXY ACE S 5830" in another o