Hi, I am a new to rstudio! May I ask your kind help to code!
Using the following data in the comment, I want to take the values from Col 3 for each same time, in which the values will be if Col 2 and Col 4 are matched.
For example, at 2015-01-08 10:30:00, Col 2 is 772.75 and Col 4 is also 772.75. So, I would like to assign 35.79172 (from Col 3) to Col 6 for all rows with 2015-01-08 10:30:00.
Likewise, for Col 7, if Col 2 and Col 5 are matched.
I tried to code as follow: A_total <- df %>% filter(Col 2 > 750 & Col 2 < 849) %>% select(time, Col 2, Col 3, Col 4, Col 5) %>% group_by(time)%>% mutate(Col 6 = match (Col 2, Col 4), Col 7 = match (Col 2, Col 5)) %>% if (Col 6 >= 1 | Col 7 >= 1) { A <- ((Col 4 + Col 5)/2)*new Col }
I am sure my code is incorrect. Could you please help to code?