I have a question about the "mutate" function
I have this dataset and I would like to create a new "Total time" column that would be equal to each station's sample time.
So
df <- df %<%
mutate(Total time = Time_out - Time_in)
Except that I also have stations where there are NA values for Time_in and Time_out.
I would then like to be able to apply the average value of total time of the other stations (where time_in and time_out are known) to the cells of the Total_time column which cannot be calculated due to the NA of the other columns
I have one more question about my data because there is a problem
For some data the Time_in and the Time_out are for two different days, so I can have for exemple Time_in = 23:42:00 and Time_out = 00:12:00
Those type of data give me negative value for Total_time..
The best solution is to use full timestamps with the day included. If you cannot do that, you can use a test that if time_out is less than time_in, add 86400 (the number of seconds in a day) to the result. This will only work if no time span is greater than 24 hours.