Hi there, something like this?
Data1<-read.table(stdin(), head=T, sep=",") p1,d1,d2 xyz,10,25 kmz,100,250 Data2<-read.table(stdin(), head=T, sep=",") p1,d1,d2 xyz,11,15 kmz,110,150 Data1 Data2 Data3<-data.frame(rbind(Data1,Data2)) Data3 Data3.sum<-aggregate(Data3[,c("d1","d2")], list(Data3$p1), sum) Data3.sum Best wishes miltinho astronauta brazil On Thu, Feb 26, 2009 at 2:52 PM, Vadlamani, Subrahmanyam {FLNA} < subrahmanyam.vadlam...@fritolay.com> wrote: > Hi: > I am a new R user. I have the following question and would appreciate your > input > > Data1 (data frame 1) > p1,d1,d2 (p1 is text and d1 and d2 are numeric) > xyz,10,25 > > Data2 (data frame 2) > p1,d1,d2 > xyz,11,15 > > Now I want to create a new data frame that looks like so below. The fields > d1 and s2 are summed by the product key. > Data3 > p1,d1,d2 > xyz,21 (sum of 10 from Data1 and 11 from Data2),40 (sum of 25 from Data1 > and 15 from Data2) > > Any other examples of merge you may have will be appreciated. Thanks. > Satish > > ______________________________________________ > 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<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.