killerkarthick
2012-Oct-03 11:30 UTC
[R] How to add a new row in to an existing data set in R Language?
Hi... I have one 2 data set with 3 variables and 4 observations. I want to combine the two data sets. I tried with merge but it gives only the common values. I need common values and and remaining values also. Please help me? this is my data set dataset:1 name va1 va2 AA 10 100 BB 20 200 CC 30 300 DD 40 400 dataset:2 name va1 va2 AA 36 444 BB 10 111 CC 20 222 DD NA 333 Please reply me..................................... -- View this message in context: http://r.789695.n4.nabble.com/How-to-add-a-new-row-in-to-an-existing-data-set-in-R-Language-tp4644855.html Sent from the R help mailing list archive at Nabble.com.
Ista Zahn
2012-Oct-03 13:44 UTC
[R] How to add a new row in to an existing data set in R Language?
Hi, Have you read the documentation for merge? The relevant section says " If 'all.x' is true, all the non matching cases of 'x' are appended to the result as well, with 'NA' filled in the corresponding columns of 'y'; analogously for 'all.y'." Please do get in the habit of reading the documentation before posting on the mailing list. Best, Ista On Wed, Oct 3, 2012 at 7:30 AM, killerkarthick <karthick.gdi at gmail.com> wrote:> Hi... > I have one 2 data set with 3 variables and 4 observations. I want to combine > the two data sets. I tried with merge but it gives only the common values. I > need common values and and remaining values also. Please help me? > this is my data set > dataset:1 > name va1 va2 > AA 10 100 > BB 20 200 > CC 30 300 > DD 40 400 > > dataset:2 > name va1 va2 > AA 36 444 > BB 10 111 > CC 20 222 > DD NA 333 > Please reply me..................................... > > > > -- > View this message in context: http://r.789695.n4.nabble.com/How-to-add-a-new-row-in-to-an-existing-data-set-in-R-Language-tp4644855.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at 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.
killerkarthick
2012-Oct-05 04:27 UTC
[R] How to add a new row in to an existing data set in R Language?
Hi Ista Zahn, Thanks for your advice. Please see the following Image. <http://r.789695.n4.nabble.com/file/n4645113/data.png> i am expecting the result should same in the image. -- View this message in context: http://r.789695.n4.nabble.com/How-to-add-a-new-row-in-to-an-existing-data-set-in-R-Language-tp4644855p4645113.html Sent from the R help mailing list archive at Nabble.com.
killerkarthick
2012-Oct-05 04:38 UTC
[R] How to add a new row in to an existing data set in R Language?
Hi................. I have one dataset with 3 variables with 4 observations. I want to add the some more observation into the existing dataset. Data;Mydata center drug change 101 P 18 102 P 14 103 D 12 104 D 18 105 P 10 This is the data set. So I want to add some more rows to the existing dataset that rows are 106 P 17 107 D 18 108 D NA 109 P 13 110 P 12 Without using any combine functions. This is possible? Please reply me................................... -- View this message in context: http://r.789695.n4.nabble.com/How-to-add-a-new-row-in-to-an-existing-data-set-in-R-Language-tp4645114.html Sent from the R help mailing list archive at Nabble.com.
killerkarthick
2012-Oct-05 06:18 UTC
[R] How to add a new row in to an existing data set in R Language?
Thanks for your answer Arun, That above image shows the merge in SAS but its possible as same in R please reply me let me know? -- View this message in context: http://r.789695.n4.nabble.com/How-to-merge-data-set-in-R-Language-tp4644855p4645119.html Sent from the R help mailing list archive at Nabble.com.
PIKAL Petr
2012-Oct-05 06:55 UTC
[R] How to add a new row in to an existing data set in R Language?
Hi ?merge or ?rbind Regards Petr> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- > project.org] On Behalf Of killerkarthick > Sent: Friday, October 05, 2012 6:39 AM > To: r-help at r-project.org > Subject: [R] How to add a new row in to an existing data set in R > Language? > > Hi................. > I have one dataset with 3 variables with 4 observations. I want to add > the some more observation into the existing dataset. > Data;Mydata > center drug change > 101 P 18 > 102 P 14 > 103 D 12 > 104 D 18 > 105 P 10 > This is the data set. So I want to add some more rows to the existing > dataset that rows are > 106 P 17 > 107 D 18 > 108 D NA > 109 P 13 > 110 P 12 > Without using any combine functions. This is possible? > Please reply me................................... > > > > -- > View this message in context: http://r.789695.n4.nabble.com/How-to-add- > a-new-row-in-to-an-existing-data-set-in-R-Language-tp4645114.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at 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.
arun
2012-Oct-05 11:44 UTC
[R] How to add a new row in to an existing data set in R Language?
Hi Karthick, Not sure if I understand your message correctly.? Are you saying that the SAS merge as shown in the image (Nabble) is correct?. The fourth row in the merged data (105 21JUN1980 21JAN2006) is incorrect. A.K. ----- Original Message ----- From: killerkarthick <karthick.gdi at gmail.com> To: r-help at r-project.org Cc: Sent: Friday, October 5, 2012 2:18 AM Subject: Re: [R] How to add a new row in to an existing data set in R Language? Thanks for your answer Arun, That above image? shows the merge in SAS but its possible as same in R please reply me let me know? -- View this message in context: http://r.789695.n4.nabble.com/How-to-merge-data-set-in-R-Language-tp4644855p4645119.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help at 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.
Ista Zahn
2012-Oct-05 13:08 UTC
[R] How to add a new row in to an existing data set in R Language?
Hi, On Fri, Oct 5, 2012 at 12:27 AM, killerkarthick <karthick.gdi at gmail.com> wrote:> Hi Ista Zahn, > Thanks for your advice. Please see the > following Image. > > > > > <http://r.789695.n4.nabble.com/file/n4645113/data.png>To me this example looks plain wrong. You end up with a row that contains the date of birth for subject 104 and the date of informed consent for subject 105. If this really is the situation you face, I suggest correcting the ID before merging.> > > > > > > i am expecting the result should same in the image.OK, then fix your ID numbers and use merge(DF1, DF2). Best, Ista> > > > > -- > View this message in context: http://r.789695.n4.nabble.com/How-to-add-a-new-row-in-to-an-existing-data-set-in-R-Language-tp4644855p4645113.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at 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.