voodooochild at gmx.de
2006-Apr-25 09:38 UTC
[R] persp plot increasing 'x' and 'y' values expected
hello, i do the following in order to get an persp-plot x<-c(2,2,2,2,2,2,3,3,3,3) y<-c(41,41,83,83,124,166,208,208,208,208) z<-c(90366,90366,92240,92240,92240,96473,100995,100995,100995,100995) x<-data$x y<-data$y z<-matrix(data$z,length(y),length(x)) persp(x,y,z, col="gray") but i always get the error message increasing 'x' and 'y' values expected, but i think my data values are already increasing, what is wrong? best regards andreas
Michael Dondrup
2006-Apr-25 10:07 UTC
[R] persp plot increasing 'x' and 'y' values expected
Hi, yes, your x and y are increasing but the (x,y) coordinates are not unique. Looks like some measurements are redundant in your input. Michael> hello, > > i do the following in order to get an persp-plot > > x<-c(2,2,2,2,2,2,3,3,3,3) > y<-c(41,41,83,83,124,166,208,208,208,208) > z<-c(90366,90366,92240,92240,92240,96473,100995,100995,100995,100995) > x<-data$x > y<-data$y > z<-matrix(data$z,length(y),length(x)) > persp(x,y,z, col="gray") > > but i always get the error message increasing 'x' and 'y' values > expected, but i think my data values are already increasing, what is wrong? > > best regards > andreas > > ______________________________________________ > 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
voodooochild at gmx.de wrote:> hello, > > i do the following in order to get an persp-plot > > x<-c(2,2,2,2,2,2,3,3,3,3) > y<-c(41,41,83,83,124,166,208,208,208,208) > z<-c(90366,90366,92240,92240,92240,96473,100995,100995,100995,100995) > x<-data$x > y<-data$y > z<-matrix(data$z,length(y),length(x)) > persp(x,y,z, col="gray") > > but i always get the error message increasing 'x' and 'y' values > expected, but i think my data values are already increasing, what is wrong?I'm not sure what your data$x, data$y, data$z are (but I can guess). Why do you think that your x is *increasing*? Is x[i+1] > x[i]? Does diff(x) yield only positive values? What kind of a perspective plot do you expect? You seem to have only 5 unique points. Peter Ehlers> > best regards > andreas >
On Fri, 5 May 2006, Rick Bilonick wrote:> Has anyone else noticed that gstat no longer handles 1-D data? >Thanks for this report, writing directly to the package maintainer or the R-sig-geo list might have been a better choice than R-help The problem does exist, but can be worked round by inserting a constant second dimension: library(gstat) data(meuse) meuse$constY <- rep(1,nrow(meuse)) coordinates(meuse) = ~ x + constY variogram(zinc ~ 1, data=meuse) also leaving out the location formula, and using the coordinates in the SpatialPointsDataFrame object Roger> > library(gstat) > > coordinates(pm.df) <- ~x > Error in validObject(.Object) : invalid class "SpatialPoints" object: > spatial.dimension should be 2 or more > > variogram(pm~1,~x,data=pm.df) > Error in validObject(.Object) : invalid class "SpatialPoints" object: > spatial.dimension should be 2 or more > > The variogram call used to work. It stopped working when I upgraded to > the latest version of gstat. > > Rick B. > > ______________________________________________ > 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 >-- Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: Roger.Bivand at nhh.no