创建不规则时间序列图的最简单方法(R?GGPLOT?ITS?)
我是一名图形设计师,正在尝试使用 R 创建对于 Excel 来说过于复杂的图表。我专门尝试创建一个不规则的时间序列步骤图。我在创建常规时间序列图表时没有遇到任何问题,但由于某种原因,不规则的日期使一切都变得混乱。
我从一个包含两列数据的基本文本文件开始:
01-04-1940 4
05-29-1963 35
12-02-2002 24
我已经使用加载了数据
d <- read.delim("file.txt", header = TRUE)
,并且已经使用 Unix 时间转换了第一列
d$date <- as.Date(d$date, format = "%m-%d-%Y")
但是目前,我在任何地方都找不到有关如何操作的更多信息继续。我已经看过 R 包“ITS”,但除了所涉及的类的技术描述之外,我找不到任何关于它的文档。
如果有一些 R 经验的人能够指出创建此图所需的几行代码,我将非常感激。谢谢!
I'm a graphic designer who is trying to use R to create graphs that are too complicated for Excel. I'm specifically trying to create an irregular time series step chart. I've had no problems creating a regular time series chart, but for some reason, the irregular dates are throwing everything off.
I'm starting with a basic text file with two columns of data:
01-04-1940 4
05-29-1963 35
12-02-2002 24
I've loaded the data using
d <- read.delim("file.txt", header = TRUE)
and I've converted the first column in Unix time using
d$date <- as.Date(d$date, format = "%m-%d-%Y")
But at this point, I can't find any more information anywhere on how to proceed. I've seen the R package "ITS," But I cannot find any documentation on it beyond technical descriptions of the classes involved.
I'd much appreciate it if someone with some experience in R could point out the few lines of code I need to create this graph. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
ggplot 可以很好地处理日期格式的数据。以下是一些建议:
ggplot
deals quite nicely with data in date format. Here are some suggestions:我会使用 xts/zoo。它们都可以轻松处理不规则的时间序列。
I would use xts/zoo. They both handle irregular time series easily.