Hello, I have two different dataset, and wanted to join the two. For example I have a table of codes of cities, and other with with the codes of travels, [source for the destine]. what he wanted was to have a new data.frame with all the information
city<-data.frame(city="Barcelona",cod=1) city<-rbind(city,data.frame(city="Madrid",cod=2)) city<-rbind(city,data.frame(city="Lisbon",cod=3))) city<-rbind(city,data.frame(city="Milan",cod=4)) city<-rbind(city,data.frame(city="London",cod=5)) travel<-data.frame(pos=1,Source=1,Destine=2) travel<-rbind(travel,data.frame(pos=1,Source=1,Destine=3)) travel<-rbind(travel,data.frame(pos=2,Source=3,Destine=4)) travel<-rbind(travel,data.frame(pos=3,Source=2,Destine=4)) travel<-rbind(travel,data.frame(pos=4,Source=1,Destine=3)) #for example pos Source city Destine city_destine 1 1 Barcelona 2 Madrid 1 1 Barcelona 3 Lisbon 2 3 Lisbon 4 Milan 3 2 Madrid 4 Milan which the fastest way to do this. Thanks. -- View this message in context: http://r.789695.n4.nabble.com/copy-the-columns-based-on-the-code-tp4505253p4505253.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.