R-beta: image(x,y,z)?
Bill Simpson
wsimpson at uwinnipeg.ca
Tue Apr 28 17:28:21 CEST 1998
Ok now I've read in my dataframe. The file is set up like this:
x y z
1 1 1
1 2 2
1 3 5
2 1 3
2 2 9
2 3 2
3 1 8
3 2 4
3 3 7
I can get at data$x, data$y, data$z. I want to do an image plot. Ideally
image (or a relative of image) would accept the vectors data$x, data$y,
data$z as arguments. (After all, if you can do plot(x,y) on vectors x and
y, why can't you do image(x,y,z) on vectors x, y, and z?) However it
doesn't work like that.
I have been fooling around with image. The examples show something like
x<-seq(0,1)
y<-x
func<-function(x,y) {x/(x+y)}
z<-outer(x,y,"func")
image(z)
or
image(x,y,z)
The bit with outer is required to make z a matrix.
I tried this idea:
x<-seq(1,4)
y<-x
z<-seq(1,16)
func<-function(x,y) {z}
z<-outer(x,y,"func")
# z
# [,1] [,2] [,3] [,4]
#[1,] 1 5 9 13
#[2,] 2 6 10 14
#[3,] 3 7 11 15
#[4,] 4 8 12 16
image(x,y,z,col=gray(16:1/16))
I still have the problem that in reality my x and y vectors are not in
ascending order as required by image.
Anyway, can someone please explain how to get my data into a form
acceptable to image? Thanks very much!
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