[R] Merging two data sets
Leeds, Mark (IED)
Mark.Leeds at morganstanley.com
Thu Dec 7 15:32:22 CET 2006
if you read them in as zoo objects , you can then use merge.zoo but but
I need to
Send you an example of reading them in as zoo objects.
Hold on.
I also have your binders on my shelf ready to send. I've just been
forgetting/busy.
-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Megh Dal
Sent: Thursday, December 07, 2006 3:35 AM
To: r-help at stat.math.ethz.ch
Subject: [R] Merging two data sets
Dear all R users,
Suppose I have two datasets:
g =
8/11/2005 92.75
9/11/2005 92.30
10/11/2005 92.55
11/11/2005 93.90
11/14/2005 94.20
11/15/2005 94.40
11/16/2005 93.90
11/22/2005 94.60
11/24/2005 95.50
2/12/2005 101.00
and,
h =
11/8/2005 45.930
11/9/2005 45.820
11/10/2005 45.815
11/11/2005 45.780
11/12/2005 45.630
11/13/2005 45.630
11/14/2005 45.630
11/15/2005 45.710
11/16/2005 45.715
11/17/2005 45.815
I want to merge these two dataset like this:
8/11/2005 92.75 NA
9/11/2005 92.30 NA
10/11/2005 92.55 NA
11/11/2005 93.90 45.780
11/14/2005 94.20 45.630
11/15/2005 94.40 45.710
11/16/2005 93.90 45.715
11/22/2005 94.60 NA
11/24/2005 95.50 NA
2/12/2005 101.00 NA
i.e. the length of final dataset should be same as 'g' regardless that
of 2nd dataset.
Can anyone tell me how to do this?
I already used ?merge function like this:
h = merge(g,f, by.x="Date", by.y="Date", sort=F, all.x=T, all.y = F,
all=F)
But it is not giving the thing that I want.
Thanks
---------------------------------
[[alternative HTML version deleted]]
______________________________________________
R-help at stat.math.ethz.ch 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.
--------------------------------------------------------
This is not an offer (or solicitation of an offer) to buy/se...{{dropped}}
More information about the R-help
mailing list