Dear Community

I have a large dataframe x as follows with common ids but different names:

> x <- data.frame(ID = c(1,1,2,2,2,3,3),
+ Name = c("B Branch A Firm ","A Firm","B Firm","B Firm","B Firm C Branch","C 
Firm","C Firm A Branch")
+ )
> x
  ID             Name
1  1 B Branch A Firm 
2  1           A Firm
3  2           B Firm
4  2           B Firm
5  2  B Firm C Branch
6  3           C Firm
7  3  C Firm A Branch

Q: How can I turn it into a dataframe with common id and common names, like 
this:

> y <- data.frame(ID = c(1,1,2,2,2,3,3),
+ Name = c("A Firm","A Firm","B Firm","B Firm","B Firm","C Firm","C Firm")
+ )
> y
  ID   Name
1  1 A Firm
2  1 A Firm
3  2 B Firm
4  2 B Firm
5  2 B Firm
6  3 C Firm
7  3 C Firm

Although I searched a lot, I am still not able to find answers to my question.  
Please help.

Thanks in advance.

2012-03-09



Chen
        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to