[R] problem with the image command

Pascal Oettli kridox at ymail.com
Wed Apr 10 03:16:28 CEST 2013


Hi,

Did you carefully read the help for "image" ?

## Default S3 method:
image(x, y, z, zlim, xlim, ylim, col = heat.colors(12),
       add = FALSE, xaxs = "i", yaxs = "i", xlab, ylab,
       breaks, oldstyle = FALSE, useRaster, ...)

Regards,
Pascal


On 04/10/2013 10:07 AM, cassie jones wrote:
> Hello R-users,
>
> I am trying to do an image plot where I have been given latitudes,
> longitudes and the values at the corresponding locations. A sample of the
> data is given as follows:
>
>     values=c(0,1,0,0,0,0,2,2,0,0)
> lat=c(29.6660,29.6756,29.3492,29.2654,29.2827,29.4070,35.3510,35.6590,35.7587,38.2794)
> long=c(-95.8121,-95.6565,-95.5771,-95.4400,-95.4356,-95.0294,-81.7940,-81.4850,-81.3777,-86.9999)
>
>
> I used the following command to generate the image plot along with an U.S.
> map:
>
> library(maps)
> image(values,x=sort(long),y=sort(lat))
> map("state",add=T)
>
> But every time I run the code I get the following error:
>
> Error in image.default(values,x=sort(long),y=sort(lat),
>
> increasing 'x' and 'y' values expected
>
> Even though I sort the latitude and longitude in increasing order, I am
> getting this error. Any help is greatly appreciated.
>
> Thanks in advance,
>
> Cassie.
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list