[R] persp on x,y,z

Bill Simpson wsi at gcal.ac.uk
Mon Feb 1 14:49:45 CET 1999


I have 3 vectors x,y,z:

x<-c(-2.88,-1.92,-.96,0,.96,1.92,2.88,3.84,
-1.92,-.96,0,.96,1.92,2.88,3.84,
-.96,0,.96,1.92,2.88,3.84,
0,.96,1.92,2.88,3.84,
.96,1.92,2.88,3.84,
1.92,2.88,3.84,
2.88,3.84,
3.84)

y<-c(rep(-3.84,8),
rep(-2.88,7),
rep(-1.92,6),
rep(-.96,5),
rep(0,4),
rep(.96,3),
rep(1.92,2),
2.88)

z<-c(.65,1.78,2.4,2.54,3.04,2.22,2.97,3.56,
.745,1.287,1.98,1.91,2.02,2.24,2.95,
.47,.80,.90,1.32,1.57,2.51,
.23,.51,1.38,2.09,2.74,
.14,.88,1.87,2.84,
.40,1.61,2.48,
.78,1.93,
.87)

These data sample one triangular corner of a matrix.

I want a plot of the efficiency
zideal<- abs(x-y)/.3 
eff<- (z/zideal)^2

But I can't figure out how to get a persp() plot of eff; this doesn't
work:
persp(x,y,eff,col="grey",theta=45,phi=30)
I tried a trick using unique(x),unique(y) which didn't work.

If I define x, y and z like this:

x<-c(-1.92,-1.44,-.96,-.48,0,.48,.96,1.44,1.92)
y<-x  
z<-rbind(c(NA,.23,.98,1.90,3.60,2.70,3.2,4.11,4.03),
c(NA,NA,.39,1.24,3.85,2.40,2.89,3.26,3.92), 
c(NA,NA,NA,.56,3.26,2.14,2.37,2.67,3.16),
c(NA,NA,NA,NA,2.65,1.02,2.08,2.18,2.96),
c(NA,NA,NA,NA,NA,2.88,3.45,3.97,3.97),
c(NA,NA,NA,NA,NA,NA,.92,1.10,1.90),
c(NA,NA,NA,NA,NA,NA,NA,.33,1.02),
c(NA,NA,NA,NA,NA,NA,NA,NA,.26),
c(NA,NA,NA,NA,NA,NA,NA,NA,NA))

persp(x,y,z,col="grey",theta=45,phi=30, zlim=c(0,7))

persp works.  However I don't know how to get a plot of eff, since I
don't know how to get eff when z has this form.

So please either tell me how to get a persp plot of x,y,z when in the form
x<- x1,x2,...xn
y<-y1,y2,...yn
z<-z1,z2,...zn

OR tell me how to get the eff matrix from vectors x and y (short) and
matrix z.

Thanks very much for any help!

Bill Simpson

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list