我正在交叉检查我的代码,基本上看起来R在逻辑条件下没有给出正确的输出。怎么可能?我有一个这样的数据框:
head(hope)
times users signal log diff
1 2014-01-13 00:00:16 00250902DC7D true ON 31
2 2014-01-13 00:00:47 00250902DC7D true ON 31
3 2014-01-13 00:01:18 00250902DC7D true ON 30
4 2014-01-13 00:01:48 00250902DC7D true ON 31
5 2014-01-13 00:02:19 00250902DC7D true ON 31
6 2014-01-13 00:02:50 00250902DC7D true ON 31
在列中有14个不同的用户。如果我尝试仅选择用户'00250902FA92'的数据,我写如下:
> mmm<-hope[users=="00250902FA92",]
如果我用'head'和'tail'进行交叉检查,我就不会得到希望用户的数据:
> head(mmm)
times users signal log diff
44319 2014-01-17 12:29:28 00250902FA92 true ON 17
44324 2014-01-17 12:30:06 00250902FA92 true ON 5
44329 2014-01-17 12:30:42 00250902FA92 true ON 3
44334 2014-01-17 12:31:16 00250902FA92 true ON 15
44339 2014-01-17 12:32:01 00250902FA92 true ON 10
44344 2014-01-17 12:32:42 00250902FA92 true ON 5
* 确定 *
但是(尾巴):
> tail(mmm)
times users signal log diff
152158 2014-01-16 23:50:22 002509030E53 true ON 14
152161 2014-01-16 23:50:46 002509030E53 true ON 7
152164 2014-01-17 11:22:11 002509030E53 true ON 13
152167 2014-01-17 11:22:26 002509030E53 true ON 7
152170 2014-01-17 11:22:55 002509030E53 true ON 1
152173 2014-01-17 11:23:03 002509030E53 true ON 9
* 错误 * _ 为何选择00250903053? _
有人能帮帮我吗?
答案 0 :(得分:1)
应该是:
mmm<-hope[hope$users=="00250902FA92",]
或者
mmm<-subset( hope, users=="00250902FA92")