someone sent in a question earlier about doing something in 3D so i took a stab at it purely for educational purposes ( i'm not even sure that I understood the question actually ). Unfortunately, persp gives me an error that I don't understand because it says "object y not found". I'm sending y in as a parameter to persp similar to what ?persp shows in one of oits examples so I must not be understanding something. the code is below. thanks. DF <- read.table(textConnection("station month bas 190 5 0.00 190 7 1.563 190 10 0.000 190 11 0.000 202 4 18.750 202 5 18.750 202 7 6.250 202 10 4.80 202 11 3.125 198 4 18.750 198 10 3.20 198 11 12.500 205 4 0.000 205 5 0.000 205 10 0.000 205 11 0.00"),header=TRUE,stringsAsFactors=FALSE) #print(DF) #print(str(DF)) temp1 <- seq(1,max(DF$month),length.out=max(DF$month)) temp2 <- seq(min(DF$station),max(DF$station),by=1) print(temp1) print(temp2) persp(x = seq(1,max(DF$month),length.out=max(DF$month)), y = seq(min(DF$station),max(DF$station),by=1), z = DF$bas, xlim=range(x), ylim=range(y), zlim=range(z))
<markleeds at verizon.net> wrote in news:21684940.337761205260816591.JavaMail.root at vms229.mailsrvcs.net:> someone sent in a question earlier about doing > something in 3D so i took a stab at it purely > for educational purposes ( i'm not even sure that I understood the > question actually ). > > Unfortunately, persp gives me an error that I don't understand > because it says "object y not found". I'm sending y in as a > parameter to persp similar to what ?persp shows in one of oits > examples so I must not be understanding something. the code is > below. thanks.I get a different error when I try to run your code, but I don't think that matters. You are not sending persp(), x's and y's that meet its requirements. See the help file for persp: "Arguments x, y locations of grid lines at which the values in z are measured. These must be in ascending order. " I do not think you have z's for each of your (x,y) pairs. And your values are not increasing. -- David Winsemius> > DF <- read.table(textConnection("station month bas > 190 5 0.00 > 190 7 1.563 > 190 10 0.000 > 190 11 0.000 > 202 4 18.750 > 202 5 18.750 > 202 7 6.250 > 202 10 4.80 > 202 11 3.125 > 198 4 18.750 > 198 10 3.20 > 198 11 12.500 > 205 4 0.000 > 205 5 0.000 > 205 10 0.000 > 205 11 0.00"),header=TRUE,stringsAsFactors=FALSE) > > #print(DF) > #print(str(DF)) > > temp1 <- seq(1,max(DF$month),length.out=max(DF$month)) > temp2 <- seq(min(DF$station),max(DF$station),by=1) > print(temp1) > print(temp2) > > persp(x = seq(1,max(DF$month),length.out=max(DF$month)), > y = seq(min(DF$station),max(DF$station),by=1), > z = DF$bas, > xlim=range(x), ylim=range(y), zlim=range(z)) > > ______________________________________________ > 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. > >
On 11/03/2008 2:40 PM, markleeds at verizon.net wrote:> someone sent in a question earlier about doing > something in 3D so i took a stab at it purely > for educational purposes ( i'm not even sure that I understood the question actually ). > > Unfortunately, persp gives me an error that I don't understand because it says "object y not found". I'm sending y in as a parameter to persp similar to what ?persp shows in one of oits examples so I must not be understanding something. the code is below. thanks. > > DF <- read.table(textConnection("station month bas > 190 5 0.00 > 190 7 1.563 > 190 10 0.000 > 190 11 0.000 > 202 4 18.750 > 202 5 18.750 > 202 7 6.250 > 202 10 4.80 > 202 11 3.125 > 198 4 18.750 > 198 10 3.20 > 198 11 12.500 > 205 4 0.000 > 205 5 0.000 > 205 10 0.000 > 205 11 0.00"),header=TRUE,stringsAsFactors=FALSE) > > #print(DF) > #print(str(DF)) > > temp1 <- seq(1,max(DF$month),length.out=max(DF$month)) > temp2 <- seq(min(DF$station),max(DF$station),by=1) > print(temp1) > print(temp2) > > persp(x = seq(1,max(DF$month),length.out=max(DF$month)), > y = seq(min(DF$station),max(DF$station),by=1), > z = DF$bas, > xlim=range(x), ylim=range(y), zlim=range(z))The values you pass to persp() are expressions to be evaluated in your workspace. Since you don't have variables x, y or z defined, you can't specify range(x), range(y) or range(z) as arguments. (Things are different for the defaults for the parameters: those are evaluated in the local frame set up for the call.) Duncan Murdoch