简体   繁体   English

如何在R中指定日期的x轴值

[英]how to specify x-axis value for date in R

I want to figure out when exactly the number of calls sharply increased.我想弄清楚呼叫数量何时急剧增加。

Here is my original code:这是我的原始代码:

plot(breaks, cumfreq0, main="Cumulative percentage of calls happened in NOV.7th", xlab="time", ylab = "cumulative percentage of calls", sub = "(each dot represents a single period of time on Nov.7th)")

阴谋

but I don't think the time scale on the x-axis is specific enough.但我认为 x 轴上的时间刻度不够具体。 How can I change it?我怎样才能改变它?

I tried some times as shown here but it seems that codes does fit time object.我尝试了几次,如下所示但似乎代码确实适合时间对象。

在此处输入图片说明 Many many thanks for any help非常感谢您的帮助

Please see below, i just replicated your example with dummy data 请看下面,我只是用虚拟数据复制了您的示例

> df
# A tibble: 55 x 2
   datetime             Freq
   <dttm>              <int>
 1 2018-11-01 12:41:57   215
 2 2018-11-01 12:41:58   163
 3 2018-11-01 12:47:06   225
 4 2018-11-01 12:51:00    69
 5 2018-11-01 12:57:37   203
 6 2018-11-01 12:57:38   248
 7 2018-11-01 12:57:38    58
 8 2018-11-01 13:29:15   179
 9 2018-11-01 13:37:45   233
10 2018-11-01 14:24:43   150
# ... with 45 more rows

And the code to kind of plot you are expecting with x-axis as timestamp and you can give whichever format you want 以及以x轴作为时间戳的期望绘图类型的代码,您可以指定所需的格式

plot(df$datetime,df$Freq,xaxt="n")
axis.POSIXct(1, at=df$datetime, labels=format(df$datetime, "%m/%d/%Y %H:%M:%S"))

以x轴为时间戳输出图像

Thanks to Sai Prabhanjan, here is my current code and plot! 感谢Sai Prabhanjan,这是我当前的代码和绘图!

enter image description here enter image description here 在此处 输入图像描述在 此处 输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM