[R] persp Error. x,y,z with the same length
Greg Snow
Greg.Snow at intermountainmail.org
Wed Apr 11 18:07:44 CEST 2007
x and y should be vectors with the coordinates, z should be a matrix
with the heights at the combination of those coordinates. If x and y
are properly gridded in your dataset, then try something like:
> h <- Measure3[,4]
> x <- sort(unique(Measure3[,3]))
> y <- sort(unique(Measure3[,2]))
> z <- matrix( h, ncol=length(x) )
> persp(x,y,z)
Hope this helps,
--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at intermountainmail.org
(801) 408-8111
> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Felix Wave
> Sent: Wednesday, April 11, 2007 8:56 AM
> To: r-help at stat.math.ethz.ch
> Subject: [R] persp Error. x,y,z with the same length
>
> Hello,
> I have a problem in drawing a 3d graphic. I simplified the
> program to show you the problem.
>
> I have a text file with hundreds of entries in 3 columns. I
> scaned these columns with matrix(scan). Then, I transformed
> some datas. Now I have the datas in h,x,y.
> I created a new matrix to use persp . But I got an error. The
> reason is probably the same length of x,y,z.
>
> But what can I do the draw my datas in a 3d graphic? (I want
> to use persp resp. image)
>
> Thanks a lot!
> Felix
>
>
> the code:
> ------------
> h <- Measure3[,4]
> x <- Measure3[,3]
> y <- Measure3[,2]
>
> z <- matrix(c(x,y,h),ncol=3)
> z
>
> persp(x, y, z)
>
>
> > z
> [,1] [,2] [,3]
> [1,] 0.0 0 0.000000000
> [2,] 0.1 0 0.000538990
> [3,] 0.2 0 0.002315760
> [4,] 0.3 0 0.005333315
> [5,] 0.4 0 0.009595005
> [6,] 0.5 0 0.015104450
> [7,] 0.6 0 0.021865495
> [8,] 0.7 0 0.029882130
> [9,] 0.8 0 0.039158475
> [10,] 0.9 0 0.049698760
>
> Default in persp.default(x, y, z) : increasing 'x' and 'y'
> values expected
>
> ______________________________________________
> 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
> and provide commented, minimal, self-contained, reproducible code.
>
More information about the R-help
mailing list