[R] persp plot
Ben Bolker
bolker at ufl.edu
Wed Jun 25 16:05:31 CEST 2008
Chad Junkermeier <junkermeier <at> byu.edu> writes:
>
> I have a set of data in the form
> x1, y1, z1
> x1, y2, z2
> ...
> x1, yN, zN
> x2, y1, z(N+1)
> x2, y2, z(N+2)
> ...
> x2, yN, z(2N)
> ...and so on...
> xM, yN, val(M*N)
>
> Do you have any suggestions?
Not at all carefully tested, but:
## make up data
x = 1:50
y = 1:50
z = outer(x,y,function(x,y) sin(2*pi*(x/10))+cos(2*pi*(y/25))^2)
v = expand.grid(x,y)
dat = data.frame(x=v[,1],y=v[,2],z=c(z))
## data as they would be read from your original data file
persp(x=unique(dat$x),y=unique(dat$y),dat$z)
[in my example x changes more rapidly than y. You
may need to play around with the identities of x and y]
More information about the R-help
mailing list