I have a sample data frame like given below
Dataframe1.
general_id date
6 2000-01-02 16:57:13
2 2000-01-02 19:26:13
3 2000-01-04 13:30:13
2 2000-01-04 19:03:13
7 2000-01-06 16:32:13
Dataframe2.
general_id date
1 2000-01-02 16:57:12
1 2000-01-06 16:57:12
1 2000-01-02 19:26:12
1 2000-01-02 19:26:12
1 2000-01-04 13:30:12
1 2000-01-04 13:30:12
1 2000-01-04 19:03:12
1 2000-01-04 19:03:12
1 2000-01-06 16:32:12
there is just a second difference in both date columns of the data frames.
i want to compare the date columns of both the data frames and assign the values of general_id
column in Dataframe1 to general_id
column in Dataframe2
date1 <- Dataframe1$date-dsecond(1)
date2 <- Dataframe1$date
if(date1==date2){
dataframe2$general_id=dataframe1$general_id
}
but i'm getting this error,
In if (date1 == date2) the condition has length > 1 and only the first element will be used
Desired Output is:
Dataframe1
general_id date
6 2000-01-02 16:57:13
2 2000-01-02 19:26:13
3 2000-01-04 13:30:13
2 2000-01-04 19:03:13
7 2000-01-06 16:32:13
Dataframe2
general_id date
6 2000-01-02 16:57:12
6 2000-01-06 16:57:12
2 2000-01-02 19:26:12
2 2000-01-02 19:26:12
3 2000-01-04 13:30:12
3 2000-01-04 13:30:12
2 2000-01-04 19:03:12
2 2000-01-04 19:03:12
7 2000-01-06 16:32:12
7 2000-01-06 16:32:12