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]]
______________________________________________
[email protected] 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.