Hello,
this code, works perfectly temp <- merge(travel, city, by.x="Source", by.y="cod") result <- merge(temp, city, by.x="Destine", by.y="cod") The problem was the construction of the data frame, had a parenthesis in city<-rbind(city,data.frame(city="Lisbon",cod=3))), I tried to delete the post, but i don't could. As I have little experience in R, I still do some mistakes. I use read.table to load the data frame, the way in the post, it was quickly that i found to describe the problem. The forum has been a great help for me. Thanks -- View this message in context: http://r.789695.n4.nabble.com/copy-the-columns-based-on-the-code-tp4505253p4509340.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ 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.