以下数据集包含一天内每分钟(x1.time
)测量的多个变量(例如x1.AI_mean
)值。每天观测1440次。我想创建一个分类变量,它将第一个1440个观测值ID1
,接下来的1440个观测值(即第二天)ID2
等等存储在一个新变量中。这是否可以通过创建一个区间范围[1;1440]或基于x1.time
变量来实现?
X x1.time x1.AI_mean x1.MAD_mean x1.SD_mean x1.ENMO_t_mean ...
1 1 00:00:00 0.3233516 0.003415065 0.004775937 0.02392688 ...
2 2 00:01:00 0.2841591 0.003029287 0.004059719 0.02370636 ...
3 3 00:02:00 0.2397491 0.002784242 0.003544154 0.02370148 ...
4 4 00:03:00 0.2307666 0.002693856 0.003508254 0.02398960 ...
5 5 00:04:00 0.2444569 0.002704939 0.003618171 0.02434014 ...
6 6 00:05:00 0.2226963 0.002611358 0.003302321 0.02355491 ...
7 7 00:06:00 0.2238880 0.002650730 0.003380582 0.02341979 ...
8 8 00:07:00 0.3994381 0.004197095 0.009734539 0.02383396 ...
9 9 00:08:00 0.9210158 0.010238607 0.017880868 0.02517337 ...
10 10 00:09:00 0.2344564 0.002713301 0.003502785 0.02341302 ...
11 11 00:10:00 0.3451940 0.003814439 0.006974292 0.02412211 ...
......
Thanks in advance:)
Try
paste0("ID", ceiling(1:nrow(df) / 1440))
或
paste0("ID", (1:nrow(df)-1) %/% 1440 + 1)