次のようなデータフレームがあります。
created_at actor_attributes_email type
3/11/12 7:28 jeremy@asynk.ch PushEvent
3/11/12 7:28 jeremy@asynk.ch PushEvent
3/11/12 7:28 jeremy@asynk.ch PushEvent
3/11/12 7:42 jeremy@asynk.ch IssueCommentEvent
3/11/12 11:06 d.bussink@gmail.com PushEvent
3/11/12 11:06 d.bussink@gmail.com PushEvent
次に、月/年で並べ替えます(時間で並べ替え、行の整合性を維持します)。これにより、各月に3つの列が作成され、その月に関連するすべてのデータ(created_at、actor_attributes_email、およびtype)がこれらの3つの列に配置され、次のヘッダーが取得されます(データに存在するすべての月)。
april_2011_created_at april_2011_actor_attributes_email april_2011_type may_2011_created_at may_2011_actor_attributes_email may_2011_type
Rでこれをどのように達成できますか?
データセット全体を含むCSVファイルはここにあります: https ://github.com/aronlindberg/VOSS-Sequencing-Toolkit/blob/master/rubinius_rubinius_sequencing/rubinius_6months.csv
dput()
CSVの最初の行は次のとおりです。
structure(list(created_at = structure(c(1L, 1L, 1L, 2L, 2L, 2L,
3L, 3L, 3L, 4L, 4L, 4L, 5L, 5L, 5L, 6L, 6L, 6L, 7L, 7L, 7L, 8L,
8L, 8L, 9L, 9L, 9L, 10L, 10L, 10L), .Label = c("2012-03-11 07:28:04",
"2012-03-11 07:28:19", "2012-03-11 07:42:16", "2012-03-11 11:06:13",
"2012-03-11 12:46:25", "2012-03-11 13:03:12", "2012-03-11 13:12:34",
"2012-03-11 13:14:52", "2012-03-11 13:30:14", "2012-03-11 13:30:48"
), class = "factor"), actor_attributes_email = structure(c(3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("",
"d.bussink@gmail.com", "jeremy@asynk.ch"), class = "factor"),
type = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L), .Label = c("IssueCommentEvent", "PushEvent"
), class = "factor")), .Names = c("created_at", "actor_attributes_email",
"type"), class = "data.frame", row.names = c(NA, -30L))
他のいくつかの仮定は次のとおりです。
- 「PushEvent」(たとえば)が10回繰り返されても、RパッケージTraMineRを使用して配列分析を行うため、これらすべてを保持する必要があります。
- 列の長さが等しくない場合があります
- 異なる月の列間には関係がありません
- 特定の月内のデータは、最も早い時間で最初に並べ替える必要があります
- たとえば、2011年6月と2012年6月のデータは別々の列に入れる必要があります