Dear friends, My dataset is like the following: x y mcpvalue 0.4603578 0.6247629 1.001 0.4603715 0.6247788 1.001 0.4603852 0.6247948 1.001 0.4110561 0.5664841 0.995 The x and y variables are unsorted. I use the function image(x,y,mcpvalue) to generate a plot, but the error is that "increasing 'x' and 'y' values are expected". So i use image(x=seq(min(x),max(x)), y=seq(min(y),max(y)),z=as.matrix (result$mcpvalue)) to do it again, but there is still an error "dimensions of z are not length(x)(-1) times length(y)(-1)". Anybody can show me how to use the image() correctly with the original x/y unsorted? Thanks very much. -- With Kind Regards, oooO::::::::: (..)::::::::: :\.(:::Oooo:: ::\_)::(..):: :::::::)./::: ::::::(_/:::: ::::::::::::: [***********************************************************************] Zhi Jie,Zhang ,PHD Tel:+86-21-54237149 Dept. of Epidemiology,School of Public Health,Fudan University Address:No. 138 Yi Xue Yuan Road,Shanghai,China Postcode:200032 Email:epistat@gmail.com Website: www.statABC.com [***********************************************************************] oooO::::::::: (..)::::::::: :\.(:::Oooo:: ::\_)::(..):: :::::::)./::: ::::::(_/:::: ::::::::::::: [[alternative HTML version deleted]]
Hi look at akima package, especially its function interp. Petr petr.pikal at precheza.cz r-help-bounces at r-project.org napsal dne 08.11.2007 17:51:21:> Dear friends, > My dataset is like the following: > x y mcpvalue > 0.4603578 0.6247629 1.001 > 0.4603715 0.6247788 1.001 > 0.4603852 0.6247948 1.001 > 0.4110561 0.5664841 0.995 > The x and y variables are unsorted. > I use the function image(x,y,mcpvalue) to generate a plot, but theerror> is that "increasing 'x' and 'y' values are expected". So i use > image(x=seq(min(x),max(x)), y=seq(min(y),max(y)),z=as.matrix > (result$mcpvalue)) > to do it again, but there is still an error "dimensions of z are not > length(x)(-1) times length(y)(-1)". > Anybody can show me how to use the image() correctly with the originalx/y> unsorted? > Thanks very much. > > > -- > With Kind Regards, > > oooO::::::::: > (..)::::::::: > :\.(:::Oooo:: > ::\_)::(..):: > :::::::)./::: > ::::::(_/:::: > ::::::::::::: >[***********************************************************************]> Zhi Jie,Zhang ,PHD > Tel:+86-21-54237149 > Dept. of Epidemiology,School of Public Health,Fudan University > Address:No. 138 Yi Xue Yuan Road,Shanghai,China > Postcode:200032 > Email:epistat at gmail.com > Website: www.statABC.com >[***********************************************************************]> oooO::::::::: > (..)::::::::: > :\.(:::Oooo:: > ::\_)::(..):: > :::::::)./::: > ::::::(_/:::: > ::::::::::::: > > [[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 guidehttp://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code.
On 11/8/2007 11:51 AM, zhijie zhang wrote:> Dear friends, > My dataset is like the following: > x y mcpvalue > 0.4603578 0.6247629 1.001 > 0.4603715 0.6247788 1.001 > 0.4603852 0.6247948 1.001 > 0.4110561 0.5664841 0.995 > The x and y variables are unsorted. > I use the function image(x,y,mcpvalue) to generate a plot, but the error > is that "increasing 'x' and 'y' values are expected". So i use > image(x=seq(min(x),max(x)), y=seq(min(y),max(y)),z=as.matrix > (result$mcpvalue)) > to do it again, but there is still an error "dimensions of z are not > length(x)(-1) times length(y)(-1)". > Anybody can show me how to use the image() correctly with the original x/y > unsorted?You can't, it doesn't know how to handle that kind of data. image() is designed to display a matrix of values. The x and y values tell it where to put the rows and columns of the matrix. You have a set of points. You need to fit a surface to them, evaluate the surface on a grid, and pass that to image(). There are many ways to do that; the akima package has the interp() function for instance. Duncan Murdoch
Reasonably Related Threads
- A question about R image function
- handle dates in R?
- Generating series of distributions with the same skewness and different kurtosis or with same kurtosis and different skewness?
- Probelms on using gam(mgcv)
- Specify a correct formula in R for Piecewise Linear Functions?