我有一组面板数据,我需要从另一个数据框中插入日期。
allweeks <- seq(as.Date("2013-01-05"),
as.Date("2013-12-28"),
by="1 week")
以上是日期的数据。下面是我的数据集,每周运行 1 到 40 次观察。
mydata
Pos LW WKs Artist Title
1 1 NEW 1 SAM_BAILEY SKYSCRAPER
2 2 4 5 PHARRELL_WILLIAMS HAPPY
3 3 3 3 LEONA_LEWIS ONE_MORE_SLEEP
4 4 NEW 5 AC/DC HIGHWAY_TO_HELL
5 5 2 13 AVICII HEY_BROTHER
6 6 1 6 LILY_ALLEN SOMEWHERE_ONLY_WE_KNOW
... ... ...
39 39 NEW 1 XYZ XYZ
40 40 4 5 XYZ XYZ
1 3 3 3 LEONA_LEWIS ONE_MORE_SLEEP
2 4 NEW 5 AC/DC HIGHWAY_TO_HELL
3 5 2 13 AVICII HEY_BROTHER
4 6 1 6 LILY_ALLEN SOMEWHERE_ONLY_WE_KNOW
所以我想从 allweeks 数据框中插入上述面板数据的每个日期 40 次,以便结果看起来像这样:
Pos LW WKs Artist Title Date
1 1 NEW 1 SAM_BAILEY SKYSCRAPER 2013-01-05
2 2 4 5 PHARRELL_WILLIAMS HAPPY 2013-01-05
3 3 3 3 LEONA_LEWIS ONE_MORE_SLEEP 2013-01-05
4 4 NEW 5 AC/DC HIGHWAY_TO_HELL 2013-01-05
5 5 2 13 AVICII HEY_BROTHER 2013-01-05
6 6 1 6 LILY_ALLEN SOMEWHERE_ONLY_WE_KNOW 2013-01-05
... ... ... ...
39 39 NEW 1 XYZ XYZ 2013-01-05
40 40 4 5 XYZ XYZ 2013-01-05
1 3 3 3 LEONA_LEWIS ONE_MORE_SLEEP 2013-01-12
2 4 NEW 5 AC/DC HIGHWAY_TO_HELL 2013-01-12
3 5 2 13 AVICII HEY_BROTHER 2013-01-12
4 6 1 6 LILY_ALLEN SOMEWHERE_ONLY_WE_KNOW 2013-01-12
任何帮助将不胜感激!