[R] problem with the image command
Pascal Oettli
kridox at ymail.com
Wed Apr 10 03:47:49 CEST 2013
Hello,
In the case:
image(x=long,y=lat,z=values)),
"long" is not in (strictly) ascending order, according to the sample you
provided:
plot(long)
Regards,
Pascal
On 04/10/2013 10:28 AM, cassie jones wrote:
> Yes, I did. But I get the following error with the command
> image(x=long,y=lat,z=values)
>
> "Error in image.default(x=long,y=lat,z=values):
> error in evaluating the argument 'x' in selecting a method for
> function 'image': Error in long: recursive indexing failed at level 2"
>
>
> Thanks,
> Cassie
>
> On Tue, Apr 9, 2013 at 8:16 PM, Pascal Oettli <kridox at ymail.com
> <mailto:kridox at ymail.com>> wrote:
>
> 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 <mailto:R-help at r-project.org> mailing list
> https://stat.ethz.ch/mailman/__listinfo/r-help
> <https://stat.ethz.ch/mailman/listinfo/r-help>
> PLEASE do read the posting guide
> http://www.R-project.org/__posting-guide.html
> <http://www.R-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>
>
More information about the R-help
mailing list