19个变量的每月相关性

时间:2017-12-21 16:32:35

标签: r

我有以下数据集,包含21列 - 19个变量,月和日期作为日期类型列。

目的是分析相关性如何随时间变化,计算一个月内汇总的变量之间的每日相关性。例如,随着时间的推移,请参阅此“月度相关性”。 (X轴为月份类型)

+------------+---------+-----+-----+--------+---------+-------------+ | Date | Month | AOV | ASP | Clicks | Traffic | Impressions | +------------+---------+-----+-----+--------+---------+-------------+ | 2017-01-01 | 2017-01 | 50 | 6 | 700 | 10000 | 4500 | +------------+---------+-----+-----+--------+---------+-------------+ | 2017-01-02 | 2017-01 | 55 | 7 | 800 | 20000 | 4600 | +------------+---------+-----+-----+--------+---------+-------------+ | 2017-02 | 2017-02 | 58 | 8 | 700 | 4599 | 2300 | +------------+---------+-----+-----+--------+---------+-------------+

目前我有以下代码,但我只能同时比较两个变量

ddply(corr,"Month",summarise,corr=cor(AOV,ASP))

我得到下表

+---------+------------+ | Month | corr | +---------+------------+ | 2017-1 | 0.4958738 | +---------+------------+ | 2017-10 | 0.8527522 | +---------+------------+ | 2017-11 | -0.2751771 | +---------+------------+ | 2017-12 | NA | +---------+------------+ | 2017-2 | 0.6596346 | +---------+------------+ | 2017-3 | 0.6399969 | +---------+------------+ | 2017-4 | 0.7926245 | +---------+------------+ | 2017-5 | 0.6429613 | +---------+------------+ | 2017-6 | 0.3824414 | +---------+------------+ | 2017-7 | 0.9154873 | +---------+------------+ | 2017-8 | 0.7235767 | +---------+------------+ | 2017-9 | 0.8264006 | +---------+------------+

我一直在使用combn来创建组合集,但我不太确定如何将它与ddply一起使用。我成对了171个组合。

combn(corr,2,simplify = F)

1 个答案:

答案 0 :(得分:0)

你可以这样做: string comando = $" delete from MyTable where IdProduccion = '{idProduccion}'"; int res = context.Database.ExecuteSqlCommand(comando); if (res < 0) throw new Exception("....")