从时间序列数据在研发制作3D曲面 [英] Making a 3D surface from time series data in R

查看:274
本文介绍了从时间序列数据在研发制作3D曲面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个大的数据集,我想从做一个三维表面。我想,x轴是时间,y轴为时间(24小时)和z轴(高度)为值我有($)。我是其中R是初学者,所以越简单越好!

I have a large data set which I would like to make a 3D surface from. I would like the x-axis to be the date, the y-axis to be the time (24h) and the z-axis (height) to be a value I have ($). I am a beginner with R, so the simpler the better!

http://www.quantmod.com/examples/chartSeries3d/ 有一个很好的例如,而code是方式复杂,我的技术水平!

http://www.quantmod.com/examples/chartSeries3d/ has a nice example, but the code is way to complicated for my skill level!

任何帮助将是非常美联社preciated - 什么,我已经研究到目前为止都需要有数据排序,这是不适合我觉得

Any help would be much appreciated - anything I have researched so far needs to have the data sorted, which is not suitable I think.

推荐答案

若干选项present自己, persp()线框( ),在封装后的

Several options present themselves, persp() and wireframe(), the latter in package lattice.

首先,一些虚拟数据:

set.seed(3)
dat <- data.frame(Dates = rep(seq(Sys.Date(), Sys.Date() + 9, by = 1), 
                              each = 24),
                  Times = rep(0:23, times = 10),
                  Value = rep(c(0:12,11:1), times = 10) + rnorm(240))

persp()所需要的数据作为 X 格位置和矩阵以Z 的意见。

persp() needs the data as the x and y grid locations and a matrix z of observations.

new.dates <- with(dat, sort(unique(Dates)))
new.times <- with(dat, sort(unique(Times)))
new.values <- with(dat, matrix(Value, nrow = 10, ncol = 24, byrow = TRUE))

和可以使用作图

persp(new.dates, new.times, new.values, ticktype = "detailed", r = 10, 
      theta = 35, scale = FALSE)

该面可以使用 COL 参数进行着色。你可以做很多事情不如学习你链接到页面的$ C $下 chartSeries3d0()。大部分的code是刚绘制适当的轴既不 persp()线框()办理日期轻松的对象。

The facets can be coloured using the col argument. You could do a lot worse than study the code for chartSeries3d0() at the page you linked to. Most of the code is just drawing proper axes as neither persp() nor wireframe() handle Date objects easily.

至于线框(),我们

require(lattice)
wireframe(Value ~ as.numeric(Dates) + Times, data = dat, drape = TRUE)

您需要做一点或工作,理清轴标记为线框()不与类的对象工作 日期的时刻(所以要转换为数字)。

You'll need to do a bit or work to sort out the axis labelling as wireframe() doesn't work with objects of class "Date" at the moment (hence the cast as numeric).

这篇关于从时间序列数据在研发制作3D曲面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆