1
我有來自IMF IFS的季度時間序列經濟數據,我需要進入長期形式。R在整形時間序列數據
現在,行是每個國家的變量,列是時間,所以它看起來像這樣。
country variable Q1 Q2
[1,] "USA" "inflation" "1" "5"
[2,] "USA" "GDPPC" "2" "6"
[3,] "UK" "inflation" "3" "7"
[4,] "UK" "GDPPC" "4" "8"
我需要得到它變成長型:
country Time inflation GDPPC
[1,] "USA" "Q1" "1" "2"
[2,] "USA" "Q2" "5" "6"
[3,] "UK" "Q1" "3" "4"
[4,] "UK" "Q2" "7" "8"
我一直沒能找到關於使用重塑當ID變量和測量變量都在行的任何建議。