[R] map two names into one

arun smartpink111 at yahoo.com
Wed Sep 26 15:02:09 CEST 2012



HI,

Try this:
vec1<-"GALAXY ACE S 5830"
vec2<-"S 5830 GALAXY ACE"
vec3<-"R GALAXY 5812 ACE"
 vec11<-paste(sort(unlist(strsplit(vec2," "))),collapse="_")
 vec22<-paste(sort(unlist(strsplit(vec2," "))),collapse="_")
 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 <metal_licaling at live.com>
To: "r-help at r-project.org" <r-help at r-project.org>
Cc: 
Sent: Wednesday, September 26, 2012 5:04 AM
Subject: [R] map two names into one


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 one,

it is "S 5830 GALAXY ACE"  

both represent same product. how do i map two name into one in R?

there are so many product name having this problem. i hope there is some mechanism which can autimatically map those.  thanks for your help..


Kind regards,
Tammy
                          
    [[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.





More information about the R-help mailing list