R按取消分组日期在顶层汇总
我有一个R代码,我试图在不取消时间分组的情况下总结代码,但R无法取消时间分组 我的桌子看起来像这样R按取消分组日期在顶层汇总,r,R,我有一个R代码,我试图在不取消时间分组的情况下总结代码,但R无法取消时间分组 我的桌子看起来像这样 Time |Zone |Main Station |Sum of Value 25/03/2019 00:30 |BW1 |BANW |4 25/03/2019 00:30 |BW2 |BANW |4 25/03/2019 00:30 |BW3 |BANW |4 25/03/2019 00:30 |BW4
Time |Zone |Main Station |Sum of Value
25/03/2019 00:30 |BW1 |BANW |4
25/03/2019 00:30 |BW2 |BANW |4
25/03/2019 00:30 |BW3 |BANW |4
25/03/2019 00:30 |BW4 |BANW |4
25/03/2019 01:30 |BW1 |BANW |2
25/03/2019 01:30 |BW3 | BANW | 6.6
25/03/2019 01:30 |BW2 | BANW | 7.2
25/03/2019 01:30 |gh1 | ty | 2
25/03/2019 01:30 |gh2 |ty | 6.6
25/03/2019 01:30 |gh3 |ty | 7.2
Time |Main Station |Sum of Value
25/03/2019 00:30 |BANW |16
25/03/2019 01:30 | BANW |9.2
我想找一张这样的桌子
Time |Zone |Main Station |Sum of Value
25/03/2019 00:30 |BW1 |BANW |4
25/03/2019 00:30 |BW2 |BANW |4
25/03/2019 00:30 |BW3 |BANW |4
25/03/2019 00:30 |BW4 |BANW |4
25/03/2019 01:30 |BW1 |BANW |2
25/03/2019 01:30 |BW3 | BANW | 6.6
25/03/2019 01:30 |BW2 | BANW | 7.2
25/03/2019 01:30 |gh1 | ty | 2
25/03/2019 01:30 |gh2 |ty | 6.6
25/03/2019 01:30 |gh3 |ty | 7.2
Time |Main Station |Sum of Value
25/03/2019 00:30 |BANW |16
25/03/2019 01:30 | BANW |9.2
我试图找到每个时间戳的各个站点的所有区域的总和
当我总结时,输出是区域的形式,而不是站点名称,Pivot表示无法求和时间,因为我不想按时间分组,而不是保持时间不变,只求和各个站点的区域值
还尝试使用lubridate软件包将时间转换为小时格式,但输出仍然是区域形式,出现了关于TIBLE的警告。数据集$time%groupby(time,Main Station)%%>%summary(值之和=值之和))
dataset$Time <- as.character(dataset$Time)
dataset%>%group_by(Time,Main Station)%>%summarise(Sum of Value=sum(Sum of Value))
以上代码将根据您的要求工作 请您在问题中使用
dput(您的_数据)
包含您的数据样本,好吗?这将让我们以与您相同的形式加载数据。我对您的目标有点不清楚:您的表格似乎按时间和站点显示总计,但您的问题是您希望“对各个站点的分区值求和”?您所指的与“Pivot”相关的代码是什么?使用dplyr
,我想您需要类似于your_data%>%group_by(Time,'Main Station')%%>%summary('Sum of Value'=Sum('Sum of Value'))
请使用dput
功能向我们展示您正在使用的代码、您收到的实际错误消息以及您数据的代表性样本。否则,我们只能猜测您正在尝试做什么以及出现了什么问题