You are telling it to merge by ID only. But it sounds like you would like it to merge by both ID and age.
merge(Elder, Younger, all=TRUE) Jean On Thu, Jan 16, 2014 at 6:25 AM, kingsly <ecoking...@yahoo.co.in> wrote: > Dear R community > > I have a two data set called "Elder" and "Younger". > This is my code for simple merge. > > Elder <- data.frame( > ID=c("ID1","ID2","ID3"), > age=c(38,35,31)) > Younger <- data.frame( > ID=c("ID4","ID5","ID3"), > age=c(29,21,31)) > > mer <- merge(Elder,Younger,by="ID", all=T) > > Output I am expecting: > > ID age > ID1 38 > ID2 35 > ID3 31 > ID4 29 > ID5 21 > > It looks very simple. But I need help. > When I run the code it gives me age.x and age.y. > thank you > > > > > -- > View this message in context: > http://r.789695.n4.nabble.com/Doubt-in-simple-merge-tp4683671.html > Sent from the R help mailing list archive at Nabble.com. > [[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. > > [[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.