使用融合函数并获取错误:名称与以前的名称不匹配

时间:2017-10-31 15:16:55

标签: r reshape reshape2 melt

我创建了一个名为

的数据框
[1] "promotion"  "code"       "01.09.2016" "01.16.2016" "01.23.2016" "01.30.2016" "02.06.2016" "02.13.2016" "02.20.2016" "02.27.2016" "03.05.2016"
[12] "03.12.2016" "03.19.2016" "03.26.2016" "04.02.2016" "04.09.2016" "04.16.2016" "04.23.2016" "04.30.2016" "05.07.2016" "05.14.2016" "05.21.2016"
[23] "05.28.2016" "06.04.2016" "06.11.2016" "06.18.2016" "06.25.2016" "07.02.2016" "07.09.2016" "07.16.2016" "07.23.2016" "07.30.2016" "08.06.2016"
[34] "08.13.2016" "08.20.2016" "08.27.2016" "09.03.2016" "09.10.2016" "09.17.2016" "09.24.2016" "10.01.2016" "10.08.2016" "10.15.2016" "10.22.2016"
[45] "10.29.2016" "11.05.2016" "11.12.2016" "11.19.2016" "11.26.2016" "12.03.2016" "12.10.2016" "12.17.2016" "12.24.2016" "12.31.2016"

我使用了这段代码

melt(Scanning_Cost, names(Scanning_Cost)[1:2])

此错误显示

Error in match.names(clabs, names(xi)) : 
  names do not match previous names

我希望我的日期列出现在产品前面并显示计数

promotion   code `01.09.2016` `01.16.2016` `01.23.2016` `01.30.2016` `02.06.2016` `02.13.2016` `02.20.2016` `02.27.2016`
                              <chr>  <chr>        <lgl>        <lgl>        <lgl>        <lgl>        <dbl>        <dbl>        <dbl>        <dbl>
1   D - MA BEACH WAVES MOUSSE 8.5OZ 372548           NA           NA           NA           NA            1            1            1            1
2 M/A 100% COCONUT OIL JAR     10OZ 968701           NA           NA           NA           NA            1            1            1            1
3 M/A BYE FRIZZ 30DAY KRTN SMT3.38Z 178685           NA           NA           NA           NA            1            1            1            1
4 M/A BYE GRY TMP SPRY L/M BRN1.5OZ 373984           NA           NA           NA           NA            1            1            1            1
5 M/A BYE GRY TMP SPRY M/D B/B1.5OZ 373985           NA           NA           NA           NA            1            1            1            1
6 M/A COCO CREAM CRL CD       8.4OZ 968704           NA           NA           NA           NA            1            1            1            1

0 个答案:

没有答案