我正在寻找一种优雅的方式来创建这些数据的表:
我有一个我感兴趣的日期向量
> date
[1] "2008-01-01" "2008-01-02" "2008-01-03" "2008-01-04" "2008-01-05"
以及来自维基百科的数据表(每天的浏览量)
> changes
2007-08-14 2007-08-16 2007-08-17 2007-12-29 2008-01-01 2008-01-03 2008-01-05
4 1 4 1 1 1 2
我想要的是一张包含我感兴趣的日期数据的表格
> mytable
2008-01-01 2008-01-02 2008-01-03 2008-01-04 2008-01-05
1 0 1 0 2
谁能给我一个关于如何优雅地做到这一点的提示?
这是dput的输出:
> dput(date)
structure(c(13879, 13880, 13881, 13882, 13883), class = "Date")
和
> dput(changes)
structure(c(15L, 2L, 9L, 1L, 1L, 1L, 3L), .Dim = 262L, .Dimnames = structure(list(
c("2007-08-14", "2007-08-16",
"2007-08-17", "2007-12-29", "2008-01-01", "2008-01-03", "2008-01-05")), .Names = ""), class = "table")