Re: [Rd] Question about image() behavior

From: Duncan Murdoch <murdoch_at_stats.uwo.ca>
Date: Wed, 25 Nov 2009 15:57:19 -0500

On 25/11/2009 3:00 PM, Justin McGrath wrote:
> If the x vector has a gap, then image() fills in those spots using the z
> value of the nearest x value. I had expected it to just leave those spaces
> blank though.
>
> For example
> x=c(1:5,100:105)
> y=c(1:10)
> z=matrix(rnorm(100),10,10)
> image(x,y,z)
>
> I expected that to produce a figure with a wide vertical gap between x=5 and
> x=100.
>
> Is this the correct behavior? Could there be an option added to choose
> between these two behaviors? Either way, it should be stated in the
> documentation.

It's doing what is documented. Giving uneven spacing to x values just says that the rectangles being coloured by the z values are not square.

If you want to leave blanks, then put in NA values for z.

For example,

x <- c(1:6, 100:105)
y <- 1:10
z <- matrix(rnorm(110), 11, 10)

z[6,] <- NA
image(x,y,z)

Duncan Murdoch



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Wed 25 Nov 2009 - 21:01:12 GMT

This archive was generated by hypermail 2.2.0 : Thu 26 Nov 2009 - 08:30:50 GMT