[R] error with persp()- increasing 'x' and 'y' values expected

David Winsemius dwinsemius at comcast.net
Mon Feb 20 21:22:35 CET 2012


On Feb 20, 2012, at 2:15 PM, adick wrote:

> I want to use persp to graph my data and it keeps giving me the error
> increasing 'x' and 'y' values expected, even though my data is in  
> increasing
> order with respect to x and y.


Do you have missing entries? (Running your data fragment through your  
code produces the same error.) You may want to use rep with each and  
times arguments to construct a regular grid and then population the  
missing entries in  matrix with NA's.

>
> Here is the code I'm currently using:
> bob= scan ("SBA3dataTaxonB.txt",what="char")
> labels = bob[1:3]
> bob=bob[-c(1,2,3)]
> bob=as.numeric(bob)
> bob=array(bob,dim=c(3, length(bob)/3))
> bob=t(bob)
> data.frame(bob) -> bob
> bob = bob[order(bob[,1], bob[,3]),]
> persp(bob[,1], bob[,3], bob[,2], log="bob[,1]")

Any way .... The z argument to `persp` is supposed to be a matrix of  
dimension == length(x)*length(y):

?matrix

>
> The first few lines of the txt file SBA3dataTaxonB.txt look like this:
> variable	TaxonB	central
> 10	19	0.002
> 10	25	0.002
> 10	26	0.002
> 1	17	0.002
> 1	23	0.002
> 1	16	0.002
> 0.1	48	0.002
> 0.1	47	0.002
> 0.1	57	0.002
> 10	15	0.004
> 10	22	0.004
> 10	22	0.004
> 1	21	0.004
> 1	22	0.004
> 1	27	0.004
> 0.1	73	0.004
> 0.1	62	0.004
>
> Can anyone help me figure out why I am getting this error? And also a
> possible solution would be greatly appreciated.
> -Thanks, Amanda
>
> --
> View this message in context: http://r.789695.n4.nabble.com/error-with-persp-increasing-x-and-y-values-expected-tp4404834p4404834.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org 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.

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list