increasing 'x' and 'y' values expected
r
Solution
As the error message implies, one problem is that in `y<-c(10:1)` the y values do not increase...
Besides, z needs to be an x*y matrix.
So try the following:
x<-c(1:10)
y<-c(1:10)
z<-matrix(x,nrow=length(x),ncol=length(y)
persp(x,y,z, theta = 30, phi = 30, expand = 0.5, col = "lightblue")
Problem
I want to do a very simple 3D plot with this code: ``` x<-c(1:10) y<-c(10:1) z<-cbind(x,y) persp(x,y,z, theta = 30, phi = 30, expand = 0.5, col = "lightblue") ``` but I get this error: ``` Error in persp.default(x, y, z, theta = 30, phi = 30, : increasing 'x' and 'y' values expected ``` what should I do exactly to solve this problem? UPDATE If I change my data. For example for x ``` test<-c(0.4118836, 0.3481329, 0.3582897, 0.3122690, 0.3346040, 0.2409363, 0.2474494, 0.1744042, 0.1589965, 0.2435564) ``` and then ``` x<-test y<-c(1:10) z<-matrix(x,nrow=length(x),ncol=length(y)) persp(x,y,z, theta = 30, phi = 30, expand = 0.5, col = "lightblue") ``` I am getting the same error