Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 将使用的时间排序为特定时间_R - Fatal编程技术网

R 将使用的时间排序为特定时间

R 将使用的时间排序为特定时间,r,R,我试图在一个小型办公网络上进行分析,但在将它们分类到特定时间时遇到了一些问题 我只知道使用: result<-with(df,table(Source,DateTime)) 因此,如果源在时间使用协议,请将它们转换为1。如果不使用,则将其转换为0。日期并不重要 result 06:00-19:59 |20:00-23:59 | 00:00-06:00 10.0.0.6 1 0 0 10.0.0.

我试图在一个小型办公网络上进行分析,但在将它们分类到特定时间时遇到了一些问题

我只知道使用:

result<-with(df,table(Source,DateTime)) 
因此,如果
时间使用
协议
,请将它们转换为
1
。如果不使用,则将其转换为
0
。日期并不重要

result 
          06:00-19:59 |20:00-23:59 | 00:00-06:00 
10.0.0.6         1         0                  0 
10.0.0.10        1         0                  0 
10.0.0.11        1         1                  0 
10.0.0.19        0         0                  1

cut
table
快速完成以下工作:

dat$bucket <- cut(as.numeric(format(dat$DateTime, "%H%M")), 
                               c(0, 600, 2000, 2359), 
                  labels=c("00:00-06:00", "06:00-20:00", "20:00-23:59"))

tab <- table(dat$Source, dat$bucket)
tab[tab>0] <- 1 # make it either 1 or 0 vs the summing table wld normally do

tab

##             00:00-06:00 06:00-20:00 20:00-23:59
##   10.0.0.10           0           1           0
##   10.0.0.11           0           1           1
##   10.0.0.19           1           0           0
##   10.0.0.6            0           1           0

dat$bucket感谢您的编辑!你确定要跳过18:00-21:59吗?哎呀!抱歉,重新编辑@感谢您的指点!对!@阿克伦。我已经试着把约会取消了,但会成功的string@akrun试过了。不删除仍然有效的日期!。非常感谢你!所以它用的是标签,以为它坏了。
dat$bucket <- cut(as.numeric(format(dat$DateTime, "%H%M")), 
                               c(0, 600, 2000, 2359), 
                  labels=c("00:00-06:00", "06:00-20:00", "20:00-23:59"))

tab <- table(dat$Source, dat$bucket)
tab[tab>0] <- 1 # make it either 1 or 0 vs the summing table wld normally do

tab

##             00:00-06:00 06:00-20:00 20:00-23:59
##   10.0.0.10           0           1           0
##   10.0.0.11           0           1           1
##   10.0.0.19           1           0           0
##   10.0.0.6            0           1           0