I am measuring electric current (µA) over a certain time interval (s) for 4 different channels (chan_n) and this is how my data looks:
dat
s µA chan_n
<dbl> <dbl> <chr>
0.00 -0.03167860 1
0.02 -0.03136610 1
0.04 -0.03118490 1
0.06 -0.03094740 1
0.08 -0.03065360 1
0.10 -0.03047860 1
0.12 -0.03012230 1
0.14 -0.02995980 1
0.16 -0.02961610 1
... ... ...
My end goal is to get the current of a certain time after the peak value. Therefore I first get the time timepoints at which the maximum appears for each channel:
BaslineTime <- dat %>%
group_by(chan_n) %>%
slice(which.max(µA)) %>% # get max current values
transmute(s = s + 30) # add 30 to the timepoints at which the max value appears
chan_n s
<chr> <dbl>
1 539.84
2 540.00
3 539.82
4 539.80
But if I use BaselineTime
to filter for my current values I get two NAs:
BaslineVal <- right_join(dat, BaselineTime, by =c("chan_n","s"))
s µA chan_n
<dbl> <dbl> <chr>
540.00 0.00364974 2
539.80 0.00610948 4
539.84 NA 1
539.82 NA 3
I checked if the time values exist for channel 1 and 3 and they do. Also if I create a data frame manualy by hardcoding the time values and use it for filtering, it works just fine. So why isn't it working? I would be very happy for any suggestions or explanations. I think it might have something to do the the decimal places as for channel 2 and 4 there is a 0 on the last decimal place.