I am merging two data sets RH.data and CC (see below).
>head(RH.data)
date RH
1 2005-05-01 71.1
2 2005-05-02 47.0
3 2005-05-03 58.6
4 2005-05-04 44.2
5 2005-05-05 41.8
6 2005-05-06 61.3
> head(cc)
X id date case year month temp
1 1 2005-05-01 1 2005 5 98
2 1 2005-05-02 0 2005 5 62
3 1 2005-05-05 0 2005 5 78
4 2 2005-05-01 1 2005 5 64
5 2 2005-05-06 0 2005 5 75
6 2 2005-05-04 0 2005 5 98
7 2 2005-05-02 0 2005 5 62
8 3 2005-05-03 1 2005 5 88
I am trying to merge them by date using the code
merge(CC, RH.data, by="date", all=T)
However when I run this code, the date changes and my data is replaced with NA
date X id case year month temp RH
1 12904 NA NA NA NA NA NA 71.1
2 12905 NA NA NA NA NA NA 47.0
3 12906 NA NA NA NA NA NA 58.6
4 12907 NA NA NA NA NA NA 44.2
I need the order of CC to stay the same and simply for the values of RH to input where the date is the same. What code would allow me to do this?