[R] error with persp()- increasing 'x' and 'y' values expected
David Winsemius
dwinsemius at comcast.net
Tue Feb 21 05:08:33 CET 2012
On Feb 20, 2012, at 5:49 PM, adick wrote:
>
> On Feb 20, 2012, at 2:15 PM, adick wrote:
>
> 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.
>
>
>
> Yes, there are missing entries. I don't know what rep and times
> arguments
> are or how to do anything you just said, because I'm knew to R.
?rep
> rep(1:3, times=3)
[1] 1 2 3 1 2 3 1 2 3
> rep(1:3, each=3)
[1] 1 1 1 2 2 2 3 3 3
You can also use gl
?gl
--
David.
>
> I did however figure out how to take the average of my three
> replicates and
> try to plot that, which returns the same error. Here is the updated
> code:
>
> 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
> vary=0
> varx= 0
> varz=0
>
> for (r in 1:(length(bob[,1])/3)) {
> vary[r] <- mean(bob[(1+((r-1)*3)):(3+((r-1)*3)),2])
> varx[r] <- bob[(1+((r-1)*3)),1]
> varz[r] <- bob[(1+((r-1)*3)),3]
> }
> rob <- data.frame(varx=varx,varz=varz,vary=vary)
>
> rob = rob[order(rob[,1], rob[,2]),]
> persp(rob[,1], rob[,2], rob[,3], log="rob[,1]")
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/error-with-persp-increasing-x-and-y-values-expected-tp4404834p4405380.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