[R] Fitting Contour to Data Points

Liaw, Andy andy_liaw at merck.com
Mon May 16 13:59:08 CEST 2005


You can use the akima package to interpolate to a regular grid, then plot
that.  Another choice is to fit a smooth surface, using any number of
smoothers available in R and CRAN.

Andy

> From: Laura Quinn
> 
> Apologies for the mass mailing today!
> 
> I am attempting to produce a contour plot for phsical data on a map
> matrix. I have a small number of data points which each has an (x,y)
> co-ordinate together with a corresponding value which I would like to
> cvreate a contour plot for.
> 
> I have tried the following code:
> 
> contour(data$x,data$y,data$value)
> 
> but am told:
> 
> Error in contour.default(data$x, data$y, data$value) :
>         increasing x and y values expected
> 
> I have re-ordered the matrix so that the x values are increasing, but
> these do not necessarrily correspond with increasing y values 
> (as this is
> not a regular grid)...can anyone offer a way around this??
> 
> Laura Quinn
> Institute of Atmospheric Science
> School of Earth and Environment
> University of Leeds
> Leeds
> LS2 9JT
> 
> tel: +44 113 343 1596
> fax: +44 113 343 6716
> mail: laura at env.leeds.ac.uk
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html
> 
> 
>




More information about the R-help mailing list