0
準備一個愚蠢的問題...R:在時間序列上繪製重複
我有一個大的數據集,看起來有點像這個..
structure(list(V1 = structure(c(4L, 3L, 6L, 5L, 1L, 2L), .Label = c("1012",
"225", "58", "602", "62", "818"), class = "factor"), V2 = structure(c(4L,
3L, 6L, 5L, 1L, 2L), .Label = c("1012", "249", "58", "603", "62",
"824"), class = "factor"), V3 = structure(c(6L, 2L, 5L, 4L, 1L,
3L), .Label = c("1014", "117", "290", "442", "831", "992"), class = "factor"),
V4 = structure(c(6L, 3L, 5L, 2L, 1L, 4L), .Label = c("1033",
"1055", "166", "377", "831", "992"), class = "factor"), V5 = structure(c(3L,
4L, 6L, 2L, 1L, 5L), .Label = c("1033", "1067", "1575", "190",
"378", "832"), class = "factor"), V6 = structure(c(3L, 4L,
6L, 2L, 1L, 5L), .Label = c("1034", "1069", "1575", "221",
"379", "833"), class = "factor"), V7 = structure(c(3L, 5L,
6L, 2L, 1L, 4L), .Label = c("1063", "1092", "2351", "379",
"406", "834"), class = "factor")), .Names = c("V1", "V2",
"V3", "V4", "V5", "V6", "V7"), class = "data.frame", row.names = c(NA,
6L))
每一行代表一個主題,並且沿着列移動的每個值表示鼠標按下槓桿的會話內的時間(以秒爲單位)。我想用ggplot來製作一個類似於this的數字。然而,我似乎無法弄清楚如何繪製一個時間序列,因爲ggplot似乎想要一個名爲x和y的離散值。我可以想出勞動密集型的方法來實現它,但我知道我只是想念一些簡單的東西。
ggplot2函數可處理長格式的數據。你需要在這些數據上使用reshape2 :: melt來獲得長格式。它應該是一塊蛋糕。 (並且應該有很多有效的例子。) –
我會研究它。謝謝!仍然試圖圍繞看似無休止的方式在R中對數據進行格式化,以使其在各種功能中發揮出色。 – user2510207