rtimesubsetposixct

Subset dataset by repeating temporal variable (accelerometer data)


I have a dataset from an accelerometer, which consists in a time variable and measurements in the 3 axis. I have 50 measurements per second, and my ultimate goal is to subset those measurements, i.e. to select randomly 30 of them (per second).

The dataset looks like this:

> head(ACCL_20220211_190222_)
# A tibble: 6 × 4
  time                    x     y     z
  <dttm>              <dbl> <dbl> <dbl>
1 2022-02-11 19:03:31 14336  6720 -6080
2 2022-02-11 19:03:31 14272  6656 -6144
3 2022-02-11 19:03:31 14208  6720 -5952
4 2022-02-11 19:03:31 14272  6656 -5952
5 2022-02-11 19:03:31 14272  6592 -6080
6 2022-02-11 19:03:31 14208  6528 -6016

I first tried this:

ACCL_20220211_190222_s <- ACCL_20220211_190222_ %>% group_by(time) %>% dplyr::slice_sample(n=30)

Which didn't work out, and I think it is because the time values are not really unique, even though it looks like they are. Because when I use the unique() function, I get the 50 values per "unique" time, and not just one (also, see the output of dput() below).

So I thought I could create a column grouping the time variable, but it is not working out, and I think it is because of the same issue.

This code below creates a column grouping_variable with a single value, 1.

ACCL_20220211_190222_s <- ACCL_20220211_190222_ %>% 
  group_by(time) %>% 
  mutate(grouping_var = match(time, sort(unique(time))))

So, how can I group this column? Or, if there's a direct way of subsampling the values, from 50 per second to 30, even better!


Here's an example of the dataset (it has dates/times for 10 seconds, so it should create 10 groups):

> dput(ACCL_20220211_190222_)
structure(list(time = structure(c(1644606211.007, 1644606211.027, 
1644606211.048, 1644606211.068, 1644606211.089, 1644606211.109, 
1644606211.129, 1644606211.15, 1644606211.17, 1644606211.19, 
1644606211.211, 1644606211.231, 1644606211.252, 1644606211.272, 
1644606211.292, 1644606211.313, 1644606211.333, 1644606211.353, 
1644606211.374, 1644606211.394, 1644606211.415, 1644606211.435, 
1644606211.455, 1644606211.476, 1644606211.496, 1644606211.517, 
1644606211.537, 1644606211.557, 1644606211.578, 1644606211.598, 
1644606211.619, 1644606211.639, 1644606211.659, 1644606211.68, 
1644606211.7, 1644606211.72, 1644606211.741, 1644606211.761, 
1644606211.782, 1644606211.802, 1644606211.822, 1644606211.843, 
1644606211.863, 1644606211.884, 1644606211.904, 1644606211.924, 
1644606211.945, 1644606211.965, 1644606211.985, 1644606212.006, 
1644606212.026, 1644606212.047, 1644606212.067, 1644606212.087, 
1644606212.108, 1644606212.128, 1644606212.149, 1644606212.169, 
1644606212.189, 1644606212.21, 1644606212.23, 1644606212.251, 
1644606212.271, 1644606212.291, 1644606212.312, 1644606212.332, 
1644606212.352, 1644606212.373, 1644606212.393, 1644606212.414, 
1644606212.434, 1644606212.454, 1644606212.475, 1644606212.495, 
1644606212.516, 1644606212.536, 1644606212.556, 1644606212.577, 
1644606212.597, 1644606212.617, 1644606212.638, 1644606212.658, 
1644606212.679, 1644606212.699, 1644606212.719, 1644606212.74, 
1644606212.76, 1644606212.781, 1644606212.801, 1644606212.821, 
1644606212.842, 1644606212.862, 1644606212.883, 1644606212.903, 
1644606212.923, 1644606212.944, 1644606212.964, 1644606212.984, 
1644606213.005, 1644606213.025, 1644606213.046, 1644606213.066, 
1644606213.086, 1644606213.107, 1644606213.127, 1644606213.147, 
1644606213.168, 1644606213.188, 1644606213.209, 1644606213.229, 
1644606213.249, 1644606213.27, 1644606213.29, 1644606213.311, 
1644606213.331, 1644606213.351, 1644606213.372, 1644606213.392, 
1644606213.413, 1644606213.433, 1644606213.453, 1644606213.474, 
1644606213.494, 1644606213.515, 1644606213.535, 1644606213.555, 
1644606213.576, 1644606213.596, 1644606213.616, 1644606213.637, 
1644606213.657, 1644606213.678, 1644606213.698, 1644606213.718, 
1644606213.739, 1644606213.759, 1644606213.78, 1644606213.8, 
1644606213.82, 1644606213.841, 1644606213.861, 1644606213.882, 
1644606213.902, 1644606213.922, 1644606213.943, 1644606213.963, 
1644606213.984, 1644606214.004, 1644606214.024, 1644606214.045, 
1644606214.065, 1644606214.085, 1644606214.106, 1644606214.126, 
1644606214.147, 1644606214.167, 1644606214.187, 1644606214.208, 
1644606214.228, 1644606214.249, 1644606214.269, 1644606214.289, 
1644606214.31, 1644606214.33, 1644606214.351, 1644606214.371, 
1644606214.391, 1644606214.412, 1644606214.432, 1644606214.452, 
1644606214.473, 1644606214.493, 1644606214.514, 1644606214.534, 
1644606214.554, 1644606214.575, 1644606214.595, 1644606214.616, 
1644606214.636, 1644606214.656, 1644606214.677, 1644606214.697, 
1644606214.718, 1644606214.738, 1644606214.758, 1644606214.779, 
1644606214.799, 1644606214.819, 1644606214.84, 1644606214.86, 
1644606214.881, 1644606214.901, 1644606214.921, 1644606214.942, 
1644606214.962, 1644606214.983, 1644606215.003, 1644606215.023, 
1644606215.044, 1644606215.064, 1644606215.085, 1644606215.105, 
1644606215.125, 1644606215.146, 1644606215.166, 1644606215.186, 
1644606215.207, 1644606215.227, 1644606215.248, 1644606215.268, 
1644606215.288, 1644606215.309, 1644606215.329, 1644606215.35, 
1644606215.37, 1644606215.39, 1644606215.411, 1644606215.431, 
1644606215.452, 1644606215.472, 1644606215.492, 1644606215.513, 
1644606215.533, 1644606215.553, 1644606215.574, 1644606215.594, 
1644606215.615, 1644606215.635, 1644606215.655, 1644606215.676, 
1644606215.696, 1644606215.717, 1644606215.737, 1644606215.757, 
1644606215.778, 1644606215.798, 1644606215.819, 1644606215.839, 
1644606215.859, 1644606215.88, 1644606215.9, 1644606215.92, 1644606215.941, 
1644606215.961, 1644606215.982, 1644606216.002, 1644606216.022, 
1644606216.043, 1644606216.063, 1644606216.083, 1644606216.104, 
1644606216.124, 1644606216.145, 1644606216.165, 1644606216.185, 
1644606216.206, 1644606216.226, 1644606216.247, 1644606216.267, 
1644606216.287, 1644606216.308, 1644606216.328, 1644606216.349, 
1644606216.369, 1644606216.389, 1644606216.41, 1644606216.43, 
1644606216.451, 1644606216.471, 1644606216.491, 1644606216.512, 
1644606216.532, 1644606216.552, 1644606216.573, 1644606216.593, 
1644606216.614, 1644606216.634, 1644606216.654, 1644606216.675, 
1644606216.695, 1644606216.716, 1644606216.736, 1644606216.756, 
1644606216.777, 1644606216.797, 1644606216.818, 1644606216.838, 
1644606216.858, 1644606216.879, 1644606216.899, 1644606216.92, 
1644606216.94, 1644606216.96, 1644606216.981, 1644606217.001, 
1644606217.021, 1644606217.042, 1644606217.062, 1644606217.083, 
1644606217.103, 1644606217.123, 1644606217.144, 1644606217.164, 
1644606217.185, 1644606217.205, 1644606217.225, 1644606217.246, 
1644606217.266, 1644606217.286, 1644606217.307, 1644606217.327, 
1644606217.348, 1644606217.368, 1644606217.388, 1644606217.409, 
1644606217.429, 1644606217.45, 1644606217.47, 1644606217.49, 
1644606217.511, 1644606217.531, 1644606217.551, 1644606217.572, 
1644606217.592, 1644606217.613, 1644606217.633, 1644606217.653, 
1644606217.674, 1644606217.694, 1644606217.715, 1644606217.735, 
1644606217.755, 1644606217.776, 1644606217.796, 1644606217.816, 
1644606217.837, 1644606217.857, 1644606217.878, 1644606217.898, 
1644606217.918, 1644606217.939, 1644606217.959, 1644606217.979, 
1644606218, 1644606218.02, 1644606218.041, 1644606218.061, 1644606218.081, 
1644606218.102, 1644606218.122, 1644606218.143, 1644606218.163, 
1644606218.183, 1644606218.204, 1644606218.224, 1644606218.244, 
1644606218.265, 1644606218.285, 1644606218.306, 1644606218.326, 
1644606218.346, 1644606218.367, 1644606218.387, 1644606218.408, 
1644606218.428, 1644606218.448, 1644606218.469, 1644606218.489, 
1644606218.509, 1644606218.53, 1644606218.55, 1644606218.571, 
1644606218.591, 1644606218.611, 1644606218.632, 1644606218.652, 
1644606218.673, 1644606218.693, 1644606218.713, 1644606218.734, 
1644606218.754, 1644606218.774, 1644606218.795, 1644606218.815, 
1644606218.836, 1644606218.856, 1644606218.876, 1644606218.897, 
1644606218.917, 1644606218.937, 1644606218.958, 1644606218.978, 
1644606218.999, 1644606219.019, 1644606219.039, 1644606219.06, 
1644606219.08, 1644606219.101, 1644606219.121, 1644606219.141, 
1644606219.162, 1644606219.182, 1644606219.203, 1644606219.223, 
1644606219.243, 1644606219.264, 1644606219.284, 1644606219.304, 
1644606219.325, 1644606219.345, 1644606219.366, 1644606219.386, 
1644606219.406, 1644606219.427, 1644606219.447, 1644606219.468, 
1644606219.488, 1644606219.508, 1644606219.529, 1644606219.549, 
1644606219.569, 1644606219.59, 1644606219.61, 1644606219.631, 
1644606219.651, 1644606219.671, 1644606219.692, 1644606219.712, 
1644606219.733, 1644606219.753, 1644606219.773, 1644606219.794, 
1644606219.814, 1644606219.835, 1644606219.855, 1644606219.875, 
1644606219.896, 1644606219.916, 1644606219.936, 1644606219.957, 
1644606219.977, 1644606219.998, 1644606220.018, 1644606220.038, 
1644606220.059, 1644606220.079, 1644606220.1, 1644606220.12, 
1644606220.14, 1644606220.161, 1644606220.181, 1644606220.202, 
1644606220.222, 1644606220.242, 1644606220.263, 1644606220.283, 
1644606220.304, 1644606220.324, 1644606220.344, 1644606220.365, 
1644606220.385, 1644606220.405, 1644606220.426, 1644606220.446, 
1644606220.467, 1644606220.487, 1644606220.507, 1644606220.528, 
1644606220.548, 1644606220.569, 1644606220.589, 1644606220.609, 
1644606220.63, 1644606220.65, 1644606220.67, 1644606220.691, 
1644606220.711, 1644606220.732, 1644606220.752, 1644606220.772, 
1644606220.793, 1644606220.813, 1644606220.834, 1644606220.854, 
1644606220.874, 1644606220.895, 1644606220.915, 1644606220.936, 
1644606220.957, 1644606220.976, 1644606220.997), tzone = "UTC", class = c("POSIXct", 
"POSIXt")), x = c(14336, 14272, 14208, 14272, 14272, 14208, 14144, 
14336, 14208, 14272, 14144, 14208, 14336, 14336, 14208, 14272, 
14144, 14080, 14272, 14272, 14272, 14144, 14400, 14400, 14272, 
14400, 14272, 14336, 14272, 14208, 14272, 14336, 14144, 14208, 
14208, 14080, 14272, 14336, 14400, 14336, 14272, 14144, 14272, 
14208, 14080, 14272, 14080, 14400, 14080, 14208, 14336, 14336, 
14144, 14272, 14272, 14144, 14272, 14272, 14272, 14336, 14208, 
14336, 14336, 14400, 14400, 14272, 14336, 14272, 14336, 14144, 
14144, 14272, 14208, 14144, 14144, 14208, 14272, 14272, 14080, 
14208, 14208, 14208, 14144, 14272, 14272, 14336, 14208, 14336, 
14400, 14336, 14336, 14144, 14272, 14144, 14336, 14144, 14336, 
14144, 14272, 14400, 14272, 14336, 14272, 14336, 14208, 14272, 
14144, 14144, 14208, 14208, 14208, 14272, 14080, 14400, 14336, 
14336, 14400, 14400, 14272, 14272, 14208, 14080, 14272, 14272, 
14400, 14336, 14400, 14464, 14336, 14400, 14144, 14144, 14080, 
14080, 14080, 14272, 14272, 14208, 14144, 14464, 14336, 14400, 
14208, 14208, 14080, 14272, 14144, 14272, 14208, 14208, 14336, 
14336, 14272, 14336, 14272, 14336, 14144, 14272, 14272, 14272, 
14272, 14272, 14016, 14336, 14208, 14208, 14336, 14208, 14144, 
14144, 14272, 14080, 14144, 14208, 14208, 14208, 14080, 14144, 
14144, 14208, 14272, 14272, 14336, 14080, 14208, 14336, 13952, 
14016, 14144, 14144, 14080, 14144, 14144, 14144, 14208, 14208, 
14208, 14080, 14208, 14208, 14272, 14208, 14144, 14080, 14208, 
14080, 14208, 14144, 14144, 14272, 14208, 14144, 14144, 14400, 
14272, 14144, 14208, 14208, 14144, 14080, 14144, 14080, 14208, 
14336, 14208, 14272, 14144, 14208, 14144, 14144, 14144, 14144, 
14144, 14208, 14144, 14016, 14144, 14336, 14208, 14208, 14208, 
14144, 14144, 14080, 13952, 14208, 14272, 14272, 14272, 14272, 
14272, 14144, 14208, 14144, 14144, 14144, 14080, 14272, 14080, 
14208, 14208, 14080, 14208, 14336, 14144, 14272, 14400, 14208, 
14272, 14080, 14080, 14272, 13760, 14208, 14016, 14272, 14208, 
14208, 14208, 14272, 14144, 14080, 14144, 14016, 14016, 14080, 
13952, 14016, 13888, 14080, 14144, 14144, 14080, 14208, 14144, 
14208, 14208, 14144, 14144, 14272, 14208, 14208, 14208, 14144, 
14144, 14272, 14208, 14080, 14272, 14272, 14144, 14272, 14080, 
14144, 14208, 14336, 14144, 14208, 14080, 14208, 14080, 14208, 
13952, 14144, 14272, 14272, 14208, 14080, 14272, 14144, 14144, 
14272, 14208, 14144, 14208, 14144, 14144, 14144, 14080, 14272, 
14144, 14208, 14272, 14080, 14080, 14208, 14144, 14144, 14208, 
14080, 14208, 14208, 14272, 14208, 14272, 14144, 14336, 14208, 
14272, 14080, 14016, 14080, 14208, 14016, 14208, 14080, 14208, 
14208, 14016, 14144, 14336, 14144, 14144, 14208, 14144, 14272, 
14080, 14144, 14080, 14208, 14144, 14144, 14272, 14208, 14272, 
14080, 14016, 14016, 14336, 14144, 14208, 14208, 14208, 14208, 
14144, 14144, 14208, 14080, 14144, 14208, 14272, 14208, 14144, 
14208, 14272, 14080, 14208, 14144, 14144, 14208, 14144, 14080, 
14208, 14272, 14208, 14336, 14080, 14208, 14016, 14144, 14016, 
14080, 14144, 14272, 14144, 14208, 14208, 14208, 14208, 14272, 
14144, 14080, 14272, 13952, 14208, 14208, 14208, 14144, 14144, 
14144, 14208, 14080, 14272, 14208, 14272, 14208, 14144, 14080, 
14144, 14080, 14016, 14144, 14272, 14272, 14208, 14144, 14144, 
14080, 14144, 14144, 14144, 14144, 14144, 14272, 14208, 14080, 
14336, 14080, 14272, 14272, 14208, 14144, 14144, 14208, 14144, 
14144, 14144, 14144, 14208, 14080, 14016, 14080, 14144, 14016, 
14080, 14080, 14144, 14080, 14016, 14208, 14208), y = c(6720, 
6656, 6720, 6656, 6592, 6528, 6528, 6592, 6656, 6592, 6784, 6656, 
6720, 6720, 6528, 6592, 6720, 6656, 6592, 6720, 6592, 6720, 6784, 
6784, 6656, 6720, 6592, 6592, 6720, 6720, 6592, 6592, 6784, 6592, 
6720, 6592, 6656, 6720, 6592, 6528, 6656, 6720, 6720, 6656, 6592, 
6464, 6592, 6592, 6720, 6720, 6720, 6784, 6656, 6592, 6656, 6592, 
6528, 6656, 6528, 6656, 6656, 6528, 6656, 6592, 6656, 6592, 6720, 
6784, 6528, 6528, 6464, 6656, 6720, 6464, 6528, 6720, 6784, 6656, 
6592, 6720, 6656, 6528, 6656, 6720, 6592, 6592, 6656, 6720, 6784, 
6656, 6528, 6592, 6720, 6528, 6400, 6528, 6592, 6720, 6528, 6720, 
6592, 6720, 6656, 6528, 6528, 6528, 6528, 6656, 6528, 6592, 6656, 
6592, 6528, 6720, 6656, 6656, 6528, 6464, 6464, 6592, 6336, 6528, 
6464, 6656, 6656, 6528, 6464, 6720, 6656, 6592, 6592, 6400, 6464, 
6400, 6784, 6592, 6592, 6720, 6720, 6720, 6656, 6528, 6528, 6592, 
6656, 6528, 6528, 6592, 6528, 6592, 6784, 6720, 6592, 6720, 6656, 
6656, 6528, 6464, 6592, 6720, 6592, 6720, 6592, 6592, 6592, 6528, 
6656, 6592, 6656, 6656, 6400, 6400, 6528, 6656, 6528, 6592, 6656, 
6848, 6720, 6528, 6528, 6656, 6592, 6720, 6592, 6656, 6528, 6592, 
6528, 6592, 6528, 6464, 6784, 6592, 6592, 6464, 6656, 6656, 6784, 
6784, 6656, 6784, 6784, 6592, 6592, 6592, 6784, 6656, 6592, 6592, 
6720, 6592, 6528, 6592, 6656, 6592, 6464, 6656, 6592, 6720, 6592, 
6592, 6720, 6720, 6720, 6464, 6656, 6720, 6656, 6592, 6656, 6592, 
6656, 6720, 6656, 6912, 6720, 6656, 6720, 6592, 6528, 6656, 6656, 
6656, 6656, 6528, 6784, 6784, 6720, 6528, 6720, 6720, 6656, 6592, 
6400, 6592, 6720, 6656, 6592, 6656, 6848, 6656, 6656, 6720, 6592, 
6592, 6592, 6464, 6912, 6656, 6592, 6272, 6528, 6464, 6592, 6336, 
6528, 6592, 6784, 6720, 6656, 6656, 6592, 6528, 6464, 6464, 6464, 
6528, 6592, 6464, 6656, 6592, 6592, 6720, 6720, 6656, 6464, 6592, 
6528, 6592, 6592, 6464, 6528, 6528, 6784, 6528, 6656, 6592, 6528, 
6784, 6656, 6464, 6656, 6592, 6592, 6656, 6656, 6592, 6656, 6720, 
6656, 6528, 6464, 6720, 6656, 6592, 6592, 6784, 6720, 6720, 6656, 
6592, 6656, 6464, 6592, 6528, 6720, 6848, 6656, 6592, 6656, 6528, 
6592, 6784, 6912, 6656, 6400, 6656, 6528, 6528, 6592, 6656, 6784, 
6912, 6656, 6656, 6400, 6720, 6592, 6592, 6592, 6656, 6656, 6656, 
6656, 6592, 6592, 6592, 6784, 6656, 6464, 6720, 6592, 6720, 6720, 
6592, 6656, 6784, 6784, 6592, 6592, 6656, 6784, 6656, 6592, 6656, 
6656, 6592, 6592, 6720, 6656, 6592, 6528, 6656, 6592, 6592, 6592, 
6656, 6656, 6592, 6528, 6656, 6656, 6656, 6592, 6400, 6656, 6656, 
6464, 6656, 6720, 6848, 6720, 6656, 6656, 6720, 6720, 6336, 6528, 
6720, 6656, 6464, 6528, 6592, 6656, 6656, 6592, 6528, 6656, 6656, 
6464, 6400, 6592, 6528, 6528, 6720, 6592, 6656, 6656, 6592, 6592, 
6656, 6528, 6656, 6784, 6976, 6592, 6464, 6656, 6656, 6720, 6720, 
6528, 6528, 6720, 6592, 6592, 6464, 6464, 6464, 6528, 6656, 6656, 
6592, 6656, 6592, 6656, 6528, 6592, 6528, 6464, 6656, 6464, 6528, 
6464, 6592, 6656, 6592, 6592, 6656, 6656, 6592, 6656, 6464, 6528, 
6400, 6592, 6464, 6528, 6528, 6656), z = c(-6080, -6144, -5952, 
-5952, -6080, -6016, -5888, -6016, -6080, -6016, -6016, -6016, 
-6016, -6080, -6208, -6016, -5888, -5952, -6144, -5952, -5888, 
-5952, -6016, -5760, -6080, -5824, -6016, -6016, -5952, -6272, 
-6080, -5952, -5824, -6016, -5888, -5760, -5760, -5952, -6272, 
-6272, -5888, -5760, -5760, -6208, -6080, -6016, -6016, -5952, 
-6080, -6272, -6016, -6016, -6080, -6016, -6016, -6016, -6080, 
-6080, -6016, -5952, -6016, -5888, -5952, -6080, -6208, -5952, 
-5824, -5952, -5888, -6016, -5824, -5888, -6080, -6016, -6144, 
-6144, -6272, -5952, -6080, -6016, -6144, -5952, -6016, -6016, 
-6080, -5952, -6016, -6208, -6080, -6208, -6272, -5952, -6080, 
-6080, -6144, -5952, -6080, -6016, -5952, -6016, -6016, -6144, 
-6144, -6080, -6144, -6144, -6016, -5952, -6080, -6080, -6016, 
-6144, -5888, -6080, -6144, -6144, -6080, -5760, -6016, -5952, 
-5952, -5952, -6144, -6080, -6144, -6272, -6272, -6272, -6144, 
-6144, -6080, -6080, -6080, -6080, -5952, -6208, -6336, -6016, 
-6144, -6144, -6208, -6336, -6080, -5888, -6016, -6144, -6080, 
-6080, -6016, -6272, -6144, -6208, -6208, -6080, -6016, -6144, 
-6144, -6144, -6016, -6144, -6080, -6144, -6144, -6272, -6144, 
-6336, -6272, -6208, -6016, -6080, -6656, -6272, -6016, -6016, 
-6208, -6208, -6272, -6144, -6208, -6272, -6144, -6272, -6144, 
-6144, -6336, -6208, -6144, -6208, -6080, -6464, -6464, -6144, 
-6208, -6144, -6080, -6208, -6208, -6208, -6336, -6208, -6336, 
-6272, -6208, -6272, -6208, -6144, -6080, -6144, -6336, -6144, 
-6208, -6272, -6272, -6208, -6336, -6400, -6080, -6208, -6272, 
-6208, -6080, -6144, -6144, -6144, -6208, -6272, -6336, -6144, 
-6336, -6208, -6208, -6144, -6208, -6208, -6208, -6208, -6272, 
-6144, -6336, -6400, -6272, -6016, -6144, -6400, -6400, -6080, 
-6208, -6208, -6272, -6336, -6208, -6144, -6208, -6080, -6144, 
-6272, -6144, -6080, -6080, -6272, -6336, -6144, -6464, -6080, 
-6528, -5888, -6464, -6144, -6016, -6208, -6272, -6080, -6400, 
-6272, -6336, -6592, -6400, -6528, -6464, -6208, -6272, -6272, 
-6336, -6464, -6784, -6272, -6336, -6144, -6272, -6400, -6656, 
-6336, -6464, -6272, -6208, -6144, -6272, -6272, -6400, -6400, 
-6272, -6400, -6400, -6464, -6400, -6400, -6272, -6336, -6336, 
-6400, -6336, -6400, -5952, -6336, -6272, -6528, -6464, -6272, 
-5952, -6272, -6336, -6400, -6272, -6272, -6272, -6336, -6272, 
-6208, -6400, -6400, -6208, -6208, -6336, -6208, -6208, -6144, 
-6208, -6208, -6208, -6080, -6272, -6528, -6464, -6272, -6208, 
-6464, -6272, -6144, -6080, -6144, -6528, -6592, -6464, -6144, 
-6464, -6272, -6336, -6272, -6272, -6144, -6272, -6336, -6208, 
-6336, -6336, -6464, -6400, -6336, -6144, -6336, -6400, -6080, 
-6080, -6208, -6208, -6400, -6528, -6400, -6272, -6208, -6208, 
-6336, -6272, -6144, -6208, -6272, -6208, -6208, -6208, -6336, 
-6400, -6144, -6208, -6208, -6464, -6272, -6336, -6336, -6272, 
-6016, -6272, -6400, -6272, -6464, -6080, -6208, -6400, -6208, 
-6144, -6272, -6400, -6400, -6336, -6336, -6080, -6528, -6400, 
-6080, -6144, -6208, -6400, -6336, -6144, -6272, -6208, -6400, 
-6400, -6400, -6400, -6272, -6208, -6400, -6272, -6400, -6144, 
-6144, -6272, -6336, -6336, -6528, -6400, -6400, -6528, -6144, 
-6208, -6272, -6336, -6272, -6208, -6272, -6464, -6400, -6400, 
-6464, -6400, -6400, -6336, -6336, -6336, -6336, -6272, -6464, 
-6208, -6272, -6208, -6272, -6272, -6336, -6464, -6464, -6208, 
-6208, -6400, -6336, -6464, -6336, -6144, -6464, -6464, -6208, 
-6464, -6464, -6272, -6272, -6272, -6336, -6464, -6272, -6400, 
-6400, -6336)), row.names = c(NA, -491L), class = c("tbl_df", 
"tbl", "data.frame"))

Solution

  • As you assumed, the date-times are not the same, they are saved with microseconds information which can be returned with e.g.

    format.Date(ACCL_20220211_190222_$time, "%H:%M:%OS3")
    [1] "20:03:31.006" "20:03:31.026" "20:03:31.048" "20:03:31.068" "20:03:31.088"
    [6] "20:03:31.108" "20:03:31.128" "20:03:31.150" "20:03:31.170" "20:03:31.190"
    

    If you want to go with your approach you can group by the complete string

    library(dplyr)
    
    ACCL_20220211_190222_ %>% 
      group_by(grp = format.Date(time, "%F %T")) %>% 
      slice_sample(n=30)