everyone! I would like to combine two dataframes: (Let's say A and B). Each has two columns: ymd_hms and Value 1 in A dataframe while ymd_hms and Value 2 in B dataframe. But ymd_hms in A dataframe and ymd_hms in B dataframe are always the same. Here is the question. I would like to take Value 2 from B dataframe if
- ymd_hms in A dataframe is equal to ymd_hms in B dataframe, or
- ymd_hms in A dataframe is more or less equal to ymd_hms in B dataframe (i.e. one or two minute difference is acceptable). Could you please help me how to code it?
A %>% mutate(Value 2 = ifelse (A$ymd_hms == B$ymd_hms| A$ymd_hms == which(B$ymd_hms + minute(2)), B$ymd_hms - (minute(2)), Value 2, NA)
I didn't get my expected result.
Aucun commentaire:
Enregistrer un commentaire