0

I have a big dataset with x, y, and z and two other variables. I want to plot them in a way that I can make 3D slides out of the data with a 4th (and later also with a 5th) variable as a color index.

I am trying to use slice3D() from package plot3D but my data is not in the correct form and I can't figure out how to organise the data. The code I want to use:

library(plot3D)
slice3D(x = x, z = z_NAP, y = y, colvar = ampl, 
        ys = 1:10, zs = NULL, NAcol = "black", 
        expand = 0.4, theta = 45, phi = 45)

The data looks like this:

x=c(53024.14,53024.14,63024.14,53024.14,53024.14,53023.98,53023.98,53023.98,53023.98, 53023.98,63023.98)
y=c(403100.1,403100.1,403100.1,403100.1,403100.1,403100.2,403100.2,403100.2,403100.2,403100.2,403100.2)
z_NAP=c(-2.2695537,-2.5505537,-2.7335537,-2.9175537,-3.2265537,1.1271519,0.9331519,0.6431519,0.4791519,0.2951519,0.0251519)
ampl=c(7196,195,5103,4537,6763,1207,2059,14121,26126,11850,9883)

I sorted the xyz data with interp because I have the same values for the x and y while z is changing.

s100<-interp(x, y, z, xo=seq(min(x), max(x), length=30), 
             yo=seq(min(y), max(y), length=30), duplicate="mean")

I have a matrix of x y with z values in it. But now I need to make matrix containing xyz and the other variable.

I've got this matrix:

dim(s100$z)
30 30 

And I need ampl to be 30 x 30 x 30.

Werner Hertzog
  • 2,002
  • 3
  • 24
  • 36
IlhameO
  • 35
  • 7
  • Would the `array` function do what you need? You use it in a similar way to the `matrix` function, but you can have as many variables as you like. – CJB Jul 21 '15 at 08:39
  • I looked at that but I need a regualar grid. I have got the regular grid (with interp) but i need to put the 4th variable in there. – IlhameO Jul 21 '15 at 09:50

0 Answers0