Attribute Time Value
pmEulRlcUserPacketThp 2013-04-30 12,51,34,17
pmEulRlcUserPacketThp 2013-04-30 84,28,17,10
pmEulRlcUserPacketThp 2013-04-30 11,43,28,15
pmEulRlcUserPacketThp 2013-04-30 80,26,17,91
pmEulRlcUserPacketThp 2013-04-30 10,41,25,13
pmEulRlcUserPacketThp 2013-04-30 97,35,23,12
我在一家公司实习!他们有这样的数据来做KS测试。值列是一个值数组,但 R 将其读取为字符。我想计算Attribute
ispmEulRlcUserPacketThp
和Time
is时所有值的总和2013-04-30
。我怎样才能做到这一点?
Attribute
包含各种 pm... 并且是从到Time
的月度数据。所以我应该为每个日期都有一个向量。请帮我解决这个问题..!30-4-2013
30-5-2013
Attribute
它不适用于行中不同的向量长度
df = read.table(text="Attribute Time Value
pmEulRlcUserPacketThp 2013-04-30 12,51,34,17
pmEulRlcUserPacketThp 2013-04-30 84,28,17,10
pmEulRlcUserPacketThp 2013-04-30 11,43,28,15
pmEulRlcUserPacketThp 2013-04-30 80,26,17,91
pmEulRlcUserPacketThp 2013-04-30 10,41,25,13
pmEulRlcUserPacketThp 2013-04-30 97,35,23,12,13",
header = TRUE, fill = TRUE, stringsAsFactors=F)
dfL <- concat.split.multiple(df, "Value", direction = "long")
"Error in data.frame(..., check.names = FALSE) :
arguments imply differing number of rows: 6, 7"
这是我得到的错误!包含不同长度向量的数据可以做什么?
对于不同的日期:
df = read.table(text="Attribute Time Value
pmEulRlcUserPacketThp 2013-04-30 12,51,34,17
pmEulRlcUserPacketThp 2013-04-29 84,28,17,10
pmEulRlcUserPacketThp 2013-04-28 11,43,28,15
pmEulRlcUserPacketThp 2013-04-27 80,26,17,91
pmEulRlcUserPacketThp 2013-04-26 10,41,25,13
pmEulRlcUserPacketThp 2013-04-25 97,35,23,12",
header = TRUE, fill = TRUE, stringsAsFactors=F)
现在我的数据看起来像这样。我已经完成了所有连接步骤 - 我现在拥有的数据是
> y
Attribute Time V1 V2 V3 V4
1 pmEulRlcUserPacketThp 2013-04-30 12 51 34 17
2 pmEulRlcUserPacketThp 2013-04-29 84 28 17 10
3 pmEulRlcUserPacketThp 2013-04-28 11 43 28 15
4 pmEulRlcUserPacketThp 2013-04-27 80 26 17 91
5 pmEulRlcUserPacketThp 2013-04-26 10 41 25 13
6 pmEulRlcUserPacketThp 2013-04-25 97 35 23 12
现在我想要的是,V1、V2、V3、V4 两个时间段的聚合——一个是(27 日到 30 日,另一个是 25 日到 26 日)。我正在使用子集,这对于包含大量元素的大量数据是不可行的。
> y1<-y[1:4,]
> y1
Attribute Time V1 V2 V3 V4
1 pmEulRlcUserPacketThp 2013-04-30 12 51 34 17
2 pmEulRlcUserPacketThp 2013-04-29 84 28 17 10
3 pmEulRlcUserPacketThp 2013-04-28 11 43 28 15
4 pmEulRlcUserPacketThp 2013-04-27 80 26 17 91
> y2<-y[-(1:4),]
> y2
Attribute Time V1 V2 V3 V4
5 pmEulRlcUserPacketThp 2013-04-26 10 41 25 13
6 pmEulRlcUserPacketThp 2013-04-25 97 35 23 12
> z1<-aggregate(V1 ~ Attribute, y1, sum)
> z1
Attribute V1
1 pmEulRlcUserPacketThp 187
> z2<-aggregate(V1 ~ Attribute, y2, sum)
> z2
Attribute V1
1 pmEulRlcUserPacketThp 107
这仅适用于两个不同时间间隔的 V1。对于其他值也必须这样做(V2、V3、V4)。这很耗时。有没有办法使用聚合来选择日期?