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/ has a nice example, but the code is way to complicated for my skill level!
Any help would be much appreciated - anything I have researched so far needs to have the data sorted, which is not suitable I think.
Several options present themselves,
persp()
andwireframe()
, the latter in package lattice.First some dummy data:
persp()
needs the data as thex
andy
grid locations and a matrixz
of observations.and can be plotted using:
The facets can be coloured using the
col
argument. You could do a lot worse than study the code forchartSeries3d0()
at the page you linked to. Most of the code is just drawing proper axes as neitherpersp()
norwireframe()
handleDate
objects easily.As for
wireframe()
, weYou'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).