Thank you Arun Kirshna. That worked perfectly!

On Mon, Mar 24, 2014 at 2:49 PM, arun kirshna [via R] <
ml-node+s789695n4687459...@n4.nabble.com> wrote:

> Hi,
> Try ?merge() or ?join from library(plyr)
> If `dat1` and `dat2` are the datasets:
> res <- merge(dat1,dat2,by="Code",all=TRUE)
>  res[is.na(res)] <- 0
>  res
> #  Code Cap04 Cap08
> #1    2   120   120
> #2    6    75     0
> #3    7   220   112
> #4    9     0   190
> #5   17     4     4
> A.K.
>
>
>
> Hello,
>
> I need to combine two data sets into one. For example:
>
> Dataset1:
> Code   Cap04
> 2        120
> 6          75
> 7        220
> 17         4
>
> Dataset2:
> Code   Cap08
> 2        120
> 7        112
> 9        190
> 17         4
>
>
> I need the dataset to look like the following where it keeps
>  every unique 'code' from both datasets and fills the blanks in both
> rows with 0:
>
> FinalDataSet:
> Code   Cap04   Cap08
> 2         120       120
> 6          75          0
> 7         220       112
> 9            0       190
> 17          4          4
>
> Can anyone help me with this please?
>
> Thank you very much!
> Johnson
>
> ______________________________________________
> [hidden email] <http://user/SendEmail.jtp?type=node&node=4687459&i=0>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.
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://r.789695.n4.nabble.com/How-to-join-data-frames-with-different-row-lengths-tp4687457p4687459.html
>  To unsubscribe from How to join data.frames with different row lengths, click
> here<http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4687457&code=bXc1d2Fnc0BnbWFpbC5jb218NDY4NzQ1N3wxNzA5ODM5Njkw>
> .
> NAML<http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>



-- 
Megan Weigel
(865)924-2124
mw5w...@gmail.com




--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-join-data-frames-with-different-row-lengths-tp4687457p4687471.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.

Reply via email to