I am building a time course dataframe. The time information is in seconds and created using seq(start, end, 0.001)
and the start and end time points are based on values from a csv file.
Start and end time points are sometimes of the form "578.1799999999999" but sometimes the equivalent will be "578.180" or "578.18000000000001". This creates problems down the line when I'm trying to merge several time courses, since for R these are all different time points. Here a comparison from two time courses where each row should represent the same time point, however, some of them are different for R (df$test = df$t1 == df$t2
):
To solve this problem, I tried to round all start and end time points to a precision of 3 digits, corresponding to ms, however, this is not working:
> round(578.1799999999999,3)
[1] 578.1799999999999
Does anyone have an idea how I can "force" R to round to 3 digits and forget the rest?