I dont get any putput by merging. merge(file1,file2) [1] Date Price <0 rows> (or 0-length row.names)
file3<-merge(file1,file2,by.file1='Date') > file3 [1] Date Price <0 rows> (or 0-length row.names) The above are the results. Nothing is coming in file3. On 7/7/10, Peter Alspach-2 [via R] <ml-node+2280305-1773552212-309...@n4.nabble.com> wrote: > > > > Tena koe > > Why is merge() not helpful? From your description I would imagine > > merge(file1, file2, by='Date') > > would do what you require. > > HTH .... > > Peter Alspach > >> -----Original Message----- >> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- >> project.org] On Behalf Of raghu >> Sent: Wednesday, 7 July 2010 10:18 a.m. >> To: r-help@r-project.org >> Subject: [R] Adding two files into one and vlookup >> >> >> I have two files with dates and prices in each. The number of rows in >> each of >> them will differ. How do I create a new file which contains data from >> both >> these files? Cbind and merge are not helpful. For cbind because the >> rows are >> not the same replication occurs. Also if I have similar data how do I >> write >> a vlookup kind of function? I am giving an example below: >> Say Price1 file contains the following: >> Date Price >> 2/3/2010 134.00 >> 3/3/2010 133.90 >> 4/3/2010 135.55 >> >> And say price2 contains the following: >> Date Price >> 2/3/2010 2300 >> 3/3/2010 3200 >> 4/3/2010 1800 >> 5/3/2010 1900 >> >> I want to take both these data together in a single file, and take the >> smaller vector (or matrix or dataframe??..i am new to R and still >> confused >> with the various objects) which is file1 (because it contains fewer >> rows ) >> and vlookup prices in the second file basedon the dates on file1 and >> write >> three columns (date, price from 1 and price from2) in a new file. How >> do i >> do this please? >> >> Many thanks... >> R >> -- >> View this message in context: http://r.789695.n4.nabble.com/Adding-two- >> files-into-one-and-vlookup-tp2280277p2280277.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. > > ______________________________________________ > 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. > > > ______________________________________ > View message @ > http://r.789695.n4.nabble.com/Adding-two-files-into-one-and-vlookup-tp2280277p2280305.html > To start a new topic under R help, email > ml-node+789696-608741344-309...@n4.nabble.com > To unsubscribe from R help, click > (link removed) > -- 'Raghu' -- View this message in context: http://r.789695.n4.nabble.com/Adding-two-files-into-one-and-vlookup-tp2280277p2281026.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.