使用 ggplot 在 R 中绘制时间序列

问题描述 投票:0回答:1

我有一个包含两列的数据框。第一个是发出请求的数据时间,格式为小时:分钟:秒。第二列包含完成请求所需的分钟数。

当我在 R 基础中使用“plot()”时,它会毫无问题地为我提供基本的散点图。当我尝试将其放入 ggplot 时,我得到以下结果:

“警告:[38;5;250m所有的美学长度都是1,但是数据有87行。[36mℹ[38;5;250m 你是想使用`annotate()`吗?[39m”。

它确实显示了一个图,但它只是带有单个点的两个轴。

我已将数据框放入 dput() 函数并粘贴下面的输出

structure(list(`Order Time` = structure(c(-2209067733, -2208991620, 
-2209031808, -2209025030, -2209022501, -2209006936, -2209007168, 
-2209027968, -2209035932, -2209028941, -2209004948, -2209070934, 
-2209030418, -2209018856, -2209018041, -2209041405, -2209055940, 
-2209024891, -2209054157, -2209007145, -2208989104, -2209023868, 
-2209065315, -2208996091, -2209016728, -2209045016, -2209022746, 
-2209008132, -2209020141, -2209003186, -2209023453, -2209037310, 
-2208994122, -2209017969, -2209048043, -2209019289, -2209068394, 
-2209045114, -2208994213, -2209039028, -2209016558, -2209013258, 
-2209059017, -2208999105, -2209030858, -2209005507, -2209004852, 
-2208997739, -2209017292, -2209027275, -2209002050, -2209002360, 
-2209018231, -2209028904, -2209023644, -2208990474, -2209000518, 
-2208993688, -2209021437, -2209018324, -2208990042, -2209041306, 
-2209015105, -2208990091, -2209074416, -2209045786, -2209001815, 
-2209005009, -2209017487, -2208991033, -2209068840, -2209012408, 
-2209039642, -2209014277, -2209074441, -2209065490, -2209064888, 
-2209025754, -2209003145, -2209009233, -2209031908, -2209025111, 
-2209014456, -2208997047, -2209039772, -2209068463, -2209055958
), class = c("POSIXct", "POSIXt"), tzone = "UTC"), `Order to Final (min)` = c(311, 
112, 105, 18, 78, 50, 64, 60, 25, 238, 47, 85, 161, 78, 87, 51, 
221, 86, 170, 93, 145, 53, 56, 31, 83, 63, 86, 177, 28, 71, 72, 
40, 58, 89, 71, 40, 281, 75, 11, 70, 80, 71, 131, 108, 46, 53, 
83, 31, 43, 35, 46, 168, 42, 132, 149, 100, 154, 61, 75, 49, 
157, 56, 60, 224, 56, 55, 70, 220, 59, 145, 102, 79, 96, 423, 
67, 834, 233, 35, 87, 52, 31, 103, 50, 108, 192, 135, 56)), row.names = c(NA, 
-87L), class = c("tbl_df", "tbl", "data.frame"))

This is using 'plot(time_frame$hms, time_frame$`Order to Final (min)`)' which is what I would like to get out of ggplot

我正在尝试使用 ggplot 将其绘制为散点图

r ggplot2 time-series
1个回答
0
投票

反引号与勾号。

https://stackoverflow.com/a/36229703/6851825

ggplot(time_frame, aes(`Order Time`, `Order to Final (min)`)) + geom_point() 
© www.soinside.com 2019 - 2024. All rights reserved.