你可以试试findInterval
like
findInterval(df$Time, seq(min(df$Time), max(df$Time), 0.03))
#[1] 1 1 1 2 2 3 3 3 4 4
我们还可以使用cut
breaks <- seq(min(df$Time), max(df$Time), 0.03)
cut(df$Time, c(breaks, Inf), labels = breaks, include.lowest = TRUE)
#[1] 0 0 0 0.03 0.03 0.03 0.06 0.06 0.09 0.09
data
df <- structure(list(Time = c(0, 0.012, 0.024, 0.036, 0.048, 0.06,
0.072, 0.084, 0.096, 0.108)), class = "data.frame", row.names = c(NA, -10L))