我有一個問題,從tidyr包收集()函數。錯誤與tidyr :: gather()當我有獨特的名稱
sample
# A tibble: 5 × 6
market_share Y2012 Y2013 Y2014 Y2015 Y2016
<chr> <dbl> <dbl> <dbl> <dbl> <dbl>
1 KAB 0.23469425 0.23513725 0.23187590 0.22940831 0.22662625
2 BGD 0.21353096 0.21352769 0.20910574 0.20035900 0.19374223
3 NN 0.16891699 0.16204919 0.16272993 0.16388675 0.16154017
4 OG 0.07648682 0.07597078 0.07945966 0.07780233 0.08069057
5 Ha 0.05092648 0.05480555 0.06434457 0.07127716 0.08054208
如果我嘗試:
sample2 <- gather(sample, market_share, period, Y2012:Y2016)
Error: Each variable must have a unique name.
Problem variables: 'market_share'
然而,每個變量似乎有一個唯一的名稱。
Ha KAB BGD NN OG
1 1 1 1 1
這似乎是人們聚集的一個共同的問題,但我不明白。
我明白了。我認爲這個錯誤在數據框的字段中單獨出現了重複的值。沒有發生在我身上我正在重複與功能的名稱。謝謝! – Prometheus