gpt4 book ai didi

r - 使用 R 生成均匀分布的随机时间数据

转载 作者:行者123 更新时间:2023-12-02 20:38:00 25 4
gpt4 key购买 nike

给定开始时间 7:00 和结束时间 8:00 日期 2017-10-08,需要生成一组 100均匀分布在 7:00 到 8:00 之间的随机时间数据。想知道如何使用 R 实现这一点?

最佳答案

也许这可以帮到你。

as.POSIXct(" 2017-10-08 07:00:00") + runif(n=100, min=0, max=3600)

输出:

  [1] "2017-10-08 07:11:22 -03" "2017-10-08 07:56:56 -03" "2017-10-08 07:32:49 -03" "2017-10-08 07:10:02 -03" "2017-10-08 07:26:02 -03"
[6] "2017-10-08 07:12:55 -03" "2017-10-08 07:38:02 -03" "2017-10-08 07:13:53 -03" "2017-10-08 07:53:55 -03" "2017-10-08 07:45:38 -03"
[11] "2017-10-08 07:10:45 -03" "2017-10-08 07:12:59 -03" "2017-10-08 07:04:53 -03" "2017-10-08 07:48:45 -03" "2017-10-08 07:51:55 -03"
[16] "2017-10-08 07:15:12 -03" "2017-10-08 07:46:31 -03" "2017-10-08 07:26:50 -03" "2017-10-08 07:27:28 -03" "2017-10-08 07:42:02 -03"
[21] "2017-10-08 07:11:13 -03" "2017-10-08 07:35:57 -03" "2017-10-08 07:42:43 -03" "2017-10-08 07:40:35 -03" "2017-10-08 07:30:59 -03"
[26] "2017-10-08 07:51:16 -03" "2017-10-08 07:11:29 -03" "2017-10-08 07:23:11 -03" "2017-10-08 07:34:58 -03" "2017-10-08 07:37:49 -03"
[31] "2017-10-08 07:49:24 -03" "2017-10-08 07:27:57 -03" "2017-10-08 07:37:27 -03" "2017-10-08 07:17:23 -03" "2017-10-08 07:00:49 -03"
[36] "2017-10-08 07:14:36 -03" "2017-10-08 07:05:32 -03" "2017-10-08 07:15:23 -03" "2017-10-08 07:33:12 -03" "2017-10-08 07:15:34 -03"
[41] "2017-10-08 07:14:20 -03" "2017-10-08 07:17:27 -03" "2017-10-08 07:47:07 -03" "2017-10-08 07:55:27 -03" "2017-10-08 07:56:49 -03"
[46] "2017-10-08 07:28:29 -03" "2017-10-08 07:04:51 -03" "2017-10-08 07:38:32 -03" "2017-10-08 07:50:14 -03" "2017-10-08 07:57:57 -03"
[51] "2017-10-08 07:58:50 -03" "2017-10-08 07:58:44 -03" "2017-10-08 07:20:31 -03" "2017-10-08 07:29:57 -03" "2017-10-08 07:52:57 -03"
[56] "2017-10-08 07:12:29 -03" "2017-10-08 07:00:36 -03" "2017-10-08 07:33:28 -03" "2017-10-08 07:40:45 -03" "2017-10-08 07:12:52 -03"
[61] "2017-10-08 07:04:53 -03" "2017-10-08 07:43:30 -03" "2017-10-08 07:55:45 -03" "2017-10-08 07:46:15 -03" "2017-10-08 07:47:29 -03"
[66] "2017-10-08 07:42:28 -03" "2017-10-08 07:43:54 -03" "2017-10-08 07:04:10 -03" "2017-10-08 07:30:10 -03" "2017-10-08 07:06:09 -03"
[71] "2017-10-08 07:14:43 -03" "2017-10-08 07:38:22 -03" "2017-10-08 07:39:23 -03" "2017-10-08 07:36:41 -03" "2017-10-08 07:22:37 -03"
[76] "2017-10-08 07:30:30 -03" "2017-10-08 07:28:44 -03" "2017-10-08 07:23:47 -03" "2017-10-08 07:10:21 -03" "2017-10-08 07:24:31 -03"
[81] "2017-10-08 07:09:41 -03" "2017-10-08 07:14:44 -03" "2017-10-08 07:22:36 -03" "2017-10-08 07:42:37 -03" "2017-10-08 07:04:02 -03"
[86] "2017-10-08 07:03:18 -03" "2017-10-08 07:09:34 -03" "2017-10-08 07:59:47 -03" "2017-10-08 07:54:39 -03" "2017-10-08 07:09:47 -03"
[91] "2017-10-08 07:43:30 -03" "2017-10-08 07:31:38 -03" "2017-10-08 07:16:34 -03" "2017-10-08 07:45:48 -03" "2017-10-08 07:44:07 -03"
[96] "2017-10-08 07:09:02 -03" "2017-10-08 07:19:53 -03" "2017-10-08 07:07:28 -03" "2017-10-08 07:35:23 -03" "2017-10-08 07:38:06 -03"

关于r - 使用 R 生成均匀分布的随机时间数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46595060/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com